MCPcopy Index your code
hub / github.com/coder/coder / GenerateAuthenticatedToken

Method GenerateAuthenticatedToken

coderd/coderdtest/oidctest/idp.go:577–590  ·  view source on GitHub ↗

GenerateAuthenticatedToken skips all oauth2 flows, and just generates a valid token for some given claims.

(claims jwt.MapClaims)

Source from the content-addressed store, hash-verified

575// GenerateAuthenticatedToken skips all oauth2 flows, and just generates a
576// valid token for some given claims.
577func (f *FakeIDP) GenerateAuthenticatedToken(claims jwt.MapClaims) (*oauth2.Token, error) {
578 state := uuid.NewString()
579 f.stateToIDTokenClaims.Store(state, claims)
580
581 exchangeOpts := []oauth2.AuthCodeOption{}
582 verifier := ""
583 if f.pkce {
584 verifier = oauth2.GenerateVerifier()
585 exchangeOpts = append(exchangeOpts, oauth2.VerifierOption(verifier))
586 }
587 code := f.newCode(state, oauth2.S256ChallengeFromVerifier(verifier))
588
589 return f.locked.Config().Exchange(oidc.ClientContext(context.Background(), f.HTTPClient(nil)), code, exchangeOpts...)
590}
591
592// Login does the full OIDC flow starting at the "LoginButton".
593// The client argument is just to get the URL of the Coder instance.

Callers 2

setupOauth2TestFunction · 0.95

Calls 5

newCodeMethod · 0.95
HTTPClientMethod · 0.95
ConfigMethod · 0.80
ExchangeMethod · 0.65
StoreMethod · 0.45

Tested by 2

setupOauth2TestFunction · 0.76