Validate validates if the OAuth2 client configuration is valid.
()
| 463 | |
| 464 | // Validate validates if the OAuth2 client configuration is valid. |
| 465 | func (o *AuthOAuth2ClientConfig) Validate() error { |
| 466 | if err := o.Redirect.Validate(); err != nil { |
| 467 | return wrap(err, "redirect") |
| 468 | } |
| 469 | if o.ClientID == "" { |
| 470 | return newError("clientId", "empty client ID") |
| 471 | } |
| 472 | |
| 473 | if o.ClientSecret == "" { |
| 474 | return newError("clientSecret", "empty client secret") |
| 475 | } |
| 476 | |
| 477 | if err := o.Provider.Validate(); err != nil { |
| 478 | return wrap(err, "provider") |
| 479 | } |
| 480 | |
| 481 | switch o.Provider { |
| 482 | case AuthOAuth2GitHubProvider: |
| 483 | if err := o.GitHub.Validate(); err != nil { |
| 484 | return wrap(err, "github") |
| 485 | } |
| 486 | case AuthOAuth2OIDCProvider: |
| 487 | if err := o.OIDC.Validate(); err != nil { |
| 488 | return wrap(err, "oidc") |
| 489 | } |
| 490 | case AuthOAuth2GenericProvider: |
| 491 | if err := o.Generic.Validate(); err != nil { |
| 492 | return wrap(err, "generic") |
| 493 | } |
| 494 | } |
| 495 | |
| 496 | return nil |
| 497 | } |
| 498 | |
| 499 | // OAuth2ProviderName provides the various methods of oAuth2 authentication. |
| 500 | type OAuth2ProviderName string |