(ctx AuthenticatorContext)
| 223 | } |
| 224 | |
| 225 | func (a OAuthAuthenticator) getConfig(ctx AuthenticatorContext) (*oauthAuthenticatorConfig, error) { |
| 226 | clientId, err := a.parseRequiredString(ctx.Config, "clientId", ClientIdEnvVarName) |
| 227 | if err != nil { |
| 228 | return nil, err |
| 229 | } |
| 230 | clientSecret, _ := a.parseString(ctx.Config, "clientSecret", ClientSecretEnvVarName) |
| 231 | redirectUri, err := a.parseRequiredString(ctx.Config, "redirectUri", RedirectUriVarName) |
| 232 | if err != nil { |
| 233 | return nil, err |
| 234 | } |
| 235 | parsedRedirectUri, err := url.Parse(redirectUri) |
| 236 | if err != nil { |
| 237 | return nil, err |
| 238 | } |
| 239 | scopes, err := a.parseRequiredString(ctx.Config, "scopes", ScopesEnvVarName) |
| 240 | if err != nil { |
| 241 | return nil, err |
| 242 | } |
| 243 | offlineAccess, err := a.parseBool(ctx.Config, "offlineAccess", true) |
| 244 | if err != nil { |
| 245 | return nil, err |
| 246 | } |
| 247 | if offlineAccess { |
| 248 | scopes = scopes + " " + offlineAccessScope |
| 249 | } |
| 250 | return newOAuthAuthenticatorConfig(clientId, clientSecret, *parsedRedirectUri, scopes, ctx.IdentityUri, offlineAccess), nil |
| 251 | } |
| 252 | |
| 253 | func (a OAuthAuthenticator) parseString(config map[string]interface{}, name string, envVarName string) (string, error) { |
| 254 | envVarValue := os.Getenv(envVarName) |
no test coverage detected