Wrap new VerifyLogin logic in allowedHostedDomains length check

This commit is contained in:
foresturquhart 2025-02-06 17:46:46 +00:00
parent cda2cb151e
commit b499412aee

View File

@ -139,6 +139,8 @@ func NewOidcAuthVerifier(additionalAuthScopes []v1.AuthScope, verifier TokenVeri
}
func (auth *OidcAuthConsumer) VerifyLogin(loginMsg *msg.Login) (err error) {
// Verify hosted domain (hd claim).
if len(auth.allowedHostedDomains) > 0 {
// Decode token without verifying signature to retrieved 'hd' claim.
parts := strings.Split(loginMsg.PrivilegeKey, ".")
if len(parts) != 3 {
@ -155,8 +157,6 @@ func (auth *OidcAuthConsumer) VerifyLogin(loginMsg *msg.Login) (err error) {
return fmt.Errorf("invalid OIDC token: failed to unmarshal payload: %v", err)
}
// Verify hosted domain (hd claim).
if len(auth.allowedHostedDomains) > 0 {
hd, ok := claims["hd"].(string)
if !ok {
return fmt.Errorf("OIDC token missing required 'hd' claim")