mirror of
https://github.com/vmware-tanzu/pinniped.git
synced 2026-09-25 17:34:37 +00:00
Create an interface to abstract the upstream IDP from the authorize, IDP discovery, callback, choose IDP, and login endpoints. This commit does not refactor the token endpoint, which will be refactored in a similar way in the next commit.
27 lines
773 B
Go
27 lines
773 B
Go
// Copyright 2024 the Pinniped contributors. All Rights Reserved.
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
package downstreamsubject
|
|
|
|
import (
|
|
"fmt"
|
|
"net/url"
|
|
|
|
"go.pinniped.dev/generated/latest/apis/supervisor/oidc"
|
|
)
|
|
|
|
func LDAP(uid string, ldapURL url.URL, idpDisplayName string) string {
|
|
q := ldapURL.Query()
|
|
q.Set(oidc.IDTokenSubClaimIDPNameQueryParam, idpDisplayName)
|
|
q.Set(oidc.IDTokenClaimSubject, uid)
|
|
ldapURL.RawQuery = q.Encode()
|
|
return ldapURL.String()
|
|
}
|
|
|
|
func OIDC(upstreamIssuerAsString string, upstreamSubject string, idpDisplayName string) string {
|
|
return fmt.Sprintf("%s?%s=%s&%s=%s", upstreamIssuerAsString,
|
|
oidc.IDTokenSubClaimIDPNameQueryParam, url.QueryEscape(idpDisplayName),
|
|
oidc.IDTokenClaimSubject, url.QueryEscape(upstreamSubject),
|
|
)
|
|
}
|