mirror of
https://github.com/oauth2-proxy/oauth2-proxy.git
synced 2026-09-30 11:41:19 +02:00
Add support for setting groups on session when using basic auth (#1064)
* Add support for setting groups on session when using basic auth * Refactoring based on feedback * Attribution
This commit is contained in:
@@ -26,6 +26,7 @@ var _ = Describe("Basic Auth Session Suite", func() {
|
||||
|
||||
type basicAuthSessionLoaderTableInput struct {
|
||||
authorizationHeader string
|
||||
sessionGroups []string
|
||||
existingSession *sessionsapi.SessionState
|
||||
expectedSession *sessionsapi.SessionState
|
||||
}
|
||||
@@ -54,7 +55,7 @@ var _ = Describe("Basic Auth Session Suite", func() {
|
||||
// Create the handler with a next handler that will capture the session
|
||||
// from the scope
|
||||
var gotSession *sessionsapi.SessionState
|
||||
handler := NewBasicAuthSessionLoader(validator)(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
handler := NewBasicAuthSessionLoader(validator, in.sessionGroups)(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
gotSession = middlewareapi.GetRequestScope(r).Session
|
||||
}))
|
||||
handler.ServeHTTP(rw, req)
|
||||
@@ -111,6 +112,12 @@ var _ = Describe("Basic Auth Session Suite", func() {
|
||||
existingSession: nil,
|
||||
expectedSession: &sessionsapi.SessionState{User: "admin"},
|
||||
}),
|
||||
Entry("Basic with groups", basicAuthSessionLoaderTableInput{
|
||||
authorizationHeader: "Basic YWRtaW46QWRtMW4xc3RyJHQwcg==",
|
||||
sessionGroups: []string{"a", "b"},
|
||||
existingSession: nil,
|
||||
expectedSession: &sessionsapi.SessionState{User: "admin", Groups: []string{"a", "b"}},
|
||||
}),
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user