Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

feat: resolved service token failure

=0b2572334e10
diff --git a/backend-go/internal/services/auth/apiauth/authenticator.go b/backend-go/internal/services/auth/apiauth/authenticator.go
index 344f81b01c..6d27764e48 100644
--- a/backend-go/internal/services/auth/apiauth/authenticator.go
+++ b/backend-go/internal/services/auth/apiauth/authenticator.go
@@ -387,16 +387,16 @@ func (a *ApiAuthenticator) validateIdentityTokenClaims(ctx context.Context, clai
}
// ValidateServiceToken performs real service token validation.
-// Exact port of fnValidateServiceToken in service-token-service.ts:172-199.
+// TODO(go): FIPS mode changes in bcrypt to the other one is needed
func (a *ApiAuthenticator) ValidateServiceToken(ctx context.Context, token string) (*auth.Identity, error) {
- // 1. Split token: "st.<tokenID>.<tokenSecret>"
- parts := strings.SplitN(token, ".", 3)
- if len(parts) != 3 || parts[0] != "st" {
+ // 1. Split token: "st.<tokenID>.<tokenSecret>[.<extra>]"
+ // Legacy tokens may have a 4th segment that should be ignored.
+ parts := strings.SplitN(token, ".", 4)
+ if len(parts) < 3 || parts[0] != "st" {
return nil, errutil.Unauthorized("You are not allowed to access this resource").WithErrf("validateServiceToken: invalid token format")
}
tokenID := parts[1]
tokenSecret := parts[2]
-
// 2. Find service token.
serviceToken, err := a.findServiceTokenByID(ctx, tokenID)
if err != nil {
diff --git a/backend-go/internal/services/permission/permission.go b/backend-go/internal/services/permission/permission.go
index c0d5fc8038..71d122aa4d 100644
--- a/backend-go/internal/services/permission/permission.go
+++ b/backend-go/internal/services/permission/permission.go
@@ -576,12 +576,16 @@ func (s *Service) getPermission(ctx context.Context, params *getPermissionParams
where.Add("membership.scope = 'project'").Add(`membership."scopeProjectId" = @projectID`)
}
- // Build additional privilege join condition
+ // Build additional privilege join condition.
+ // Match the privilege against the request's actor literal, not against
+ // membership.actor*Id. Group-derived memberships have actorUserId/actorIdentityId
+ // NULL, so the column-to-column predicate dropped privileges for any user/identity
+ // whose only project access is via a group.
apJoinCond := qb.NewWhere()
if params.ActorType == auth.ActorTypeIdentity {
- apJoinCond.Add(`membership."actorIdentityId" = addlPriv."actorIdentityId"`)
+ apJoinCond.Add(`addlPriv."actorIdentityId" = @actorID`)
} else {
- apJoinCond.Add(`membership."actorUserId" = addlPriv."actorUserId"`)
+ apJoinCond.Add(`addlPriv."actorUserId" = @actorID`)
}
if params.Scope == AccessScopeOrganization {
apJoinCond.Add(`membership."scopeOrgId" = addlPriv."orgId"`)