README
Global Authorizer function to authorize protected routes
How do I get set up?
- Summary of set up
** npm install @teamfabric/authorizer **
Add a route under a /app/routes/auth/authorizer.js
Copy and paste below
const { authorize } = require('@teamfabric/authorizer')
exports.handler = async event => {
return authorize(event)
}
In your serverless.yml add the handeer to the route above
functions:
authorizerFunc:
handler: app/routes/auth/authorize.handler
For routes you want to protect add
authorizer:
name: authorizerFunc
resultTtlInSeconds: 0
For example
user-get:
name: ${self:provider.apiName}-user-get
memorySize: 512
handler: app/routes/user/core/get.handler
events:
- http:
method: get
path: /user/{userId}
private: true
authorizer:
name: authorizerFunc
resultTtlInSeconds: 0
How do I test?
- Create and setup
.env
file using .env.example
file secrets
Secrets | Description |
---|
PUBLIC | Public key |
PRIVATE | RSA Private key |
OKTA_ISSUERS | Stringified JSON |
ISSUER | String |
TRUSTED_ISSUERS | Stringified JSON |
OKTA_ACCOUNT | String |
OKTA_ACCOUNT_ID | String |
STAGE | String |
PLATFORM | String |
RUN_AUTHORIZER | String |
- RUN
npm run test
to run test cases