GenerateAuthenticatedToken skips all oauth2 flows, and just generates a valid token for some given claims.
(claims jwt.MapClaims)
| 575 | // GenerateAuthenticatedToken skips all oauth2 flows, and just generates a |
| 576 | // valid token for some given claims. |
| 577 | func (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. |