Authorize
Authorize{#Authorize}
authorize(params) {#authorize}⇒ authorizationSuccessResult
| authorizationErrorResult
authorizationSuccessResult
| authorizationErrorResult
Main authorization function
Consists of the following steps:
If token is missing and endpoint is open, authorize request.
Validate and decode service token.
If servieToken exists and endpoint is open, authorize request.
Try to authorize using serviceAdmin.
Build auth params and check if service token exists.
Authorize organization.
Authorize using optional accessRules.
Returns: authorizationSuccessResult
| authorizationErrorResult
- Either returns an authorizeSuccessResult object or an authorizationErrorResult object
Param | Type | Description |
---|---|---|
params |
| Required - |
params.authParams |
| Required - Object with auth parameters from the request |
params.unverifiedServiceToken |
| Required - Unverified service token in JWT format |
params.serviceTokenSignSecret |
| Required - The secret the unverified token should be validated with |
params.request |
| Required - The request object to be made availbable in authParams |
The result object returnd if the authorization was successful
Param | Type | Description |
---|---|---|
result |
| Required - |
result.credentials |
| Required - |
result.credentials.serviceToken |
| Required - Decoded service token used to authorize the request |
result.artifacts |
| Required - |
result.artifacts.reason |
| Required - Why the request was authorized |
result.artifacts.authenticationParameters |
| Required - The built authorization parameters used to authorize the request |
result.artifacts.matchingAccessRules |
| Required - The built access rules that matched the provided token |
result.artifacts.matchingServiceAdmin |
| Required - If the token matched a service admin rule |
The error object returned if the authorization failed.
Returns either Unauthoried, AccessDenied or ConfigError
Param | Type | Description |
---|---|---|
result |
| Required - |
result.err |
| Required - The error thrown during authorization |
Last updated