Giter Club home page Giter Club logo

nodejs-sdk's People

Contributors

alexfrontegg avatar amirjaron avatar arturwolny-frontegg avatar aviadmizrachi avatar davidantoon avatar dependabot[bot] avatar doratias18 avatar eldad-frontegg avatar eran-frontegg avatar ihigani avatar madvinking avatar noa-frontegg avatar omers-frontegg avatar raz-shlomo-frontegg avatar royi-frontegg avatar sdemjanenko avatar semantic-release-bot avatar shaym-cyera avatar snyk-bot avatar tomerfrontegg avatar yossi-frontegg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

nodejs-sdk's Issues

4.2.0 release changed `IdentityClient.getInstance().validateIdentityOnToken` call return signature

https://github.com/frontegg/nodejs-sdk/releases/tag/4.2.0 changed the values returned from IdentityClient.getInstance().validateIdentityOnToken. Now roles and permissions are not returned anymore, which should be considered a breaking change.

This should've been a major version bump instead of a minor version according to semver. Teams who use dependency bots with automerge features would end up with a broken deployment.

fronteggNextJs middleware seems to be broken

Hi, I found an issue when trying to setup Frontegg middleware with Next.js as described in the documentation. There seems to be a problem when checking whether given route is frontegg public route here, but only when isFronteggPublicRoute function is called from fronteggNextJs middleware. I also tried to setup express app with frontegg middleware and it works correctly.

Actual behaviour

  • following API requests sent from login screen fail with status code 401
    • /api/frontegg/metadata?entityName=saml
    • /api/frontegg/identity/resources/sso/v1
    • /api/frontegg/identity/resources/configurations/v1/public
  • user is not able to log in to the app using login form

Expected behaviour

  • requests to public API mentioned above succeed with status code 200
  • login flow works correctly

For now, we are using following workaround to make fronteggNextJs middleware work:

export default (req: NextApiRequest, res: NextApiResponse) => {

  // we had to remove `/api/frontegg` part
  // of `req.url` to make it work correctly
  req.url = req.url.replace('/api/frontegg', '')
  
  return fronteggNextJs({
    clientId: process.env.FRONTEGG_CLIENT_ID,
    apiKey: process.env.FRONTEGG_API_KEY,
    authMiddleware: withAuthentication(),
    contextResolver: async (req) => {
      return {
        tenantId: req.user ? req.user.tenantId : '',
        userId: req.user ? req.user.id : '',
        permissions: [FronteggPermissions.All],
      }
    },
  })(req, res)
}

authMiddleware can lead to express error during logout flow

Sometimes during logout flow, there is an express error ERR_HTTP_HEADERS_SENT.

The problem is frontegg middleware calls to auth middleware via this helper function
https://github.com/frontegg/nodejs-sdk/blob/master/src/middleware/utils.ts#L141
This function will throw an error if the value of the next callback (resolve of promise) is a string, this callback function (next) will be sent to auth middleware.
In case of error, the code (frontegg middleware) will send a response, you can see it here
https://github.com/frontegg/nodejs-sdk/blob/master/src/middleware/fronteggMiddleware.ts#L142
The problem is the auth middleware already (could) made a response and called to next callback, see this
https://github.com/frontegg/nodejs-sdk/blob/master/src/identity/with-authentication.ts#L45

The setup:

app.use('/frontegg', frontegg({
  clientId: 'my-client-id',
  apiKey: 'my-api-key',
  authMiddleware: withAuthentication(),
  contextResolver: (req) => {
    const email = req.context.user; // The user context (after JWT verification)
    const tenantId = req.context.tenantId; // The tenantId context (after JWT verification)
    const permissions = [FronteggPermissions.All];

    return {
      email,
      tenantId,
      permissions
    };
  }
}))

Thanks

Authenticator refresh token task runs indefinitely

When using the frontegg client, the authenticator start a task with setTimeout which runs indefinitely (the authenticator has no shutdown function). Leaving a task open when an app shuts down is bad practice and can also fail tests.
This also affects the getPublicKey function in the IdentityClient class, that in turn creates an authenticator, again starting a task that runs indefinitely (And actually the access token is needed only once).

Suggested fix:
Add a shutdown function to the authenticator, removing the refresh token timeout + in identity client, shutdown the authenticator after the key is retrieved.

Suggested PR:
#36

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.