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

Method Check

internal/engines/check.go:63–84  ·  view source on GitHub ↗

Check executes a permission check based on the provided request. The permission field in the request can either be a relation or an permission. This function performs various checks and returns the permission check response along with any errors that may have occurred.

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

Source from the content-addressed store, hash-verified

61// This function performs various checks and returns the permission check response
62// along with any errors that may have occurred.
63func (engine *CheckEngine) Check(ctx context.Context, request *base.PermissionCheckRequest) (response *base.PermissionCheckResponse, err error) {
64 emptyResp := denied(emptyResponseMetadata())
65
66 // Retrieve entity definition
67 var en *base.EntityDefinition
68 en, _, err = engine.schemaReader.ReadEntityDefinition(ctx, request.GetTenantId(), request.GetEntity().GetType(), request.GetMetadata().GetSchemaVersion())
69 if err != nil {
70 return emptyResp, err
71 }
72
73 // Perform permission check
74 var res *base.PermissionCheckResponse
75 res, err = engine.check(ctx, request, en)(ctx)
76 if err != nil {
77 return emptyResp, err
78 }
79
80 return &base.PermissionCheckResponse{
81 Can: res.Can,
82 Metadata: res.Metadata,
83 }, nil
84}
85
86// CheckFunction is a type that represents a function that takes a context
87// and returns a PermissionCheckResponse along with an error. It is used

Callers

nothing calls this directly

Calls 9

checkMethod · 0.95
deniedFunction · 0.85
emptyResponseMetadataFunction · 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