AuthN: Fix namespaces for anonymous and render (#75661)

* AuthN: remove IsAnonymous from identity struct and set correct namespace for anonymous and render

* Don't parse user id for render namespace
This commit is contained in:
Karl Persson
2023-09-29 09:10:33 +02:00
committed by GitHub
parent 0e2b741fc3
commit 7a38090bc0
10 changed files with 20 additions and 17 deletions

View File

@ -57,7 +57,7 @@ func TestAuth_Middleware(t *testing.T) {
desc: "ReqSignedIn should return 200 for anonymous user",
path: "/api/secure",
authMiddleware: ReqSignedIn,
identity: &authn.Identity{IsAnonymous: true},
identity: &authn.Identity{ID: authn.AnonymousNamespaceID},
expecedReached: true,
expectedCode: http.StatusOK,
},
@ -65,7 +65,7 @@ func TestAuth_Middleware(t *testing.T) {
desc: "ReqSignedIn should return redirect anonymous user with forceLogin query string",
path: "/secure?forceLogin=true",
authMiddleware: ReqSignedIn,
identity: &authn.Identity{IsAnonymous: true},
identity: &authn.Identity{ID: authn.AnonymousNamespaceID},
expecedReached: false,
expectedCode: http.StatusFound,
},
@ -73,7 +73,7 @@ func TestAuth_Middleware(t *testing.T) {
desc: "ReqSignedIn should return redirect anonymous user when orgId in query string is different from currently used",
path: "/secure?orgId=2",
authMiddleware: ReqSignedIn,
identity: &authn.Identity{IsAnonymous: true, OrgID: 1},
identity: &authn.Identity{ID: authn.AnonymousNamespaceID, OrgID: 1},
expecedReached: false,
expectedCode: http.StatusFound,
},
@ -81,7 +81,7 @@ func TestAuth_Middleware(t *testing.T) {
desc: "ReqSignedInNoAnonymous should return 401 for anonymous user",
path: "/api/secure",
authMiddleware: ReqSignedInNoAnonymous,
identity: &authn.Identity{IsAnonymous: true},
identity: &authn.Identity{ID: authn.AnonymousNamespaceID},
expecedReached: false,
expectedCode: http.StatusUnauthorized,
},