Skip to content

Commit 7acf6e0

Browse files
committed
add iss check to oidc auth resp flow
1 parent 3952aa9 commit 7acf6e0

File tree

5 files changed

+19
-0
lines changed

5 files changed

+19
-0
lines changed

api/acl.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1232,6 +1232,8 @@ type ACLOIDCCompleteAuthRequest struct {
12321232
State string
12331233
Code string
12341234

1235+
Iss string
1236+
12351237
// RedirectURI is the URL that authorization should redirect to. This is a
12361238
// required parameter.
12371239
RedirectURI string

command/login.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@ func (l *LoginCommand) loginOIDC(ctx context.Context, client *api.Client) (*api.
256256
ClientNonce: callbackServer.Nonce(),
257257
Code: req.Code,
258258
State: req.State,
259+
Iss: req.Iss,
259260
}
260261

261262
token, _, err := client.ACLAuth().CompleteAuth(&cbArgs, nil)

lib/auth/oidc/server.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ func (s *CallbackServer) ServeHTTP(w http.ResponseWriter, req *http.Request) {
8787
State: q.Get("state"),
8888
ClientNonce: s.clientNonce,
8989
Code: q.Get("code"),
90+
Iss: q.Get("iss"),
9091
}
9192

9293
// Send our result. We don't block here because the channel should be

nomad/acl_endpoint.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2767,6 +2767,20 @@ func (a *ACL) OIDCCompleteAuth(
27672767
return fmt.Errorf("failed to generate OIDC provider: %v", err)
27682768
}
27692769

2770+
// Check if the OIDC provider requires the `iss` parameter to be
2771+
// validated
2772+
providerMetadata := struct {
2773+
AuthorizationResponseIssParameterSupported bool `json:"authorization_response_iss_parameter_supported"`
2774+
}{}
2775+
if err := oidcProvider.Claims(&providerMetadata); err != nil {
2776+
return fmt.Errorf("failed to retrieve OIDC provider metadata: %v", err)
2777+
}
2778+
if providerMetadata.AuthorizationResponseIssParameterSupported {
2779+
if args.Iss == "" || args.Iss != authMethod.Config.OIDCDiscoveryURL {
2780+
return structs.NewErrRPCCodedf(http.StatusBadRequest, "invalid or missing iss parameter")
2781+
}
2782+
}
2783+
27702784
// Retrieve the request generated in OIDCAuthURL()
27712785
oidcReq := a.oidcRequestCache.LoadAndDelete(args.ClientNonce) // I am so done with this NONCENSE
27722786
if oidcReq == nil {

nomad/structs/acl.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2350,6 +2350,7 @@ type ACLOIDCCompleteAuthRequest struct {
23502350
ClientNonce string
23512351
State string
23522352
Code string
2353+
Iss string
23532354

23542355
// RedirectURI is the URL that authorization should redirect to. This is a
23552356
// required parameter.

0 commit comments

Comments
 (0)