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

Method FgaListUsers

internal/service/admin_fga.go:211–234  ·  view source on GitHub ↗

FgaListUsers returns the fully-qualified user ids of user_type that have relation on object ("who can access this object?"). This is an introspection surface that reveals the access graph, so it is super-admin gated. Requires super-admin auth. Fail-closed: a nil engine returns ErrFgaNotEnabled. Read

(ctx context.Context, meta RequestMetadata, params *model.FgaListUsersInput)

Source from the content-addressed store, hash-verified

209// Read-only: no audit. Logic migrated from internal/graphql/fga_list_users.go.
210// Permission: authorizer:admin.
211func (p *provider) FgaListUsers(ctx context.Context, meta RequestMetadata, params *model.FgaListUsersInput) (*model.FgaListUsersResponse, *ResponseSideEffects, error) {
212 log := p.Log.With().Str("func", "FgaListUsers").Logger()
213 if err := p.requireSuperAdmin(ctx, meta); err != nil {
214 return nil, nil, err
215 }
216 if p.AuthzEngine == nil {
217 return nil, nil, ErrFgaNotEnabled
218 }
219 if params == nil || strings.TrimSpace(params.Object) == "" || strings.TrimSpace(params.Relation) == "" || strings.TrimSpace(params.UserType) == "" {
220 return nil, nil, InvalidArgument("object, relation and user_type are required")
221 }
222 users, err := p.AuthzEngine.ListUsers(ctx, params.Object, params.Relation, params.UserType)
223 if err != nil {
224 metrics.RecordFgaOperation(metrics.FgaOpListUsers, metrics.FgaResultError)
225 log.Debug().Err(err).Msg("Failed to list users")
226 return nil, nil, err
227 }
228 metrics.RecordFgaOperation(metrics.FgaOpListUsers, metrics.FgaResultSuccess)
229 // Cap the result set; ListUsers is an expensive enumeration surface.
230 if len(users) > maxFgaListResults {
231 users = users[:maxFgaListResults]
232 }
233 return &model.FgaListUsersResponse{Users: users}, nil, nil
234}
235
236// FgaExpand returns the OpenFGA relationship/userset tree for (relation, object)
237// as a JSON string (the explainability/"why" primitive). It reveals the access

Callers

nothing calls this directly

Calls 4

requireSuperAdminMethod · 0.95
RecordFgaOperationFunction · 0.92
InvalidArgumentFunction · 0.85
ListUsersMethod · 0.65

Tested by

no test coverage detected