(serviceName string, params OAuthURLParams)
| 613 | } |
| 614 | |
| 615 | func (auth *AuthService) NewOAuthSession(serviceName string, params OAuthURLParams) (string, OAuthPendingSession, error) { |
| 616 | auth.ensureOAuthSessionLimit() |
| 617 | |
| 618 | service, ok := auth.oauthBroker.GetService(serviceName) |
| 619 | |
| 620 | if !ok { |
| 621 | return "", OAuthPendingSession{}, fmt.Errorf("oauth service not found: %s", serviceName) |
| 622 | } |
| 623 | |
| 624 | sessionId, err := uuid.NewRandom() |
| 625 | |
| 626 | if err != nil { |
| 627 | return "", OAuthPendingSession{}, fmt.Errorf("failed to generate session ID: %w", err) |
| 628 | } |
| 629 | |
| 630 | state := service.NewRandom() |
| 631 | verifier := service.NewRandom() |
| 632 | |
| 633 | session := OAuthPendingSession{ |
| 634 | State: state, |
| 635 | Verifier: verifier, |
| 636 | Service: &service, |
| 637 | ExpiresAt: time.Now().Add(1 * time.Hour), |
| 638 | CallbackParams: params, |
| 639 | } |
| 640 | |
| 641 | auth.oauthMutex.Lock() |
| 642 | auth.oauthPendingSessions[sessionId.String()] = &session |
| 643 | auth.oauthMutex.Unlock() |
| 644 | |
| 645 | return sessionId.String(), session, nil |
| 646 | } |
| 647 | |
| 648 | func (auth *AuthService) GetOAuthURL(sessionId string) (string, error) { |
| 649 | session, err := auth.GetOAuthPendingSession(sessionId) |
no test coverage detected