mirror of
https://github.com/vmware-tanzu/pinniped.git
synced 2026-02-11 23:31:49 +00:00
Also: - fix github teams query: fix bug and sort/unique the results - add IDP display name to github downstream subject - fix error types returned by LoginFromCallback - add trace logs to github API results - update e2e test - implement placeholder version of refresh for github
35 lines
1.0 KiB
Go
35 lines
1.0 KiB
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),
|
|
)
|
|
}
|
|
|
|
func GitHub(apiBaseURL, idpDisplayName, login, id string) string {
|
|
return fmt.Sprintf("%s?%s=%s&login=%s&id=%s", apiBaseURL,
|
|
oidc.IDTokenSubClaimIDPNameQueryParam, url.QueryEscape(idpDisplayName),
|
|
url.QueryEscape(login),
|
|
url.QueryEscape(id),
|
|
)
|
|
}
|