Feature 03 task 2: Server-side sessions, cookie and logout (#19)
CI / ci (push) Successful in 1m24s
CI / ci (push) Successful in 1m24s
Co-authored-by: dev_agent <dev_agent@cubecraftlabs.com> Co-committed-by: dev_agent <dev_agent@cubecraftlabs.com>
This commit was merged in pull request #19.
This commit is contained in:
@@ -86,6 +86,7 @@ func (p *fakeProvider) discovery(w http.ResponseWriter, _ *http.Request) {
|
||||
"authorization_endpoint": p.issuer() + "/authorize",
|
||||
"token_endpoint": p.issuer() + "/token",
|
||||
"jwks_uri": p.issuer() + "/jwks",
|
||||
"end_session_endpoint": p.issuer() + "/end-session/",
|
||||
"response_types_supported": []string{"code"},
|
||||
"subject_types_supported": []string{"public"},
|
||||
"id_token_signing_alg_values_supported": []string{"RS256", "HS256"},
|
||||
@@ -223,11 +224,12 @@ func writeJSON(w http.ResponseWriter, v any) {
|
||||
json.NewEncoder(w).Encode(v)
|
||||
}
|
||||
|
||||
// memorySessions is an in-memory SessionStarter that records the claims it
|
||||
// was handed.
|
||||
// memorySessions is an in-memory Sessions that records the claims it was
|
||||
// handed and how many sessions were ended.
|
||||
type memorySessions struct {
|
||||
mu sync.Mutex
|
||||
claims []Claims
|
||||
ended int
|
||||
err error
|
||||
}
|
||||
|
||||
@@ -242,6 +244,16 @@ func (m *memorySessions) StartSession(w http.ResponseWriter, _ *http.Request, cl
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *memorySessions) EndSession(http.ResponseWriter, *http.Request) error {
|
||||
m.mu.Lock()
|
||||
defer m.mu.Unlock()
|
||||
if m.err != nil {
|
||||
return m.err
|
||||
}
|
||||
m.ended++
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *memorySessions) started() []Claims {
|
||||
m.mu.Lock()
|
||||
defer m.mu.Unlock()
|
||||
@@ -780,6 +792,7 @@ func TestNewRejectsRemoteHTTPEndpoint(t *testing.T) {
|
||||
{"authorization_endpoint", "authorization endpoint"},
|
||||
{"token_endpoint", "token endpoint"},
|
||||
{"jwks_uri", "JWKS endpoint"},
|
||||
{"end_session_endpoint", "end session endpoint"},
|
||||
}
|
||||
for _, tc := range tests {
|
||||
t.Run(tc.field, func(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user