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)
| 113 | // "type:id" form (both halves non-empty). It rejects usersets |
| 114 | // ("type:id#relation") and malformed values. |
| 115 | func 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 |
no test coverage detected