Auth Utils
Auth Utils
yarn add @rapharacing/auth-utils
``js
import * as utils from "@rapharacing/auth-utils";
import { getHeaders } from "@rapharacing/auth-utils";
`
Design tokens are freely distributable under the terms of the MIT license.
[license-image]: http://img.shields.io/badge/license-MIT-blue.svg?style=flat
[license-url]: https://github.com/moment/moment/blob/develop/LICENSE
#### Table of Contents
- buildIAMPolicy
- Parameters
- getUserTokens
- Parameters
- setUserToken
- Parameters
- updateUserToken
- Parameters
- decodeJWT
- Parameters
- verifyJWT
- Parameters
- formatAuthorizationToken
- Parameters
- getHeaders
- Parameters
- authorizeUser
- Parameters
Returns an IAM policy document for a given user and resource.
#### Parameters
- username String usernameeffect
- String allow / denyresource
- String resource ARNcontext
- Object response context
Returns Object policyDocument
Returns tokens from key value store
#### Parameters
- db DynamoDB dbtable
- String tableuid
- String uidclient
- String client
Returns Object tokens
Sets tokens in key value store by uid and client
#### Parameters
- db DynamoDB dbtable
- String tableuid
- String uidclient
- String clientdata
- Object data to set as the value in the store
Updates a users tokens in the key value store
#### Parameters
- db DynamoDB dbtable
- String tableuid
- String uidclient
- String clientdata
- Object data to set as the value in the store
Returns decoded user data from JWT
#### Parameters
- token String jwt tokensecret
- String jwt secret depending on env
Returns Object token
Returns verified user data from JWT
#### Parameters
- token String jwt tokensecret
- String jwt secret depending on env
Returns Object token
Formats the Authorization Token
#### Parameters
- token String jwt token
Returns String token
Get common headers depending on environment
#### Parameters
- headers Object headers to mergeenv
- String current environment
Returns Object headers
Returns a boolean whether or not a user is allowed to call a particular method
#### Parameters
- userScopes Array array of user scopesmethodArn` String methodArn
-
Returns Boolean