Functions - auth

checkForScopeMatch

Check whether the scopes of the user and scopes of resource matches.

extractUsernameAndPassword

Extracts the username and password from the credential values.

prepareError

Log and prepare error as a Error.

setAuthenticationContext

Set the authentication context values to invocation context.

setPrincipal

Set the principal values to invocation context.

checkForScopeMatch

(string[] | string[] resourceScopes, string[] userScopes, string authzCacheKey, Cache? positiveAuthzCache, Cache? negativeAuthzCache)

returns boolean

Check whether the scopes of the user and scopes of resource matches.

Parameters

  • userScopes string[]
  • Scopes of user

  • authzCacheKey string
  • Authorization cache key

  • positiveAuthzCache Cache?
  • The cache for positive authorizations

  • negativeAuthzCache Cache?
  • The cache for negative authorizations

  • Return Type

    (boolean)
  • true if there is a match between resource and user scopes, else false

extractUsernameAndPassword

(string credential)

returns [string, string] | Error

Extracts the username and password from the credential values.

Parameters

  • credential string
  • The credential values.

  • Return Type

    ([string, string] | Error)
  • A string tuple with the extracted username and password or Error occurred while extracting credentials

prepareError

(string message, error? err)

returns Error

Log and prepare error as a Error.

Parameters

  • message string
  • Error message

  • err error? - ()
  • error instance

  • Return Type

    (Error)
  • Prepared Error instance

setAuthenticationContext

Set the authentication context values to invocation context.

Parameters

  • scheme string
  • Auth scheme (JWT, LDAP, OAuth2, Basic etc.)

  • authToken string
  • Auth token (credential)

setPrincipal

Set the principal values to invocation context.

Parameters

  • userId string? - ()
  • User Id of the authenticated user.

  • username string? - ()
  • Username of the authenticated user.

  • scopes string[]? - ()
  • Authenticated user scopes.

  • claims map? - ()
  • Claims of the authenticated user.