1
0
mirror of https://github.com/oauth2-proxy/oauth2-proxy.git synced 2025-08-08 22:46:33 +02:00

Reinstate preferEmailToUser behaviour for basic auth sessions

This commit is contained in:
Joel Speed
2021-03-21 18:49:30 +00:00
parent b82182763e
commit 64f0a9f580
6 changed files with 32 additions and 6 deletions

View File

@@ -26,6 +26,7 @@ var _ = Describe("Basic Auth Session Suite", func() {
type basicAuthSessionLoaderTableInput struct {
authorizationHeader string
preferEmail bool
sessionGroups []string
existingSession *sessionsapi.SessionState
expectedSession *sessionsapi.SessionState
@@ -55,7 +56,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, in.sessionGroups)(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
handler := NewBasicAuthSessionLoader(validator, in.sessionGroups, in.preferEmail)(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
gotSession = middlewareapi.GetRequestScope(r).Session
}))
handler.ServeHTTP(rw, req)
@@ -118,6 +119,12 @@ var _ = Describe("Basic Auth Session Suite", func() {
existingSession: nil,
expectedSession: &sessionsapi.SessionState{User: "admin", Groups: []string{"a", "b"}},
}),
Entry("Basic Base64(user1:<user1Password>) (with PreferEmailToUser)", basicAuthSessionLoaderTableInput{
authorizationHeader: "Basic dXNlcjE6VXNFck9uM1A0NTU=",
preferEmail: true,
existingSession: nil,
expectedSession: &sessionsapi.SessionState{User: "user1", Email: "user1"},
}),
)
})
})