mirror of
https://github.com/oauth2-proxy/oauth2-proxy.git
synced 2026-10-20 09:04:28 +02:00
Add the allowed_email_domains and the allowed_groups on the auth_request endpoint + support standard wildcard char for validation with sub-domain and email-domain.
Signed-off-by: Valentin Pichard <github@w3st.fr>
This commit is contained in:
committed by
Valentin Pichard
parent
c5a98c6d03
commit
2b4c8a9846
@@ -153,6 +153,13 @@ func TestValidatorCases(t *testing.T) {
|
||||
email: "foo.bar@example0.com",
|
||||
expectedAuthZ: false,
|
||||
},
|
||||
{
|
||||
name: "EmailNotInCorrect1stSubDomainsNotInEmailsWildcard",
|
||||
allowedEmails: []string{"xyzzy@example.com", "plugh@example.com"},
|
||||
allowedDomains: []string{"*.example0.com", "*.example1.com"},
|
||||
email: "foo.bar@example0.com",
|
||||
expectedAuthZ: false,
|
||||
},
|
||||
{
|
||||
name: "EmailInFirstDomain",
|
||||
allowedEmails: []string{"xyzzy@example.com", "plugh@example.com"},
|
||||
@@ -160,6 +167,13 @@ func TestValidatorCases(t *testing.T) {
|
||||
email: "foo@bar.example0.com",
|
||||
expectedAuthZ: true,
|
||||
},
|
||||
{
|
||||
name: "EmailInFirstDomainWildcard",
|
||||
allowedEmails: []string{"xyzzy@example.com", "plugh@example.com"},
|
||||
allowedDomains: []string{"*.example0.com", "*.example1.com"},
|
||||
email: "foo@bar.example0.com",
|
||||
expectedAuthZ: true,
|
||||
},
|
||||
{
|
||||
name: "EmailNotInCorrect2ndSubDomainsNotInEmails",
|
||||
allowedEmails: []string{"xyzzy@example.com", "plugh@example.com"},
|
||||
@@ -174,6 +188,13 @@ func TestValidatorCases(t *testing.T) {
|
||||
email: "baz@quux.example1.com",
|
||||
expectedAuthZ: true,
|
||||
},
|
||||
{
|
||||
name: "EmailInSecondDomainWildcard",
|
||||
allowedEmails: []string{"xyzzy@example.com", "plugh@example.com"},
|
||||
allowedDomains: []string{"*.example0.com", "*.example1.com"},
|
||||
email: "baz@quux.example1.com",
|
||||
expectedAuthZ: true,
|
||||
},
|
||||
{
|
||||
name: "EmailInFirstEmailList",
|
||||
allowedEmails: []string{"xyzzy@example.com", "plugh@example.com"},
|
||||
@@ -181,6 +202,13 @@ func TestValidatorCases(t *testing.T) {
|
||||
email: "xyzzy@example.com",
|
||||
expectedAuthZ: true,
|
||||
},
|
||||
{
|
||||
name: "EmailInFirstEmailListWildcard",
|
||||
allowedEmails: []string{"xyzzy@example.com", "plugh@example.com"},
|
||||
allowedDomains: []string{"*.example0.com", "*.example1.com"},
|
||||
email: "xyzzy@example.com",
|
||||
expectedAuthZ: true,
|
||||
},
|
||||
{
|
||||
name: "EmailNotInDomainsNotInEmails",
|
||||
allowedEmails: []string{"xyzzy@example.com", "plugh@example.com"},
|
||||
@@ -370,6 +398,13 @@ func TestValidatorCases(t *testing.T) {
|
||||
allowedDomains: []string{"company.com"},
|
||||
expectedAuthZ: false,
|
||||
},
|
||||
{
|
||||
name: "CheckForEqualityNotSuffixWildcard",
|
||||
email: "foo@evilcompany.com",
|
||||
allowedEmails: []string(nil),
|
||||
allowedDomains: []string{"*.company.com"},
|
||||
expectedAuthZ: false,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
|
||||
Reference in New Issue
Block a user