Commit Graph

70 Commits

Author SHA1 Message Date
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
Arne Luenser f56e5fad74 fix: append /v2 to module path 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 142b55f295 refactor(sdk): OAuth2 SDK API
BREAKING CHANGE: SDK naming has changed for the following operations:

```patch
ory.
-   V0alpha2Api.AdminDeleteOAuth2Token(context.Background()).
+   OAuth2Api.DeleteOAuth2Token(context.Background()).
    ClientId("foobar").Execute()

ory.
-   V0alpha2Api.RevokeOAuth2Token(
+   OAuth2Api.RevokeOAuth2Token(
        context.WithValue(context.Background(), sdk.ContextBasicAuth, sdk.BasicAuth{
            UserName: clientID,
            Password: clientSecret,
        })).Token(token).Execute()

ory.
-   V0alpha2Api.AdminIntrospectOAuth2Token(context.Background()).
+   OAuth2Api.IntrospectOAuth2Token(context.Background()).
    Token(token).
    Scope("foo bar")).Execute()
```
2022-10-11 17:01:24 +02: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 a364db4ff2 fix: move to v0alpha2 api spec 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 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 d746fa499a fix: support issuer with and without trailing slash
BREAKING CHANGE: The `iss` (issuer) value no longer appends a trailing slash but instead uses the raw value set in the config.

Setting

```yaml
urls:
  self:
    issuer: https://auth.example.com
```

has changed

```patch
-  "iss": "https://auth.example.com/"
+  "iss": "https://auth.example.com"
```

To set a trailing slash make sure to set it in the config value:

```yaml
urls:
  self:
    issuer: https://auth.example.com/
```

