Files
pinniped/internal/federationdomain/downstreamsubject/downstream_subject.go
T
Ryan Richard 1bc13e94f7 Refactor to extract interface for upstream IDP interactions
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.
2024-02-20 09:26:34 -08:00

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),
)
}