Deny suspended directory identities
All checks were successful
Build and Publish Container Image / build-and-push (push) Successful in 24s

This commit is contained in:
tegwick 2026-07-28 01:23:22 +02:00
parent 76da0237ff
commit 909bb327fc
4 changed files with 67 additions and 7 deletions

View file

@ -202,6 +202,30 @@ func TestTokenHandler_ValidExchange_ReturnsJWT(t *testing.T) {
}
}
func TestTokenHandler_SuspendedUserCannotExchangeCode(t *testing.T) {
sessions := oidc.NewSessionStore()
user := aliceUser()
user.Groups = append(user.Groups, "netkingdom-suspended")
users := &mockUserRepo{users: map[string]*domain.User{"alice": user}}
h, _ := newTokenHandler(t, sessions, users)
verifier := "suspended-verifier-with-enough-entropy"
code := seededSession(sessions, verifier)
req := tokenRequest(url.Values{
"grant_type": {"authorization_code"},
"code": {code},
"client_id": {"test-client"},
"code_verifier": {verifier},
})
w := httptest.NewRecorder()
h.ServeHTTP(w, req)
if w.Code != http.StatusForbidden {
t.Fatalf("expected 403, got %d: %s", w.Code, w.Body.String())
}
if _, ok := sessions.Get(code); ok {
t.Fatal("authorization code must be consumed when suspension is detected")
}
}
func TestTokenHandler_WrongGrantType_FeatureNotSupported(t *testing.T) {
sessions := oidc.NewSessionStore()
users := &mockUserRepo{}