MCPcopy Create free account
hub / github.com/Permify/permify / SubjectFilter

Method SubjectFilter

internal/engines/subject_filter.go:61–83  ·  view source on GitHub ↗

SubjectFilter is a method for the SubjectFilterEngine struct. It takes a context and a pointer to a PermissionSubjectFilterRequest and returns a pointer to a PermissionSubjectFilterResponse and an error.

(ctx context.Context, request *base.PermissionLookupSubjectRequest)

Source from the content-addressed store, hash-verified

59// It takes a context and a pointer to a PermissionSubjectFilterRequest
60// and returns a pointer to a PermissionSubjectFilterResponse and an error.
61func (engine *SubjectFilter) SubjectFilter(ctx context.Context, request *base.PermissionLookupSubjectRequest) (response []string, err error) {
62 // ReadEntityDefinition method of the SchemaReader interface is used to retrieve the entity's schema definition.
63 // GetTenantId, GetType and GetSchemaVersion methods are used to provide necessary arguments to ReadEntityDefinition.
64 var en *base.EntityDefinition
65 en, _, err = engine.schemaReader.ReadEntityDefinition(ctx, request.GetTenantId(), request.GetEntity().GetType(), request.GetMetadata().GetSchemaVersion())
66 if err != nil {
67 // If an error is encountered while reading the schema definition, return an empty response and the error.
68 return subjectFilterEmpty(), err
69 }
70
71 var res []string
72
73 // Call the subjectFilter method of the engine, which returns a function.
74 // That function is then immediately called with the context to perform the actual subject lookup.
75 res, err = engine.subjectFilter(ctx, request, en)(ctx)
76 if err != nil {
77 // If an error is encountered during the lookup, return an empty response and the error.
78 return subjectFilterEmpty(), err
79 }
80
81 // If everything went smoothly, return the lookup result and nil error.
82 return res, nil
83}
84
85// subjectFilter is a method for the SubjectFilterEngine struct.
86// It determines the type of relational reference for the permission field in the request,

Callers 5

subjectFilterCallMethod · 0.95
LookupSubjectMethod · 0.80

Calls 8

subjectFilterMethod · 0.95
subjectFilterEmptyFunction · 0.85
ReadEntityDefinitionMethod · 0.65
GetTypeMethod · 0.65
GetTenantIdMethod · 0.45
GetEntityMethod · 0.45
GetSchemaVersionMethod · 0.45
GetMetadataMethod · 0.45

Tested by

no test coverage detected