-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: implement Ory Hydra v2.0 #2796
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2796 +/- ##
==========================================
- Coverage 79.26% 76.72% -2.55%
==========================================
Files 111 123 +12
Lines 8107 8846 +739
==========================================
+ Hits 6426 6787 +361
- Misses 1263 1634 +371
- Partials 418 425 +7
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
x/sqlx.go
Outdated
|
||
// NullDuration represents a nullable JSON and SQL compatible time.Duration. | ||
// | ||
// TODO delete this type and replace it with ory/x/sqlxx/NullDuration when applying the custom client token TTL patch to Hydra 2.x |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@aeneasr We user swagger:ignore
here, but sqlxx uses a different swagger definition. Can you think of any way to depend on sqlxx's implementation while keeping our swagger:ignore
?
33cd424
to
0594435
Compare
64644b0
to
72f7f1f
Compare
To Do
hydra clients create
commands and remove--id
flag and rename--callback
to--redirect-uris
--dangerous-force-http
in docsChanges Requiring Attention
Changes you must know about!
Cookies
New cookie configuration options have been introduced, allowing a higher degree of control:
The default names of cookies have changed:
Use the new configuration option to change the cookie names back to v1.x if required:
PBKDF2 and Bcrypt Client Secret Hashing
This release adds support for hashing OAuth2 Client Secrets using pbkdf2 instead of bcrypt, which might be a more appropriate algorithm in certain settings. As we assume that most environments fall in this category, we also changed the default to pbkdf2 with 25.000 rounds (roughly 1-3ms per hash on an Apple M1 Max core).
High hash costs are needed when hashing user-chosen passwords, as users often reuse passwords across sites. A high hash cost will make it much harder for the attacker to guess the user-chosen password and try using it on other sites (e.g. Google).
As most client secrets are auto-generated, using high hash costs is not useful. The password (OAuth2 Client Secret) is not user chosen and unlikely to be reused. As such, there is little point in using excessive hash costs to protect users. High hash costs in a system like Ory Hydra will cause high CPU costs from mostly automated traffic (OAuth2 Client interactions). It has also been a point of critizism from some who wish for better RPS on specific endpoints.
Other systems like Keycloak do not hash client secrets at all, referencing more secure authentication mechanisms such as assertion-based client authentication.
We and the IETF disagree though, as rfc6819#section-5.1.4.1.3 states:
For that reason, cleartext storage of client secrets is not going to be supported.
BREAKING CHANGE: This change is backwards compatible, but changes the default hashing algorithm to PBKDF2. To keep using BCrypt for hashing new OAuth2 Client Secrets set the following configuration option in your configuration file:
Token Prefixes
This release adds token prefixes to access tokens (
ory_at_
), refresh tokens (ory_rt_
), and authorize codes (ory_ac_
). Token prefixes are useful when scanning for secrets in e.g. git repositories. Token prefixes are only use for opaque tokens, not JSON Web Tokens as that would invalidate the JSON Web Tokens.Tokens issued before this change will continue working!
OAuth2 Client ID Generated
It is no longer possible to set arbitrary OAuth 2.0 Client IDs. Instead, OAuth 2.0 Client IDs are generated by Ory Hydra. Clients created before the 2.0 release will continue to work with their legacy IDs.
This change was made to improve scalability of the number of clients in distributed databases such as CockroachDB. Ory Hydra v3.0 will most likely remove support for these legacy IDs. Please start migrating your users to new OAuth2 Clients.
New
--dev
modeTo better support local development, a new flag
--dev
has been added. With--dev
it is possible to use to usehttp
andlocalhost
URLs. If--dev
is not set, URLs (e.g. the consent url) must behttps
and non-localhost.iss
no longer has a forced trailing slashThe
iss
(issuer) value no longer appends a trailing slash but instead uses the raw value set in the config.Setting
has changed
To set a trailing slash make sure to set it in the config value:
Database schema
This release comes with significant changes to the database schema, which affect most tables in Hydra. Some of the notable changes include:
We've also upgraded the databases used in tests and examples to the following versions:
Config hot reloading
Ory Hydra is now capable of hot reloading any OAuth2-related configuration setting and no longer needs to be restarted to change certain values (e.g. the access token strategy).
TLS
The CLI flag
--dangerous-force-http
has been removed. To control TLS, use the TLS configuration instead:Please keep in mind that TLS is disabled by default as we expect most deployments to run behind a proxy which does TLS termination.
TLS termination requirement
The TLS Termination Middleware Requirement has been removed. The TLS Termination configuration flags have no effect any more and can be removed.
JSON Web Key generation
Previously, JSON Web Keys were generated in public and private key pairs with
public:
andprivate:
prefixes. This practice has been removed. Generating new JSON Web Key will from now on return one key in the JSON Web Key SetDeployments with keys generated in Ory Hydra v1.x will continue to work!
Admin routes
To match compatibility with other Ory services, we have moved all admin APIs under the
/admin
prefix on the admin port. There are redirects set up, but we encourage to upgrade the SDK and paths in your system to match the new prefix.Breaking changes
Changes which require code adjustments.
CLI
The CLI has been reworked and now follows the structure of Ory Keto, Ory Kratos, and the Ory CLI. Mostly, commands and flags have been renamed, and support for output formats and STDIN have been added. Please head over to the CLI documentation to get a sense of the new Ory CLI.
To highlight the changes, here are some examples:
Please note that all environment variables named
HYDRA_ADMIN_URL
andHYDRA_URL
have been renamed and unified underORY_SDK_URL
HTTP Flush Endpoint Removed
The HTTP Endpoint
/oauth/flush
has been removed. The command was not useful and had a tendency to time out. Please use thehydra janitor
command instead.SDKs
Ory Hydra 2.0 moved to the OpenAPI spec for SDK generation. API methods and payload names also were updated to match other services in the ecosystem. Please check the respective SDK code documentation when upgrading.