MCPcopy Create free account
hub / github.com/authorizerdev/authorizer / validateFgaSubject

Function validateFgaSubject

internal/service/fga.go:115–124  ·  view source on GitHub ↗

validateFgaSubject ensures an explicitly supplied subject is in OpenFGA "type:id" form (both halves non-empty). It rejects usersets ("type:id#relation") and malformed values.

(user string)

Source from the content-addressed store, hash-verified

113// "type:id" form (both halves non-empty). It rejects usersets
114// ("type:id#relation") and malformed values.
115func validateFgaSubject(user string) error {
116 objType, objID, found := strings.Cut(user, ":")
117 if !found || strings.TrimSpace(objType) == "" || strings.TrimSpace(objID) == "" {
118 return InvalidArgument(fmt.Sprintf("user must be in type:id form, got %q", user))
119 }
120 if strings.Contains(objID, "#") {
121 return InvalidArgument(fmt.Sprintf("user must be a concrete subject in type:id form, not a userset, got %q", user))
122 }
123 return nil
124}
125
126// toContextualTuples converts client-supplied contextual tuples. These are
127// request-scoped only (never persisted) and are safe to accept from any

Callers 1

resolveFgaSubjectMethod · 0.85

Calls 1

InvalidArgumentFunction · 0.85

Tested by

no test coverage detected