Skip to content

Add support for JWT secret callbacks to allow JWKS (required for Auth0) #551

@MaxDesiatov

Description

@MaxDesiatov

I'm using Auth0 and secrets for JWT middleware in their example code is fetched through jwks. This isn't possible with current postgraphql API, even v4 as it only accepts secrets supplied as strings, not callback function.

Specifically I would like jwtSecret property to accept something like

import * as jwks from 'jwks-rsa';
...

app.use(postgraphql(connectionString, 'public', {
      ...
      jwtAudiences: ['custom.audience.id'],
      jwtSecret: jwks.expressJwtSecret({
          cache: true,
          rateLimit: true,
          jwksRequestsPerMinute: 5,
          jwksUri
      })
      graphiql: true,
      ...
}));

I see that it will probably be relatively simple to refine code at https://github.com/postgraphql/postgraphql/blob/5979eafcb2fe4c675870b265aeca8ff68d7d053e/src/postgraphql/withPostGraphQLContext.ts#L125-L130 but would it require more changes for PgJWTPlugin as well for everything to work?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions