Commit Graph

144 Commits

Author SHA1 Message Date
Henning Perl 5f41949ad2
feat: remove login session cookie during consent flow (#3667) 2023-11-15 10:05:49 +01:00
Henning Perl 19857d20b1
feat: add prompt=registration (#3636)
Ory Hydra now supports a `registration` value for the `prompt` parameter of
the authorization request. When specifying `prompt=registration`, Ory Hydra
will redirect the user to the URL found under `urls.registration`
(instead of `urls.login`).
2023-09-29 10:01:35 +02:00
Patrik 5c8e7923ed
feat: add authentication options to hooks (#3633) 2023-09-25 11:09:43 +02:00
Patrik 5dd7d306ba
feat: re-enable legacy client IDs (#3628)
This patch changes the primary key of the `hydra_client` table. We do not expect issues, as that table is probably not overly huge in any deployment. We do however highly recommend to test the migration performance on a staging environment with a similar database setup.
2023-09-19 11:20:23 +02:00
Henning Perl 0176adc178
fix: verifiable credentials JWT format (#3614) 2023-08-23 17:19:32 +02:00
Henning Perl 9f1c8d1920
fix: add kid to verifiable credential header (#3606) 2023-08-16 14:12:43 +02:00
Arne Luenser 1d73d83eb0
fix: reject invalid JWKS in client configuration / dependency cleanup and bump (#3603) 2023-08-11 16:33:22 +02:00
Henning Perl 219a7c068f
feat: add support for OIDC VC (#3575)
This adds initial support for issuing verifiable credentials
as specified in https://openid.net/specs/openid-connect-userinfo-vc-1_0.html.

Because the spec is still in draft, public identifiers are
suffixed with `draft_00`.
2023-08-04 10:57:36 +02:00
Henning Perl f29fe3af97
feat: stateless authorization code flow (#3515)
This patch optimizes the performance of authorization code grant flows by minimizing the number of database queries. We acheive this by storing the flow in an AEAD-encoded cookie and AEAD-encoded request parameters for the authentication and consent screens. 

BREAKING CHANGE:

* The client that is used as part of the authorization grant flow is stored in the AEAD-encoding. Therefore, running flows will not observe updates to the client after they were started.
* Because the login and consent challenge values now include the AEAD-encoded flow, their size increased to around 1kB for a flow without any metadata (and increases linearly with the amount of metadata). Please adjust your ingress / gateway accordingly.
2023-06-12 20:27:00 +02:00
Serhii Halchenko 9bdf225d8f
feat: add token request hooks for all grant types (#3427)
Added a generic token hook that is called for all grant types and includes `payload` with a single allowed value - `assertion` to cover the `jwt-bearer` grant type customization.

The existing `refresh token hook` is left unchanged and is considered to be deprecated in favor of the new hook logic. The `refresh token hook` will at some point be removed.

Closes #3244
Closes https://github.com/ory/fosite/issues/729
2023-03-26 12:35:52 +02:00
Arne Luenser f56e5fad74 fix: append /v2 to module path 2023-01-28 08:40:41 +01:00
Arne Luenser 488f930e4f fix: clean up unused code 2023-01-28 08:40:41 +01:00
hackerman c54b9dbf9a
fix: add v2 suffix (#3340) 2022-11-05 17:53:04 +02:00
Kevin Goslar d768cf6580
docs: standardize license headers (#3216) 2022-11-03 10:10:12 -05:00
aeneasr e800002d09 refactor(sdk): consent SDK
BREAKING CHANGE: SDK naming has changed for the following operations:

```patch
ory.
-   V0alpha2Api.AdminRevokeOAuth2ConsentSessions(cmd.Context()).
+   OAuth2Api.RevokeOAuth2ConsentSessions(context.Background()).
    Client(clientId).Execute()

ory.
-   V0alpha2Api.AdminListOAuth2SubjectConsentSessions(cmd.Context(), id).
+   OAuth2Api.RevokeOAuth2ConsentSessions(context.Background()).
    Client(clientId).Execute()

ory.
-   V0alpha2Api.AdminListOAuth2SubjectConsentSessions(context.Background()).
+   OAuth2Api.ListOAuth2ConsentSessions(context.Background()).
    Subject(subjectId).Execute()

ory.
-   V0alpha2Api.AdminRevokeOAuth2LoginSessions(context.Background()).
+   OAuth2Api.RevokeOAuth2LoginSessions(context.Background()).
    Subject(subjectId).Execute()

ory.
-   V0alpha2Api.AdminGetOAuth2LoginRequest(context.Background()).
+   OAuth2Api.GetOAuth2LoginRequest(context.Background()).
    LoginChallenge(challenge).Execute()

ory.
-   V0alpha2Api.AdminAcceptOAuth2LoginRequest(context.Background()).
+   OAuth2Api.AcceptOAuth2LoginRequest(context.Background()).
    AcceptOAuth2LoginRequest(body).
    LoginChallenge(challenge).Execute()

ory.
-   V0alpha2Api.AdminRejectOAuth2LoginRequest(context.Background()).
+   OAuth2Api.RejectOAuth2LoginRequest(context.Background()).
    RejectOAuth2Request(body).
    LoginChallenge(challenge).Execute()

ory.
-   V0alpha2Api.AdminGetOAuth2ConsentRequest(context.Background()).
+   OAuth2Api.GetOAuth2ConsentRequest(context.Background()).
    ConsentChallenge(challenge).Execute()

ory.
-   V0alpha2Api.AdminAcceptOAuth2ConsentRequest(context.Background()).
+   OAuth2Api.AcceptOAuth2ConsentRequest(context.Background()).
    AcceptOAuth2ConsentRequest(body).
    ConsentChallenge(challenge).Execute()

ory.
-   V0alpha2Api.AdminRejectOAuth2ConsentRequest(context.Background()).
+   OAuth2Api.RejectOAuth2ConsentRequest(context.Background()).
    RejectOAuth2Request().
    ConsentChallenge(challenge).Execute()

ory.
-   V0alpha2Api.AdminAcceptOAuth2LogoutRequest(context.Background()).
+   OAuth2Api.AcceptOAuth2LogoutRequest(context.Background()).
    LogoutChallenge(challenge).
    Execute()

ory.
-   V0alpha2Api.AdminRejectOAuth2LogoutRequest(context.Background()).
+   OAuth2Api.RejectOAuth2LogoutRequest(context.Background()).
    LogoutChallenge(challenge).
    Execute()

ory.
    V0alpha2Api.AdminGetOAuth2LogoutRequest(context.Background()).
+   OAuth2Api.GetOAuth2LogoutRequest(context.Background()).
    LogoutChallenge(challenge).
    Execute()

- var AlreadyHandledError HandledOAuth2LoginRequest
+ var AlreadyHandledError ErrorOAuth2LoginRequestAlreadyHandled

- var AlreadyHandledError HandledOAuth2LoginRequest
+ var AlreadyHandledError ErrorOAuth2ConsentRequestAlreadyHandled

- var OAuth2SuccessResponse SuccessfulOAuth2RequestResponse
+ var OAuth2SuccessResponse OAuth2RedirectTo
```
2022-10-11 17:01:24 +02:00
aeneasr cb742ad0d6 refactor(sdk): rename oauth2 client operations and payloads
BREAKING CHANGE: The SDK API for the following has changed:

```patch
// Go example
ory.
-   V0alpha2Api.AdminUpdateOAuth2Client(cmd.Context(), id)
+   Oauth2Api.SetOAuth2Client(cmd.Context(), id).
    OAuth2Client(client).Execute()

ory.
-   V0alpha2Api.AdminGetOAuth2Client(cmd.Context(), id).
+   Oauth2Api.GetOAuth2Client(cmd.Context(), id).
    Execute()

ory.
-   V0alpha2Api.AdminDeleteOAuth2Client(cmd.Context(), id).
+   Oauth2Api.DeleteOAuth2Client(cmd.Context(), id).
    Execute()

ory.
-   V0alpha2Api.AdminCreateOAuth2Client(cmd.Context()).
+   Oauth2Api.CreateOAuth2Client(cmd.Context()).
    OAuth2Client(client).Execute()

ory.
-   V0alpha2Api.DynamicClientRegistrationGetOAuth2Client(cmd.Context(), id).
+   OidcApi.GetOidcDynamicClient(cmd.Context(), id).
    Execute()

ory.
-   V0alpha2Api.DynamicClientRegistrationGetOAuth2Client(cmd.Context()).
+   OidcApi.CreateOidcDynamicClient(cmd.Context()).
    OAuth2Client(client).Execute()

ory.
-   V0alpha2Api.DynamicClientRegistrationDeleteOAuth2Client(cmd.Context()).
+   OidcApi.DeleteOidcDynamicClient(cmd.Context()).
    OAuth2Client(client).Execute()

ory.
-   V0alpha2Api.DynamicClientRegistrationUpdateOAuth2Client(cmd.Context(), id).
+   OidcApi.SetOidcDynamicClient(cmd.Context(), id).
    Execute()
```
2022-10-11 17:01:24 +02:00
aeneasr da0feb7554 chore: format 2022-09-07 08:10:31 +02:00
Ferdynand Naczynski ac279c38f7 chore: change metric name and make Go 1.19 compatible (#3223) 2022-09-07 08:10:31 +02:00
aeneasr a364db4ff2 fix: move to v0alpha2 api spec 2022-09-07 08:10:31 +02:00
aeneasr dc11913681 chore: code review 2022-09-07 08:10:31 +02:00
Grant Zvolsky 51600f499d test: fix a flaky test 2022-09-07 08:10:31 +02:00
Grant Zvolský 9ef671f284 feat: custom client token ttl (#3206)
This change introduces a new endpoint that allows you to control how long client tokens last. Now you can configure the lifespan for each valid combination of Client, GrantType, and TokenType.

See #3157

Co-authored-by: aeneasr <3372410+aeneasr@users.noreply.github.com>
Co-authored-by: Andreas Bucksteeg <andreas@bucksteeg.de>
2022-09-07 08:10:31 +02:00
aeneasr 937e6baabf fix: resolve internal SDK regressions 2022-09-07 08:10:31 +02:00
Grant Zvolsky 53d225a980 refactor: finalize consent SDK methods 2022-09-07 08:10:31 +02:00
aeneasr 34dfc0fe57 unstaged - refactor sdk use across the board 2022-09-07 08:10:31 +02:00
Grant Zvolsky 0752721dd8 refactor(client): rename SDK methods and introduce `/admin` prefix
BREAKING CHANGE: This release updates SDK services from `public` and `admin` to `v2`. Methods exposed at the admin interface are now prefixed with `admin` (e.g. `adminCreateOAuth2Client`). Administrative endpoints now have an `/admin` prefix (e.g. `POST /admin/clients`). Existing administrative endpoints will redirect to this new prefixed path for backwards compatibility.
2022-09-07 08:10:31 +02:00
aeneasr ddba42f498 feat: support alternate hashing algorithms for client secrets
This patch adds support for hashing 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](https://groups.google.com/g/keycloak-dev/c/TmsNfnol0_g), 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](https://datatracker.ietf.org/doc/html/rfc6819#section-5.1.4.1.3) states:

> The authorization server should not store credentials in clear text.
   Typical approaches are to store hashes instead or to encrypt
   credentials.  If the credential lacks a reasonable entropy level
   (because it is a user password), an additional salt will harden the
   storage to make offline dictionary attacks more difficult.

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:

```
oauth2:
  hashers:
    algorithm: bcrypt
```
2022-09-07 08:10:31 +02:00
aeneasr 5835ede15c chore: update fosite dependency 2022-09-07 08:10:31 +02:00
aeneasr 1100aba1e1 test: fix flaky equal check 2022-09-07 08:10:31 +02:00
aeneasr 82ba44672a chore: update formatter and formatting 2022-09-07 08:10:31 +02:00
aeneasr 2c4615cea9 test: fix flaky equal check 2022-09-07 08:10:31 +02:00
aeneasr 9a4f9e9993 fix: client specific CORS
Closes #1754
2022-09-07 08:10:31 +02:00
aeneasr 4002224439 refactor(client): make OAuth2 Client IDs system-chosen and immutable
BREAKING CHANGE: To improve security and scalability (in particular sharding), OAuth 2.0 Client IDs can no longer be chosen but are always assigned a random generated UUID V4. OAuth 2.0 Clients created with custom IDs before the v2.0 release will continue working with their legacy Client ID in Ory Hydra v2.x.

Additionally, the `hydra create client` command no longer supports flag `--id` and flag `--callbacks` has been renamed to `--redirect-uris`.

Closes #2911
2022-09-07 08:10:31 +02:00
Zach Abney afa2ea0303 feat: add ability to allow token refresh from hook without overriding the session claims (#3146)
Closes #3082
2022-09-07 08:10:31 +02:00
aeneasr bbe0406df6 feat: config hot reloading architecture 2022-09-07 08:10:31 +02:00
Grant Zvolský 1d9891dcf1 fix: use StringSliceJSONFormat instead of StringSlicePipeDelimiter (#3112)
Closes https://github.com/ory/hydra/issues/2859
2022-09-07 08:10:31 +02:00
Grant Zvolsky 8e961d0eb3 code review 2022-09-07 08:10:31 +02:00
Grant Zvolsky 00490cbbc5 code review: generate first NID randomly; add/update tests; fix db-diff 2022-09-07 08:10:31 +02:00
Grant Zvolsky b7fc2bff53 feat: implement NID 2022-09-07 08:10:31 +02:00
aeneasr 7128ad2a06 fix: remove special char from snapshot symbols 2022-08-25 14:30:36 +02:00
aeneasr d40b1daf2b fix: improve refresh webhook getter 2022-08-25 14:17:35 +02:00
Serhii Halchenko 6d23859009
feat: add session and requester to refresh token webhook data (#3204)
Closes #3203
2022-08-01 13:27:25 +02:00
Grant Zvolský 9544c03a3b
feat: custom client token ttl (#3206)
This change introduces a new endpoint that allows you to control how long client tokens last. Now you can configure the lifespan for each valid combination of Client, GrantType, and TokenType.

See #3157

Co-authored-by: aeneasr <3372410+aeneasr@users.noreply.github.com>
Co-authored-by: Andreas Bucksteeg <andreas@bucksteeg.de>
2022-07-28 21:12:09 +02:00
Stepan Rakitin 8d0e5e65dd
fix: add content-type header to hook request (#2775) 2021-10-01 21:03:49 +02:00
Felix Jung f701310a8b
feat: include amr claim in ID token (#2770)
Closes #1756

Co-authored-by: Stepan Rakitin <stepanr@mailbox.org>
2021-09-30 14:25:06 +02:00
Stepan Rakitin 1a7dcd1c46
feat: refresh token hook to update claims (#2649)
This patch adds a new feature to Ory Hydra which allows the updating of access and ID tokens during the refresh flow. To set it up, use the `oauth2.refresh_token_hook` configuration to set up a HTTP(S) endpoint which receives a POST request when a refresh token is about to be issued.

Closes #2570

Co-authored-by: hackerman <3372410+aeneasr@users.noreply.github.com>
2021-09-01 09:28:04 +03:00
aeneasr 68976f8f6f
fix: resolve sdk build issues 2021-07-06 15:22:07 +02:00
aeneasr 5de255b09e
fix: build issues 2021-07-06 14:48:56 +02:00
Nestor 5bdc4bc156
refactor: integrate with fosite `v0.40` (go-jose migration) (#2526)
Co-authored-by: aeneasr <3372410+aeneasr@users.noreply.github.com>
2021-05-31 18:01:28 +03:00
Stepan Rakitin bc349f1fba
feat: refresh token reuse detection (#2383)
This patch adds support for Refresh Token reuse Detection introduced by https://github.com/ory/fosite/pull/567. Ory Hydra's persister no longer deletes refresh tokens when using them, but instead deactivates them - similar to how authorization codes work.

Closes #2022
2021-03-23 10:35:19 +01:00