···
-
func (o *OauthClient) ResolvePDSAuthServer(ctx context.Context, ustr string) (string, error) {
u, err := isSafeAndParsed(ustr)
···
return "", fmt.Errorf("error creating request for oauth protected resource: %w", err)
-
resp, err := o.h.Do(req)
return "", fmt.Errorf("could not get response from server: %w", err)
···
return resource.AuthorizationServers[0], nil
-
func (o *OauthClient) FetchAuthServerMetadata(ctx context.Context, ustr string) (any, error) {
u, err := isSafeAndParsed(ustr)
···
return nil, fmt.Errorf("error creating request to fetch auth metadata: %w", err)
-
resp, err := o.h.Do(req)
return nil, fmt.Errorf("error getting response for auth metadata: %w", err)
···
-
func (o *OauthClient) ClientAssertionJwt(authServerUrl string) (string, error) {
"iat": time.Now().Unix(),
token := jwt.NewWithClaims(jwt.SigningMethodES256, claims)
-
token.Header["kid"] = o.clientKid
-
tokenString, err := token.SignedString(o.clientPrivateKey)
···
-
func (o *OauthClient) AuthServerDpopJwt(method, url, nonce string, privateJwk jwk.Key) (string, error) {
raw, err := jwk.PublicKeyOf(privateJwk)
···
-
func (o *OauthClient) SendParAuthRequest(ctx context.Context, authServerUrl string, authServerMeta *OauthAuthorizationMetadata, loginHint, scope string, dpopPrivateKey jwk.Key) (any, error) {
if authServerMeta == nil {
return nil, fmt.Errorf("nil metadata provided")
···
codeChallenge := generateCodeChallenge(pkceVerifier)
codeChallengeMethod := "S256"
-
clientAssertion, err := o.ClientAssertionJwt(authServerUrl)
-
dpopProof, err := o.AuthServerDpopJwt("POST", parUrl, nonce, dpopPrivateKey)
···
"code_challenge": codeChallenge,
"code_challenge_method": codeChallengeMethod,
-
"client_id": o.clientId,
-
"redirect_uri": o.redirectUri,
"client_assertion_type": "urn:ietf:params:oauth:client-assertion-type:jwt-bearer",
"client_assertion": clientAssertion,
···
+
func (c *OauthClient) ResolvePDSAuthServer(ctx context.Context, ustr string) (string, error) {
u, err := isSafeAndParsed(ustr)
···
return "", fmt.Errorf("error creating request for oauth protected resource: %w", err)
+
resp, err := c.h.Do(req)
return "", fmt.Errorf("could not get response from server: %w", err)
···
return resource.AuthorizationServers[0], nil
+
func (c *OauthClient) FetchAuthServerMetadata(ctx context.Context, ustr string) (any, error) {
u, err := isSafeAndParsed(ustr)
···
return nil, fmt.Errorf("error creating request to fetch auth metadata: %w", err)
+
resp, err := c.h.Do(req)
return nil, fmt.Errorf("error getting response for auth metadata: %w", err)
···
+
func (c *OauthClient) ClientAssertionJwt(authServerUrl string) (string, error) {
"iat": time.Now().Unix(),
token := jwt.NewWithClaims(jwt.SigningMethodES256, claims)
+
token.Header["kid"] = c.clientKid
+
tokenString, err := token.SignedString(c.clientPrivateKey)
···
+
func (c *OauthClient) AuthServerDpopJwt(method, url, nonce string, privateJwk jwk.Key) (string, error) {
raw, err := jwk.PublicKeyOf(privateJwk)
···
+
func (c *OauthClient) SendParAuthRequest(ctx context.Context, authServerUrl string, authServerMeta *OauthAuthorizationMetadata, loginHint, scope string, dpopPrivateKey jwk.Key) (any, error) {
if authServerMeta == nil {
return nil, fmt.Errorf("nil metadata provided")
···
codeChallenge := generateCodeChallenge(pkceVerifier)
codeChallengeMethod := "S256"
+
clientAssertion, err := c.ClientAssertionJwt(authServerUrl)
+
dpopProof, err := c.AuthServerDpopJwt("POST", parUrl, nonce, dpopPrivateKey)
···
"code_challenge": codeChallenge,
"code_challenge_method": codeChallengeMethod,
+
"client_id": c.clientId,
+
"redirect_uri": c.redirectUri,
"client_assertion_type": "urn:ietf:params:oauth:client-assertion-type:jwt-bearer",
"client_assertion": clientAssertion,