Skip to content

Commit 2b393b6

Browse files
Implement RFC 8628 (#826)
``` BREAKING CHANGES: This patch breaks up `OAuth2AuthorizeExplicitFactory` into `OAuth2AuthorizeExplicitAuthFactory` and `Oauth2AuthorizeExplicitTokenFactory` ``` This PR is based on the work done on #701, by @supercairos and @BuzzBumbleBee. That PR was based on an older version of fosite and was missing some features/tests. Co-authored-by: Shu <[email protected]>
1 parent 049ed19 commit 2b393b6

File tree

267 files changed

+4893
-844
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

267 files changed

+4893
-844
lines changed

.github/workflows/oidc-conformity.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ jobs:
1313
uses: actions/checkout@v2
1414
with:
1515
fetch-depth: 2
16-
repository: ory/hydra
17-
ref: a35e78e364a26c4f87f37d9f545ef10b3ffa468a
16+
repository: nsklikas/hydra
17+
ref: canonical-master
1818
- uses: actions/setup-go@v2
1919
with:
2020
go-version: "1.21"

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ test: # runs all tests
2121
curl https://raw.githubusercontent.com/ory/ci/master/licenses/install | sh
2222

2323
.bin/mockgen:
24-
go build -o .bin/mockgen github.com/golang/mock/mockgen
24+
go build -o .bin/mockgen go.uber.org/mock/mockgen
2525

2626
.bin/ory: Makefile
2727
curl https://raw.githubusercontent.com/ory/meta/master/install.sh | bash -s -- -b .bin ory v0.1.48

access_error.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright © 2024 Ory Corp
1+
// Copyright © 2025 Ory Corp
22
// SPDX-License-Identifier: Apache-2.0
33

44
package fosite
@@ -10,11 +10,12 @@ import (
1010
"net/http"
1111
)
1212

13-
func (f *Fosite) WriteAccessError(ctx context.Context, rw http.ResponseWriter, req AccessRequester, err error) {
13+
// Convert an error to an http response as per RFC6749
14+
func (f *Fosite) WriteAccessError(ctx context.Context, rw http.ResponseWriter, req Requester, err error) {
1415
f.writeJsonError(ctx, rw, req, err)
1516
}
1617

17-
func (f *Fosite) writeJsonError(ctx context.Context, rw http.ResponseWriter, requester AccessRequester, err error) {
18+
func (f *Fosite) writeJsonError(ctx context.Context, rw http.ResponseWriter, requester Requester, err error) {
1819
rw.Header().Set("Content-Type", "application/json;charset=UTF-8")
1920
rw.Header().Set("Cache-Control", "no-store")
2021
rw.Header().Set("Pragma", "no-cache")

access_error_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright © 2024 Ory Corp
1+
// Copyright © 2025 Ory Corp
22
// SPDX-License-Identifier: Apache-2.0
33

44
package fosite_test
@@ -11,9 +11,9 @@ import (
1111
"net/http/httptest"
1212
"testing"
1313

14-
"github.com/golang/mock/gomock"
1514
"github.com/stretchr/testify/assert"
1615
"github.com/stretchr/testify/require"
16+
gomock "go.uber.org/mock/gomock"
1717

1818
. "github.com/ory/fosite"
1919
. "github.com/ory/fosite/internal"

access_request.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright © 2024 Ory Corp
1+
// Copyright © 2025 Ory Corp
22
// SPDX-License-Identifier: Apache-2.0
33

44
package fosite

access_request_handler.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright © 2024 Ory Corp
1+
// Copyright © 2025 Ory Corp
22
// SPDX-License-Identifier: Apache-2.0
33

44
package fosite

access_request_handler_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright © 2024 Ory Corp
1+
// Copyright © 2025 Ory Corp
22
// SPDX-License-Identifier: Apache-2.0
33

44
package fosite_test
@@ -10,10 +10,10 @@ import (
1010
"net/url"
1111
"testing"
1212

13-
"github.com/golang/mock/gomock"
1413
"github.com/pkg/errors"
1514
"github.com/stretchr/testify/assert"
1615
"github.com/stretchr/testify/require"
16+
gomock "go.uber.org/mock/gomock"
1717

1818
. "github.com/ory/fosite"
1919
"github.com/ory/fosite/internal"

access_request_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright © 2024 Ory Corp
1+
// Copyright © 2025 Ory Corp
22
// SPDX-License-Identifier: Apache-2.0
33

44
package fosite

access_response.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright © 2024 Ory Corp
1+
// Copyright © 2025 Ory Corp
22
// SPDX-License-Identifier: Apache-2.0
33

44
package fosite

access_response_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright © 2024 Ory Corp
1+
// Copyright © 2025 Ory Corp
22
// SPDX-License-Identifier: Apache-2.0
33

44
package fosite_test

access_response_writer.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright © 2024 Ory Corp
1+
// Copyright © 2025 Ory Corp
22
// SPDX-License-Identifier: Apache-2.0
33

44
package fosite

access_response_writer_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright © 2024 Ory Corp
1+
// Copyright © 2025 Ory Corp
22
// SPDX-License-Identifier: Apache-2.0
33

44
package fosite_test
@@ -8,9 +8,9 @@ import (
88
"fmt"
99
"testing"
1010

11-
"github.com/golang/mock/gomock"
1211
"github.com/stretchr/testify/assert"
1312
"github.com/stretchr/testify/require"
13+
gomock "go.uber.org/mock/gomock"
1414

1515
. "github.com/ory/fosite"
1616
"github.com/ory/fosite/internal"

access_write.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright © 2024 Ory Corp
1+
// Copyright © 2025 Ory Corp
22
// SPDX-License-Identifier: Apache-2.0
33

44
package fosite

access_write_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright © 2024 Ory Corp
1+
// Copyright © 2025 Ory Corp
22
// SPDX-License-Identifier: Apache-2.0
33

44
package fosite_test
@@ -8,8 +8,8 @@ import (
88
"net/http"
99
"testing"
1010

11-
"github.com/golang/mock/gomock"
1211
"github.com/stretchr/testify/assert"
12+
gomock "go.uber.org/mock/gomock"
1313

1414
. "github.com/ory/fosite"
1515
. "github.com/ory/fosite/internal"

arguments.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright © 2024 Ory Corp
1+
// Copyright © 2025 Ory Corp
22
// SPDX-License-Identifier: Apache-2.0
33

44
package fosite

arguments_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright © 2024 Ory Corp
1+
// Copyright © 2025 Ory Corp
22
// SPDX-License-Identifier: Apache-2.0
33

44
package fosite

audience_strategy.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright © 2024 Ory Corp
1+
// Copyright © 2025 Ory Corp
22
// SPDX-License-Identifier: Apache-2.0
33

44
package fosite
@@ -92,10 +92,10 @@ func GetAudiences(form url.Values) []string {
9292
}
9393
}
9494

95-
func (f *Fosite) validateAuthorizeAudience(ctx context.Context, r *http.Request, request *AuthorizeRequest) error {
96-
audience := GetAudiences(request.Form)
95+
func (f *Fosite) validateAudience(ctx context.Context, r *http.Request, request Requester) error {
96+
audience := GetAudiences(request.GetRequestForm())
9797

98-
if err := f.Config.GetAudienceStrategy(ctx)(request.Client.GetAudience(), audience); err != nil {
98+
if err := f.Config.GetAudienceStrategy(ctx)(request.GetClient().GetAudience(), audience); err != nil {
9999
return err
100100
}
101101

audience_strategy_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright © 2024 Ory Corp
1+
// Copyright © 2025 Ory Corp
22
// SPDX-License-Identifier: Apache-2.0
33

44
package fosite

authorize_error.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright © 2024 Ory Corp
1+
// Copyright © 2025 Ory Corp
22
// SPDX-License-Identifier: Apache-2.0
33

44
package fosite

authorize_error_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright © 2024 Ory Corp
1+
// Copyright © 2025 Ory Corp
22
// SPDX-License-Identifier: Apache-2.0
33

44
package fosite_test
@@ -10,8 +10,8 @@ import (
1010
"net/url"
1111
"testing"
1212

13-
"github.com/golang/mock/gomock"
1413
"github.com/stretchr/testify/assert"
14+
gomock "go.uber.org/mock/gomock"
1515

1616
. "github.com/ory/fosite"
1717
. "github.com/ory/fosite/internal"

authorize_helper.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright © 2024 Ory Corp
1+
// Copyright © 2025 Ory Corp
22
// SPDX-License-Identifier: Apache-2.0
33

44
package fosite

authorize_helper_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright © 2024 Ory Corp
1+
// Copyright © 2025 Ory Corp
22
// SPDX-License-Identifier: Apache-2.0
33

44
package fosite_test

authorize_helper_whitebox_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright © 2024 Ory Corp
1+
// Copyright © 2025 Ory Corp
22
// SPDX-License-Identifier: Apache-2.0
33

44
package fosite

authorize_request.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright © 2024 Ory Corp
1+
// Copyright © 2025 Ory Corp
22
// SPDX-License-Identifier: Apache-2.0
33

44
package fosite

authorize_request_handler.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright © 2024 Ory Corp
1+
// Copyright © 2025 Ory Corp
22
// SPDX-License-Identifier: Apache-2.0
33

44
package fosite
@@ -390,7 +390,7 @@ func (f *Fosite) newAuthorizeRequest(ctx context.Context, r *http.Request, isPAR
390390
return request, err
391391
}
392392

393-
if err = f.validateAuthorizeAudience(ctx, r, request); err != nil {
393+
if err = f.validateAudience(ctx, r, request); err != nil {
394394
return request, err
395395
}
396396

authorize_request_handler_oidc_request_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright © 2024 Ory Corp
1+
// Copyright © 2025 Ory Corp
22
// SPDX-License-Identifier: Apache-2.0
33

44
package fosite

authorize_request_handler_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright © 2024 Ory Corp
1+
// Copyright © 2025 Ory Corp
22
// SPDX-License-Identifier: Apache-2.0
33

44
package fosite_test
@@ -10,10 +10,10 @@ import (
1010
"net/url"
1111
"testing"
1212

13-
"github.com/golang/mock/gomock"
1413
"github.com/pkg/errors"
1514
"github.com/stretchr/testify/assert"
1615
"github.com/stretchr/testify/require"
16+
gomock "go.uber.org/mock/gomock"
1717

1818
. "github.com/ory/fosite"
1919
. "github.com/ory/fosite/internal"

authorize_request_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright © 2024 Ory Corp
1+
// Copyright © 2025 Ory Corp
22
// SPDX-License-Identifier: Apache-2.0
33

44
package fosite

authorize_response.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright © 2024 Ory Corp
1+
// Copyright © 2025 Ory Corp
22
// SPDX-License-Identifier: Apache-2.0
33

44
package fosite

authorize_response_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright © 2024 Ory Corp
1+
// Copyright © 2025 Ory Corp
22
// SPDX-License-Identifier: Apache-2.0
33

44
package fosite

authorize_response_writer.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright © 2024 Ory Corp
1+
// Copyright © 2025 Ory Corp
22
// SPDX-License-Identifier: Apache-2.0
33

44
package fosite

authorize_response_writer_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright © 2024 Ory Corp
1+
// Copyright © 2025 Ory Corp
22
// SPDX-License-Identifier: Apache-2.0
33

44
package fosite_test
@@ -7,9 +7,9 @@ import (
77
"context"
88
"testing"
99

10-
"github.com/golang/mock/gomock"
1110
"github.com/pkg/errors"
1211
"github.com/stretchr/testify/assert"
12+
gomock "go.uber.org/mock/gomock"
1313

1414
"github.com/ory/fosite"
1515
. "github.com/ory/fosite"

authorize_validators_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright © 2024 Ory Corp
1+
// Copyright © 2025 Ory Corp
22
// SPDX-License-Identifier: Apache-2.0
33

44
package fosite

authorize_write.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright © 2024 Ory Corp
1+
// Copyright © 2025 Ory Corp
22
// SPDX-License-Identifier: Apache-2.0
33

44
package fosite

authorize_write_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright © 2024 Ory Corp
1+
// Copyright © 2025 Ory Corp
22
// SPDX-License-Identifier: Apache-2.0
33

44
package fosite_test
@@ -9,8 +9,8 @@ import (
99
"net/url"
1010
"testing"
1111

12-
"github.com/golang/mock/gomock"
1312
"github.com/stretchr/testify/assert"
13+
gomock "go.uber.org/mock/gomock"
1414

1515
. "github.com/ory/fosite"
1616
. "github.com/ory/fosite/internal"

client.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright © 2024 Ory Corp
1+
// Copyright © 2025 Ory Corp
22
// SPDX-License-Identifier: Apache-2.0
33

44
package fosite

client_authentication.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright © 2024 Ory Corp
1+
// Copyright © 2025 Ory Corp
22
// SPDX-License-Identifier: Apache-2.0
33

44
package fosite

client_authentication_jwks_strategy.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright © 2024 Ory Corp
1+
// Copyright © 2025 Ory Corp
22
// SPDX-License-Identifier: Apache-2.0
33

44
package fosite

client_authentication_jwks_strategy_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright © 2024 Ory Corp
1+
// Copyright © 2025 Ory Corp
22
// SPDX-License-Identifier: Apache-2.0
33

44
package fosite

client_authentication_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright © 2024 Ory Corp
1+
// Copyright © 2025 Ory Corp
22
// SPDX-License-Identifier: Apache-2.0
33

44
package fosite_test

client_manager.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright © 2024 Ory Corp
1+
// Copyright © 2025 Ory Corp
22
// SPDX-License-Identifier: Apache-2.0
33

44
package fosite

client_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright © 2024 Ory Corp
1+
// Copyright © 2025 Ory Corp
22
// SPDX-License-Identifier: Apache-2.0
33

44
package fosite

client_with_custom_token_lifespans.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright © 2024 Ory Corp
1+
// Copyright © 2025 Ory Corp
22
// SPDX-License-Identifier: Apache-2.0
33

44
package fosite

client_with_custom_token_lifespans_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright © 2024 Ory Corp
1+
// Copyright © 2025 Ory Corp
22
// SPDX-License-Identifier: Apache-2.0
33

44
package fosite

0 commit comments

Comments
 (0)