git.iko.soy/typeable/oauth2-proxy
on master help sign in
Fixed name for GoogleGroups env variable + unit tests (#2221)
f3269b3Koen van Zuijlen
CHANGELOG.md+2
@@ -7,6 +7,8 @@
7## Breaking Changes
7## Breaking Changes
8
8
9## Changes since v7.5.0
9## Changes since v7.5.0
10+
11+- [#2221](https://github.com/oauth2-proxy/oauth2-proxy/pull/2221) Backwards compatible fix for wrong environment variable name (OAUTH2_PROXY_GOOGLE_GROUPS) (@kvanzuijlen)
10- [#1989](https://github.com/oauth2-proxy/oauth2-proxy/pull/1989) Fix default scope for keycloak-oidc provider
12- [#1989](https://github.com/oauth2-proxy/oauth2-proxy/pull/1989) Fix default scope for keycloak-oidc provider
11
13
12# V7.5.0
14# V7.5.0
pkg/apis/options/legacy_options.go+10−1
@@ -3,6 +3,7 @@ package options
3import (
3import (
4 "fmt"
4 "fmt"
5 "net/url"
5 "net/url"
6+ "reflect"
6 "strconv"
7 "strconv"
7 "strings"
8 "strings"
8 "time"
9 "time"
@@ -494,7 +495,8 @@ type LegacyProvider struct {
494 GitHubUsers []string `flag:"github-user" cfg:"github_users"`
495 GitHubUsers []string `flag:"github-user" cfg:"github_users"`
495 GitLabGroup []string `flag:"gitlab-group" cfg:"gitlab_groups"`
496 GitLabGroup []string `flag:"gitlab-group" cfg:"gitlab_groups"`
496 GitLabProjects []string `flag:"gitlab-project" cfg:"gitlab_projects"`
497 GitLabProjects []string `flag:"gitlab-project" cfg:"gitlab_projects"`
498+ GoogleGroupsLegacy []string `flag:"google-group" cfg:"google_group"`
497− GoogleGroups []string `flag:"google-group" cfg:"google_group"`
499+ GoogleGroups []string `flag:"google-group" cfg:"google_groups"`
498 GoogleAdminEmail string `flag:"google-admin-email" cfg:"google_admin_email"`
500 GoogleAdminEmail string `flag:"google-admin-email" cfg:"google_admin_email"`
499 GoogleServiceAccountJSON string `flag:"google-service-account-json" cfg:"google_service_account_json"`
501 GoogleServiceAccountJSON string `flag:"google-service-account-json" cfg:"google_service_account_json"`
500 GoogleUseApplicationDefaultCredentials bool `flag:"google-use-application-default-credentials" cfg:"google_use_application_default_credentials"`
502 GoogleUseApplicationDefaultCredentials bool `flag:"google-use-application-default-credentials" cfg:"google_use_application_default_credentials"`
@@ -727,6 +729,13 @@ func (l *LegacyProvider) convert() (Providers, error) {
727 Repository: l.BitbucketRepository,
729 Repository: l.BitbucketRepository,
728 }
730 }
729 case "google":
731 case "google":
732+ if len(l.GoogleGroupsLegacy) != 0 && !reflect.DeepEqual(l.GoogleGroupsLegacy, l.GoogleGroups) {
733+ // Log the deprecation notice
734+ logger.Error(
735+ "WARNING: The 'OAUTH2_PROXY_GOOGLE_GROUP' environment variable is deprecated and will likely be removed in the next major release. Use 'OAUTH2_PROXY_GOOGLE_GROUPS' instead.",
736+ )
737+ l.GoogleGroups = l.GoogleGroupsLegacy
738+ }
730 provider.GoogleConfig = GoogleOptions{
739 provider.GoogleConfig = GoogleOptions{
731 Groups: l.GoogleGroups,
740 Groups: l.GoogleGroups,
732 AdminEmail: l.GoogleAdminEmail,
741 AdminEmail: l.GoogleAdminEmail,
pkg/apis/options/legacy_options_test.go+13
@@ -991,6 +991,14 @@ var _ = Describe("Legacy Options", func() {
991 GoogleServiceAccountJSON: "test.json",
991 GoogleServiceAccountJSON: "test.json",
992 GoogleGroups: []string{"1", "2"},
992 GoogleGroups: []string{"1", "2"},
993 }
993 }
994+
995+ legacyConfigLegacyProvider := LegacyProvider{
996+ ClientID: clientID,
997+ ProviderType: "google",
998+ GoogleAdminEmail: "email@email.com",
999+ GoogleServiceAccountJSON: "test.json",
1000+ GoogleGroupsLegacy: []string{"1", "2"},
1001+ }
994 DescribeTable("convertLegacyProviders",
1002 DescribeTable("convertLegacyProviders",
995 func(in *convertProvidersTableInput) {
1003 func(in *convertProvidersTableInput) {
996 providers, err := in.legacyProvider.convert()
1004 providers, err := in.legacyProvider.convert()
@@ -1024,6 +1032,11 @@ var _ = Describe("Legacy Options", func() {
1024 expectedProviders: Providers{internalConfigProvider},
1032 expectedProviders: Providers{internalConfigProvider},
1025 errMsg: "",
1033 errMsg: "",
1026 }),
1034 }),
1035+ Entry("with legacy provider config", &convertProvidersTableInput{
1036+ legacyProvider: legacyConfigLegacyProvider,
1037+ expectedProviders: Providers{internalConfigProvider},
1038+ errMsg: "",
1039+ }),
1027 )
1040 )
1028 })
1041 })
1029})
1042})
pkg/apis/options/load.go+2−2
@@ -43,8 +43,8 @@ func Load(configFileName string, flagSet *pflag.FlagSet, into interface{}) error
43 return fmt.Errorf("unable to register flags: %w", err)
43 return fmt.Errorf("unable to register flags: %w", err)
44 }
44 }
45
45
46− // UnmarhsalExact will return an error if the config includes options that are
46+ // UnmarshalExact will return an error if the config includes options that are
47− // not mapped to felds of the into struct
47+ // not mapped to fields of the into struct
48 err = v.UnmarshalExact(into, decodeFromCfgTag)
48 err = v.UnmarshalExact(into, decodeFromCfgTag)
49 if err != nil {
49 if err != nil {
50 return fmt.Errorf("error unmarshalling config: %w", err)
50 return fmt.Errorf("error unmarshalling config: %w", err)