Skip to content

Commit 0a05ad0

Browse files
committed
Changed DID to subject
1 parent adff851 commit 0a05ad0

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

nuts/client.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ func TokenSource(nutsAPIURL string, ownDID string) *OAuth2TokenSource {
2525
var _ oauth2.TokenSource = &OAuth2TokenSource{}
2626

2727
type OAuth2TokenSource struct {
28-
OwnDID string
28+
NutsSubject string
2929
// NutsAPIURL is the base URL of the Nuts node API.
3030
NutsAPIURL string
3131
// NutsHttpClient is the HTTP client used to communicate with the Nuts node.
@@ -34,7 +34,7 @@ type OAuth2TokenSource struct {
3434
}
3535

3636
func (o OAuth2TokenSource) Token(httpRequest *http.Request, authzServerURL *url.URL, scope string) (*oauth2.Token, error) {
37-
if o.OwnDID == "" {
37+
if o.NutsSubject == "" {
3838
return nil, fmt.Errorf("ownDID is required")
3939
}
4040
var additionalCredentials []vc.VerifiableCredential
@@ -48,7 +48,7 @@ func (o OAuth2TokenSource) Token(httpRequest *http.Request, authzServerURL *url.
4848
// TODO: Might want to support DPoP as well
4949
var tokenType = iam.ServiceAccessTokenRequestTokenTypeBearer
5050
// TODO: Is this the right context to use?
51-
response, err := client.RequestServiceAccessToken(httpRequest.Context(), o.OwnDID, iam.RequestServiceAccessTokenJSONRequestBody{
51+
response, err := client.RequestServiceAccessToken(httpRequest.Context(), o.NutsSubject, iam.RequestServiceAccessTokenJSONRequestBody{
5252
AuthorizationServer: authzServerURL.String(),
5353
Credentials: &additionalCredentials,
5454
Scope: scope,

nuts/client_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ import (
1717
func TestOAuth2TokenSource_Token(t *testing.T) {
1818
t.Run("ok", func(t *testing.T) {
1919
mux := http.NewServeMux()
20-
mux.HandleFunc("/internal/auth/v2/did:web:example.com/request-service-access-token", func(w http.ResponseWriter, r *http.Request) {
20+
mux.HandleFunc("/internal/auth/v2/123abc/request-service-access-token", func(w http.ResponseWriter, r *http.Request) {
2121
w.Header().Set("Content-Type", "application/json")
2222
w.WriteHeader(http.StatusOK)
2323
_, _ = w.Write([]byte(`{"access_token":"test","token_type":"bearer","expires_in":3600}`))
2424
})
2525
httpServer := httptest.NewServer(mux)
2626
tokenSource := OAuth2TokenSource{
27-
OwnDID: "did:web:example.com",
28-
NutsAPIURL: httpServer.URL,
27+
NutsSubject: "123abc",
28+
NutsAPIURL: httpServer.URL,
2929
}
3030
expectedAuthServerURL, _ := url.Parse("https://auth.example.com")
3131
httpRequest, _ := http.NewRequestWithContext(context.Background(), "GET", "https://resource.example.com", nil)
@@ -43,16 +43,16 @@ func TestOAuth2TokenSource_Token(t *testing.T) {
4343
t.Run("additional credentials", func(t *testing.T) {
4444
mux := http.NewServeMux()
4545
var capturedRequest iam.ServiceAccessTokenRequest
46-
mux.HandleFunc("/internal/auth/v2/did:web:example.com/request-service-access-token", func(w http.ResponseWriter, r *http.Request) {
46+
mux.HandleFunc("/internal/auth/v2/123abc/request-service-access-token", func(w http.ResponseWriter, r *http.Request) {
4747
require.NoError(t, json.NewDecoder(r.Body).Decode(&capturedRequest))
4848
w.Header().Set("Content-Type", "application/json")
4949
w.WriteHeader(http.StatusOK)
5050
_, _ = w.Write([]byte(`{"access_token":"test","token_type":"bearer","expires_in":3600}`))
5151
})
5252
httpServer := httptest.NewServer(mux)
5353
tokenSource := OAuth2TokenSource{
54-
OwnDID: "did:web:example.com",
55-
NutsAPIURL: httpServer.URL,
54+
NutsSubject: "123abc",
55+
NutsAPIURL: httpServer.URL,
5656
}
5757
expectedAuthServerURL, _ := url.Parse("https://auth.example.com")
5858
requestCtx := WithAdditionalCredentials(context.Background(), []vc.VerifiableCredential{

0 commit comments

Comments
 (0)