Closes #1482
2022-09-07 08:10:31 +02:00
aeneasr bbe0406df6 feat: config hot reloading architecture 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
hackerman 4937a00b9a
fix: bump ory/x and update config usage (#2248) 2020-12-15 13:55:30 +01:00
aeneasr 428df22c7f chore: clean up viper mentions 2020-12-02 13:37:05 +01:00
aeneasr 8c12b27a59 refactor: replace viper with koanf config management
BREAKING CHANGES: After battling with [spf13/viper](https://github.com/spf13/viper) for several years we finally found a viable alternative with [knadh/koanf](https://github.com/knadh/koanf). The complete internal configuration infrastructure has changed, with several highlights:

1. Configuration sourcing works from all sources (file, env, cli flags) with validation against the configuration schema, greatly improving developer experience when changing or updating configuration.
2. Configuration reloading has improved significantly and works flawlessly on Kubernetes.
3. Performance increased dramatically, completely removing the need for a cache layer between the configuration system and ORY Hydra.
4. It is now possible to load several config files using the `--config` flag.
5. Configuration values are now sent to the tracer (e.g. Jaeger) if tracing is enabled.

Please be aware that deprecated configuration flags have finally been removed with this change. It is also possible that ORY Hydra might complain about an invalid configuration, because the validation process has improved significantly.
2020-12-02 13:37:05 +01:00
Patrik 56bce678cb refactor: use gobuffalo/pop for SQL abstraction (#2059)
This patch replaces the existing SQL and memory managers with a pop based persister. Existing SQL migrations are compatible as they have been migrated to the new SQL abstraction in version 1.7.x. As a goodie, ORY Hydra now supports SQLite for both in-memory as well as on-disk (useful for development and very small deployments) databases!

Closes #1730

Co-authored-by: aeneasr <aeneas@ory.sh>
Co-authored-by: hackerman <3372410+aeneasr@users.noreply.github.com>
2020-10-20 14:55:49 +02:00
aeneasr eeaa3ac903 fix: deprecate client flags in introspection CLI 2020-08-24 10:35:00 +02:00
hackerman 94057d9400
refactor: move migrations to gobuffalo/fizz (#1775)
This patch deprecates the previous migration system (sql-migrate) in favor of gobuffalo/fizz. No functional changes have been made.

BREAKING CHANGES: Please run `hydra migrate sql` before applying this release.
2020-04-30 10:58:57 +02:00
aeneasr c499e52bbc
Implement new SDK pipeline (interim)
This is an interim commit that got pushed to master by the CI on accident.
2020-01-07 16:12:18 +01:00
hackerman 9243dc2490
vendor: Fix SQL-regression caused by go 1.12.7 (#1534) 2019-08-19 19:11:44 +02:00
hackerman 6829a58622
sdk: Move to go-swagger code generator (#1347)
Signed-off-by: aeneasr <aeneas@ory.sh>
2019-04-09 13:24:13 +02:00
hackerman 95a51deb31
Improve configuration and service management (#1314)
This patch significantly refactors internal configuration and service management with the goal of making configuration changes possible without service restarts. This patch prepares the possibility to configure ORY Hydra from a remote source (etcd, consul) and watch for changes. This patch also introduces the possibility to configure ORY Hydra from a configuration file on top of environment variables.

The following issues have been fixed as well:

- Key rotation of the system secret is now much simpler (closes #1316)
- Database connectivity parameters such as max_conns no longer cause issues with older postgres versions (closes #1327)
- Non-existing routes now return a JSON error instead of `text/plain` when `application/json` was requested (clsoes #1244)
- We now push tags latest, X, X.Y, X.Y.Z to docker hub (closes #1289)
- The quickstart guide no longer builds the source code but instead pulls latest tag (closes #1309)
- We moved to goreleaser and godownloader for release management (closes #1107)
- The quickstart Docker Compose files are now reusable (closes #1196)

The following issues are also resolved:

- Closes #1121 

Signed-off-by: aeneasr <aeneas@ory.sh>
2019-04-02 11:52:21 +02:00
arekkas 671b69c763 sdk: Clean up SDKs
Signed-off-by: arekkas <aeneas@ory.am>
2018-11-18 23:04:32 +01:00
arekkas 700a4a2eff sdk: Use new api groups everywhere 2018-11-18 23:04:10 +01:00
hackerman 4a8cf84f15
cmd: Add ability to specify consent and login lifespan (#1155)
Closes #1057
2018-11-03 21:15:59 +01:00
hackerman 65b7406abe
Move dependencies to ory/x (#1095)
Signed-off-by: aeneasr <aeneas@ory.sh>
2018-10-23 06:59:31 -07:00
Amir Aslaminejad 404bdd711f jwk: update manager to take in context and update all consumers
Signed-off-by: Amir Aslaminejad <aslaminejad@gmail.com>
2018-09-18 09:48:55 +02:00
arekkas 480904f380 cmd: Upgrade to new fosite compose API
Signed-off-by: arekkas <aeneas@ory.am>
2018-08-26 20:46:52 +02:00
hackerman a36d0af611
oauth2: Enable client specific CORS settings (#1009)
Field `allowed_cors_origins` was added to OAuth 2.0 Clients. It enables
CORS for the whitelisted URLS for paths which clients interact with,
such as /oauth2/token.

Closes #975

Signed-off-by: arekkas <aeneas@ory.am>
2018-08-26 14:28:05 +02:00
hackerman c72e64cebd
oauth2: Resolve broken expiry when refreshing id token (#1002)
Closes #985

Signed-off-by: arekkas <aeneas@ory.am>
2018-08-23 00:27:20 +02:00
arekkas 479acd7ea7 consent: Introduce pairwise support
This patch introduces the OpenID Connect pairwise Subject Identifier Algorithm.

Closes #950

Signed-off-by: arekkas <aeneas@ory.am>
2018-08-10 10:23:19 +02:00
arekkas 17e63116c8 oauth2: Removes authorization from introspection
Signed-off-by: arekkas <aeneas@ory.am>
2018-08-06 16:20:36 +02:00
arekkas f32c97e844 cmd: Fix 2-port tests and improve upgrade guide
Signed-off-by: arekkas <aeneas@ory.am>
2018-08-06 11:29:38 +02:00
arekkas cfee3eb3d0 cmd: Introduce public and administrative ports
This patch introduces two ports, public and administrative. The public
port is responsible for handling API requests to public endpoints such
as /oauth2/auth, while the administrative port handles requests to
JWK, OAuth 2.0 Client, and Login & Consent endpoints.

Closes #904

Signed-off-by: arekkas <aeneas@ory.am>
2018-08-06 11:29:38 +02:00
arekkas c932ab4571 oauth2: Adds JWT Access Token strategy
This patch adds the (experimental) ability to issue JSON Web Tokens instead of ORY Hydra's opaque access tokens. Please be aware that this feature has had little real-world and unit testing and may not be suitable for production.

Simple integration tests using the JWT strategy have been added to ensure functionality.

To use the new JWT strategy, set environment variable `OAUTH2_ACCESS_TOKEN_STRATEGY` to `jwt`. For example: `export OAUTH2_ACCESS_TOKEN_STRATEGY=jwt`.

Please be aware that we (ORY) do not recommend using the JWT strategy for various reasons. If you can, use the default and recommended "opaque" strategy instead.

Closes #248

Signed-off-by: arekkas <aeneas@ory.am>
2018-07-23 17:10:30 +02:00
Aeneas 2bf24b9d92
oauth2: Add scope to introspection test suite (#941)
Signed-off-by: arekkas <aeneas@ory.am>
2018-07-21 22:36:40 +02:00
arekkas bc0b54c545 oauth2: Implements userinfo response signing 2018-06-24 17:24:12 +02:00
arekkas e41fcf263c jwk: Removes buggy rotate command and improves jwk refresh 2018-06-24 17:24:12 +02:00
arekkas 1d02cae554 jwk: Implements proper refreshing strategy 2018-06-24 17:24:12 +02:00
arekkas 259d63a4de oauth2: Adds private_key_jwt authentication method 2018-06-24 17:24:12 +02:00
arekkas 526e3a7dbe oauth2: Resolves issues with broken tests 2018-05-29 12:20:50 +02:00
arekkas 1940c3c8ff oauth2: Properly uses issuer in JWT 2018-05-19 22:39:01 +02:00
arekkas 3d0bf0bda5 Removes policy, warden and groups from this project
We have learned a lot over the last year in terms of how ORY Hydra is being used. Initially, we wanted to avoid the problems facing popular databases like MongoDB or others, which did not include authentication for their management APIs.

For this reason, the Warden API was born and primarily used internally and exposed via HTTP. We learned that access control policies are well received, but also add additional complexity to understanding the software. While we firmly believe that these policies implement best practices for access control in complex systems, we do understand that they add a barrier to getting started with ORY Hydra.

For this reason we are planning on moving the Warden API from this project to ORY Oathkeeper or potentially it's own server. We would add a migration path for existing policy definitions to the new service. The default docker image would combine the services in such a way, that ORY Hydra is protected. We would additionally have an (insecure) docker image without authentication which can be used for testing.

This also opens up the possibility of having more access control mechanisms than access control policies. For example, we can add ACL and RBAC and other mechanisms too.

First I think it makes good sense to move this functionality into a separate service and remove the warden calls internally completely. The reason being that not everyone wants to rely on Hydra's access control. Sometimes it's enough to use a gateway in front and require e.g. an API key for management or whatever. New adopters are always baffled by complexity involved with policies and scopes. Removing that from the core could really help. The user survey has also shown that this stuff is quite complex to grasp.

The idea is to have a separate service which is basically ladon as a HTTP API. I think it makes sense to add some functionality to resolve access tokens so it would basically be very similar to the current warden API - probably even equal. There would definitely be some backup mode where hydra's database tables and migrations are used as to make migration as easy as possible.

Then, we would ship docker images and example set ups where different configurations are shown. One of the configurations would be the current one, so basically what we have now in hydra but with the three services combined in one image.

Closes #807
2018-04-29 18:25:42 +02:00
arekkas 4f72a48067 Merge remote-tracking branch 'origin/0.11-merge-1.0.0' into 1.0.x-2
# Conflicts:
#	Gopkg.lock
#	Gopkg.toml
#	UPGRADE.md
#	cmd/server/handler_oauth2_factory.go
#	oauth2/consent_strategy.go
#	oauth2/consent_strategy_test.go
#	oauth2/fosite_store_memory.go
#	oauth2/fosite_store_test.go
#	oauth2/fosite_store_test_helpers.go
#	sdk/php/.swagger-codegen/VERSION
#	sdk/php/swagger/README.md
#	sdk/php/swagger/autoload.php
#	sdk/php/swagger/docs/Api/HealthApi.md
#	sdk/php/swagger/docs/Api/JsonWebKeyApi.md
#	sdk/php/swagger/docs/Api/OAuth2Api.md
#	sdk/php/swagger/lib/Api/HealthApi.php
#	sdk/php/swagger/lib/Api/JsonWebKeyApi.php
#	sdk/php/swagger/lib/Api/OAuth2Api.php
#	sdk/php/swagger/lib/Api/PolicyApi.php
#	sdk/php/swagger/lib/Api/WardenApi.php
#	sdk/php/swagger/lib/ApiClient.php
#	sdk/php/swagger/lib/ApiException.php
#	sdk/php/swagger/lib/Configuration.php
#	sdk/php/swagger/lib/Model/ConsentRequest.php
#	sdk/php/swagger/lib/Model/ConsentRequestAcceptance.php
#	sdk/php/swagger/lib/Model/ConsentRequestManager.php
#	sdk/php/swagger/lib/Model/ConsentRequestRejection.php
#	sdk/php/swagger/lib/Model/Context.php
#	sdk/php/swagger/lib/Model/Firewall.php
#	sdk/php/swagger/lib/Model/Group.php
#	sdk/php/swagger/lib/Model/GroupMembers.php
#	sdk/php/swagger/lib/Model/Handler.php
#	sdk/php/swagger/lib/Model/InlineResponse200.php
#	sdk/php/swagger/lib/Model/InlineResponse401.php
#	sdk/php/swagger/lib/Model/JoseWebKeySetRequest.php
#	sdk/php/swagger/lib/Model/JsonWebKey.php
#	sdk/php/swagger/lib/Model/JsonWebKeySet.php
#	sdk/php/swagger/lib/Model/JsonWebKeySetGeneratorRequest.php
#	sdk/php/swagger/lib/Model/KeyGenerator.php
#	sdk/php/swagger/lib/Model/Manager.php
#	sdk/php/swagger/lib/Model/OAuth2Client.php
#	sdk/php/swagger/lib/Model/OAuth2ConsentRequest.php
#	sdk/php/swagger/lib/Model/OAuth2TokenIntrospection.php
#	sdk/php/swagger/lib/Model/Policy.php
#	sdk/php/swagger/lib/Model/PolicyConditions.php
#	sdk/php/swagger/lib/Model/RawMessage.php
#	sdk/php/swagger/lib/Model/SwaggerAcceptConsentRequest.php
#	sdk/php/swagger/lib/Model/SwaggerCreatePolicyParameters.php
#	sdk/php/swagger/lib/Model/SwaggerDoesWardenAllowAccessRequestParameters.php
#	sdk/php/swagger/lib/Model/SwaggerDoesWardenAllowTokenAccessRequestParameters.php
#	sdk/php/swagger/lib/Model/SwaggerGetPolicyParameters.php
#	sdk/php/swagger/lib/Model/SwaggerJsonWebKeyQuery.php
#	sdk/php/swagger/lib/Model/SwaggerJwkCreateSet.php
#	sdk/php/swagger/lib/Model/SwaggerJwkSetQuery.php
#	sdk/php/swagger/lib/Model/SwaggerJwkUpdateSet.php
#	sdk/php/swagger/lib/Model/SwaggerJwkUpdateSetKey.php
#	sdk/php/swagger/lib/Model/SwaggerListPolicyParameters.php
#	sdk/php/swagger/lib/Model/SwaggerListPolicyResponse.php
#	sdk/php/swagger/lib/Model/SwaggerOAuthConsentRequestPayload.php
#	sdk/php/swagger/lib/Model/SwaggerOAuthIntrospectionRequest.php
#	sdk/php/swagger/lib/Model/SwaggerRejectConsentRequest.php
#	sdk/php/swagger/lib/Model/SwaggerRevokeOAuth2TokenParameters.php
#	sdk/php/swagger/lib/Model/SwaggerUpdatePolicyParameters.php
#	sdk/php/swagger/lib/Model/TokenAllowedRequest.php
#	sdk/php/swagger/lib/Model/WardenAccessRequest.php
#	sdk/php/swagger/lib/Model/WardenAccessRequestResponse.php
#	sdk/php/swagger/lib/Model/WardenTokenAccessRequest.php
#	sdk/php/swagger/lib/Model/WardenTokenAccessRequestResponse.php
#	sdk/php/swagger/lib/Model/WellKnown.php
#	sdk/php/swagger/lib/Model/Writer.php
#	sdk/php/swagger/lib/ObjectSerializer.php
2018-04-19 17:49:11 +02:00
arekkas 45eabc2bcf oauth2: Uses UTC timecodes everywhere 2018-04-08 21:10:17 +02:00
Aeneas 366ed57d9c
all: Updates license headers (#793) 2018-03-08 10:27:18 +01:00
Aeneas f5b6558c72
oauth2: Requires firewall check for introspecting access tokens (#678) 2017-12-07 17:44:33 +01:00
arekkas bb960fe995 pkg: Make low entropy RSA key generation explicit in function name 2017-11-18 16:04:08 +01:00