Skip to content
Snippets Groups Projects
Verified Commit ee5c21ff authored by Janne Mareike Koschinski's avatar Janne Mareike Koschinski
Browse files

Implement optional login functionality

parent 6193766d
Branches
Tags 1.5.2
No related merge requests found
...@@ -143,6 +143,8 @@ type Resource struct { ...@@ -143,6 +143,8 @@ type Resource struct {
Methods []string `json:"methods" yaml:"methods"` Methods []string `json:"methods" yaml:"methods"`
// WhiteListed permits the prefix through // WhiteListed permits the prefix through
WhiteListed bool `json:"white-listed" yaml:"white-listed"` WhiteListed bool `json:"white-listed" yaml:"white-listed"`
// WhiteListed permits the prefix through
OptionalLogin bool `json:"optional-login" yaml:"optional-login"`
// RequireAnyRole indicates that ANY of the roles are required, the default is all // RequireAnyRole indicates that ANY of the roles are required, the default is all
RequireAnyRole bool `json:"require-any-role" yaml:"require-any-role"` RequireAnyRole bool `json:"require-any-role" yaml:"require-any-role"`
// Roles the roles required to access this url // Roles the roles required to access this url
......
...@@ -264,14 +264,16 @@ func (r *oauthProxy) createReverseProxy() error { ...@@ -264,14 +264,16 @@ func (r *oauthProxy) createReverseProxy() error {
r.admissionMiddleware(false, x), r.admissionMiddleware(false, x),
r.identityHeadersMiddleware(r.config.AddClaims)) r.identityHeadersMiddleware(r.config.AddClaims))
w := engine.With( o := engine.With(
r.authenticationMiddleware(true), r.authenticationMiddleware(true),
r.admissionMiddleware(true, x), r.admissionMiddleware(true, x),
r.identityHeadersMiddleware(r.config.AddClaims)) r.identityHeadersMiddleware(r.config.AddClaims))
for _, m := range x.Methods { for _, m := range x.Methods {
if x.WhiteListed { if x.OptionalLogin {
w.MethodFunc(m, x.URL, emptyHandler) o.MethodFunc(m, x.URL, emptyHandler)
} else if x.WhiteListed {
engine.MethodFunc(m, x.URL, emptyHandler)
} else { } else {
e.MethodFunc(m, x.URL, emptyHandler) e.MethodFunc(m, x.URL, emptyHandler)
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment