You've already forked oauth2-proxy
mirror of
https://github.com/oauth2-proxy/oauth2-proxy.git
synced 2025-07-15 01:44:22 +02:00
Fix default scope settings for none oidc providers like GitHub (#1927)
* fix default scope settings for none oidc providers * add changelog for bugfix * fix scope test cases by producing and accessing correct result value
This commit is contained in:
@ -12,6 +12,7 @@
|
|||||||
- [#1882](https://github.com/oauth2-proxy/oauth2-proxy/pull/1882) Make `htpasswd.GetUsers` racecondition safe
|
- [#1882](https://github.com/oauth2-proxy/oauth2-proxy/pull/1882) Make `htpasswd.GetUsers` racecondition safe
|
||||||
- [#1883](https://github.com/oauth2-proxy/oauth2-proxy/pull/1883) Ensure v8 manifest variant is set on docker images
|
- [#1883](https://github.com/oauth2-proxy/oauth2-proxy/pull/1883) Ensure v8 manifest variant is set on docker images
|
||||||
- [#1906](https://github.com/oauth2-proxy/oauth2-proxy/pull/1906) Fix PKCE code verifier generation to never use UTF-8 characters
|
- [#1906](https://github.com/oauth2-proxy/oauth2-proxy/pull/1906) Fix PKCE code verifier generation to never use UTF-8 characters
|
||||||
|
- [#1927](https://github.com/oauth2-proxy/oauth2-proxy/pull/1927) Fix default scope settings for none oidc providers
|
||||||
|
|
||||||
# V7.4.0
|
# V7.4.0
|
||||||
|
|
||||||
|
@ -152,7 +152,7 @@ func newProviderDataFromConfig(providerConfig options.Provider) (*ProviderData,
|
|||||||
p.EmailClaim = providerConfig.OIDCConfig.UserIDClaim
|
p.EmailClaim = providerConfig.OIDCConfig.UserIDClaim
|
||||||
}
|
}
|
||||||
|
|
||||||
if p.Scope == "" {
|
if providerConfig.Type == "oidc" && p.Scope == "" {
|
||||||
p.Scope = "openid email profile"
|
p.Scope = "openid email profile"
|
||||||
|
|
||||||
if len(providerConfig.AllowedGroups) > 0 {
|
if len(providerConfig.AllowedGroups) > 0 {
|
||||||
|
@ -125,32 +125,48 @@ func TestScope(t *testing.T) {
|
|||||||
|
|
||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
name string
|
name string
|
||||||
|
configuredType options.ProviderType
|
||||||
configuredScope string
|
configuredScope string
|
||||||
expectedScope string
|
expectedScope string
|
||||||
allowedGroups []string
|
allowedGroups []string
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "with no scope provided",
|
name: "oidc: with no scope provided",
|
||||||
|
configuredType: "oidc",
|
||||||
configuredScope: "",
|
configuredScope: "",
|
||||||
expectedScope: "openid email profile",
|
expectedScope: "openid email profile",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "with no scope provided and groups",
|
name: "oidc: with no scope provided and groups",
|
||||||
|
configuredType: "oidc",
|
||||||
configuredScope: "",
|
configuredScope: "",
|
||||||
expectedScope: "openid email profile groups",
|
expectedScope: "openid email profile groups",
|
||||||
allowedGroups: []string{"foo"},
|
allowedGroups: []string{"foo"},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "with a configured scope provided",
|
name: "oidc: with a configured scope provided",
|
||||||
|
configuredType: "oidc",
|
||||||
configuredScope: "openid",
|
configuredScope: "openid",
|
||||||
expectedScope: "openid",
|
expectedScope: "openid",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "github: with no scope provided",
|
||||||
|
configuredType: "github",
|
||||||
|
configuredScope: "",
|
||||||
|
expectedScope: "user:email",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "github: with a configured scope provided",
|
||||||
|
configuredType: "github",
|
||||||
|
configuredScope: "user:email org:read",
|
||||||
|
expectedScope: "user:email org:read",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
providerConfig := options.Provider{
|
providerConfig := options.Provider{
|
||||||
ID: providerID,
|
ID: providerID,
|
||||||
Type: "oidc",
|
Type: tc.configuredType,
|
||||||
ClientID: clientID,
|
ClientID: clientID,
|
||||||
ClientSecretFile: clientSecret,
|
ClientSecretFile: clientSecret,
|
||||||
LoginURL: msAuthURL,
|
LoginURL: msAuthURL,
|
||||||
@ -164,10 +180,10 @@ func TestScope(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
pd, err := newProviderDataFromConfig(providerConfig)
|
pd, err := NewProvider(providerConfig)
|
||||||
g.Expect(err).ToNot(HaveOccurred())
|
g.Expect(err).ToNot(HaveOccurred())
|
||||||
|
|
||||||
g.Expect(pd.Scope).To(Equal(tc.expectedScope))
|
g.Expect(pd.Data().Scope).To(Equal(tc.expectedScope))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user