Skip to content

Commit 998f12b

Browse files
committed
new client authentication methods tests
Signed-off-by: Ivan Gatnau Lopez <[email protected]>
1 parent 87bd38b commit 998f12b

File tree

3 files changed

+810
-2
lines changed

3 files changed

+810
-2
lines changed

e2e/keycloak/authz-config.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"access_token": {
2222
"header": "x-access-token"
2323
},
24+
"client_authentication_method" : "client_secret_basic",
2425
"logout": {
2526
"path": "/logout"
2627
},

internal/authz/oidc.go

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,11 @@ func buildAuthHeader(config *oidcv1.OIDCConfig) (http.Header, error) {
429429
// TODO: implement private key jwt auth header
430430
return nil, errors.New("client authentication method private_key_jwt is not implemented")
431431
default:
432-
return nil, errors.New("client authentication requires at least one authentication method")
432+
// Builds basic auth header
433+
headers = http.Header{
434+
inthttp.HeaderContentType: []string{inthttp.HeaderContentTypeFormURLEncoded},
435+
inthttp.HeaderAuthorization: []string{inthttp.BasicAuthHeader(config.GetClientId(), config.GetClientSecret())},
436+
}
433437
}
434438

435439
return headers, nil
@@ -464,12 +468,23 @@ func buildAuthParams(config *oidcv1.OIDCConfig, codeFromReq string, codeVerifier
464468
// Build jwt auth params
465469
// TODO: implement jwt auth params
466470
return nil, errors.New("client authentication method client_secret_jwt is not implemented")
471+
467472
case oidcv1.OIDCConfig_CLIENT_AUTHENTICATION_METHOD_PRIVATE_KEY_JWT:
468473
// Build private key jwt auth params
469474
// TODO: implement private key jwt auth params
470475
return nil, errors.New("client authentication method private_key_jwt is not implemented")
476+
471477
default:
472-
return nil, errors.New("client authentication requires at least one authentication method")
478+
479+
// Build basic auth params
480+
params = url.Values{
481+
"grant_type": []string{"authorization_code"},
482+
"code": []string{codeFromReq},
483+
"redirect_uri": []string{config.GetCallbackUri()},
484+
"code_verifier": []string{codeVerifierFromReq},
485+
}
486+
487+
return params, nil
473488
}
474489
return params, nil
475490
}

0 commit comments

Comments
 (0)