Gathering detailed insights and metrics for exegesis-cognito
Gathering detailed insights and metrics for exegesis-cognito
Gathering detailed insights and metrics for exegesis-cognito
Gathering detailed insights and metrics for exegesis-cognito
npm install exegesis-cognito
Typescript
Module System
Node Version
NPM Version
TypeScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
3 Stars
88 Commits
1 Forks
5 Branches
3 Contributors
Updated on Jan 23, 2023
Latest Version
3.0.0
Package Id
exegesis-cognito@3.0.0
Unpacked Size
41.69 kB
Size
15.88 kB
File Count
18
NPM Version
6.14.4
Node Version
12.16.2
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
This package provides authentication of AWS cognito tokens in Exegesis requests.
Configure server
1import * as exegesisExpress from 'exegesis-express'; 2import exegesisCognito from 'exegesis-cognito'; 3 4 5async function createServer() { 6 const app = express(); 7 8 const jwks = fs.readFileSync('config/jwks.json', 'utf8') 9 10 app.use(await exegesisExpress.middleware( 11 path.resolve(__dirname, './openapi.yaml'), 12 { 13 // Other options go here... 14 authenticators: { 15 bearerAuth: exegesisCognito( { jwks }) 16 } 17 } 18 )); 19 20 const server = http.createServer(app); 21 server.listen(3000); 22}
Open API spec
1... 2paths: 3 '/things': 4 get: 5 operationId: getThings 6 x-exegesis-controller: thingController 7 security: 8 - bearerAuth: [] 9... 10components: 11 securitySchemes: 12 bearerAuth: 13 type: http 14 scheme: bearer 15 bearerFormat: JWT
Returns an Exegesis authenticator that will authenticate a request with an AWS bearer token.
The authenticator can be configured by passing in an options object.
jwks
is a JSON object that represents a set of JWKs. The JSON object MUST have a keys member, which is an
array of JWKs. The JWKS for a AWS cognito pool can be found at this well known
https://cognito-idp.{region}.amazonaws.com/{userPoolId}/.well-known/jwks.json
See AWS cognito site for more details.
algorithms
: List of strings with the names of the allowed algorithms. For instance, ["HS256", "HS384"]
.audience
: if you want to check audience (aud
), provide a value here. The audience can be checked against a string, a regular expression or a list of strings and/or regular expressions. Eg: "urn:foo"
, /urn:f[o]{2}/
, [/urn:f[o]{2}/, "urn:bar"]
issuer
(optional): string or array of strings of valid values for the iss
field.ignoreExpiration
: if true
do not validate the expiration of the token.ignoreNotBefore
...subject
: if you want to check subject (sub
), provide a value hereclockTolerance
: number of seconds to tolerate when checking the nbf
and exp
claims, to deal with small clock differences among different serversmaxAge
: the maximum allowed age for tokens to still be valid. It is expressed in seconds or a string describing a time span zeit/ms. Eg: 1000
, "2 days"
, "10h"
, "7d"
. A numeric value is interpreted as a seconds count. If you use a string be sure you provide the time units (days, hours, etc), otherwise milliseconds unit is used by default ("120"
is equal to "120ms"
).clockTimestamp
: the time in seconds that should be used as the current time for all necessary comparisons.The authenticator will store the verified decoded token in the context.security
object.
It will also poupulate the context.user
object. The details extracted will deped on whether the bearer token is an id
or access token.
1{ 2 "user": { 3 "id": "ba5bcf72-4b20-4c06-bc6b-ffc710adb244", 4 "username": "jane", 5 "email_verified": false, 6 "email": "janeh@d.oe", 7 "roles": [ 8 "mygroup" 9 ] 10 } 11}
1{ 2 "user": { 3 "id": "ba5bcf72-4b20-4c06-bc6b-ffc710adb244", 4 "username": "niall" 5 } 6}
The client must send the access/id token in the Authorization header when making requests to protected resources. For example,
1curl -X GET \ 2 'http://localhost:3000/things' \ 3 -H 'Authorization: Bearer eyJraWQiOiJpaGZYSVQ4Uk4yeFwvQW15UVo0Z2FUdEw5T3ZqQVpQa3RUcHY4SUpTbWttaz0iLCJhbGciOiJSUzI1NiJ9.eyJzdWIiOiJiYTViY2Y3Mi00YjIwLTRjMDYtYmM2Yi1mZmM3MTBhZGIyNDQiLCJhdWQiOiIyNzh2b2EwY3UzM2Mxa3VlODJyYTYycTY1cSIsImNvZ25pdG86Z3JvdXBzIjpbIm15Z3JvdXAiXSwiZW1haWxfdmVyaWZpZWQiOnRydWUsImV2ZW50X2lkIjoiMzI4NDRkNDgtYjFkZC0xMWU4LWE0NzQtMDVhN2YwNzQzYmE3IiwidG9rZW5fdXNlIjoiaWQiLCJhdXRoX3RpbWUiOjE1MzYyNDI0MjIsImlzcyI6Imh0dHBzOlwvXC9jb2duaXRvLWlkcC51cy1lYXN0LTEuYW1hem9uYXdzLmNvbVwvdXMtZWFzdC0xX1RFU1QiLCJjb2duaXRvOnVzZXJuYW1lIjoiamFuZSIsImV4cCI6MTUzNjI0NjAyMiwiaWF0IjoxNTM2MjQyNDIyLCJlbWFpbCI6ImphbmVAZC5vZSJ9.IdZV1F0MxEU0eC_6Qe_98EjgMSgYEGhP-mwqZtzQb4L8U1jOw-hnK4J1REChsaOatffE-aOJ4uoLV4oPYedRqnX4ABJ9XueN3lWfcZHc_DE2RTvDuEAV7hHoNTZwwn_mgaaYwLNMMOJeciXu3iM7PeT7xJAjdCxcdczZi1hPpqBc9Yx9wM7EMHyEo5klov3zRPJyvFPEpQPgpG1TjNkuvFwcl848YaXQDdlS9rXtTOySBVQu913e3i25VBnxZGxeHpFO3mmUomefOprDEvZpBSPg3-Di4F2-vKDzIl1OT98J8GayrJnD39O1TMUdiW-ApZKBFydtJtqvydQoVmEo_g'
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
Found 1/8 approved changesets -- score normalized to 1
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
license file not detected
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More