Filter inactive and private oidc auth methods from unauthenticated list requests (#1110)

This commit is contained in:
Todd Knight authored and GitHub committed 2021-04-13 16:42:25 -07:00
1 parent ca57e50516
commit 072b950540
8 files changed
+155 -36

No files matched your search

+7 -3
View File
@@ -42,6 +42,10 @@ const (
AuthTokenTypeRecoveryKms
)
const (
AnonymousUserId = "u_anon"
)
type key int
var verifierKey key
@@ -238,7 +242,7 @@ func Verify(ctx context.Context, opt ...Option) (ret VerifyResults) {
// If the anon user was used (either no token, or invalid (perhaps
// expired) token), return a 401. That way if it's an authn'd user
// that is not authz'd we'll return 403 to be explicit.
if ret.UserId == "u_anon" {
if ret.UserId == AnonymousUserId {
ret.Error = handlers.UnauthenticatedError()
}
return
@@ -381,7 +385,7 @@ func (v verifier) performAuthCheck() (aclResults perms.ACLResults, userId string
// Make the linter happy
_ = retErr
scopeInfo = new(scopes.ScopeInfo)
userId = "u_anon"
userId = AnonymousUserId
var accountId string
// Validate the token and fetch the corresponding user ID
@@ -416,7 +420,7 @@ func (v verifier) performAuthCheck() (aclResults perms.ACLResults, userId string
userId = at.GetIamUserId()
if userId == "" {
v.logger.Warn("perform auth check: valid token did not map to a user, likely because no account is associated with the user any longer; continuing as u_anon", "token_id", at.GetPublicId())
userId = "u_anon"
userId = AnonymousUserId
accountId = ""
}
}