Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Usage without express #49

Closed
SebTVisage opened this issue Jan 21, 2022 · 3 comments
Closed

Usage without express #49

SebTVisage opened this issue Jan 21, 2022 · 3 comments
Labels
enhancement New feature or request

Comments

@SebTVisage
Copy link

Please do not report security vulnerabilities here. The Responsible Disclosure Program details the procedure for disclosing security issues.

Thank you in advance for helping us to improve this library! Your attention to detail here is greatly appreciated and will help us respond as quickly as possible. For general support or usage questions, use the Auth0 Community or Auth0 Support. Finally, to avoid duplicates, please search existing Issues before submitting one here.

By submitting an Issue to this repository, you agree to the terms within the Auth0 Code of Conduct.

Describe the problem you'd like to have solved

I'm trying to implement your Getting started guide on nodejs with a Koa server, not express. I would like this to work without having to manually code everything.

Describe the ideal solution

Would it be possible to simply export some lower level functions that can be used by any HTTP js framework. I think all I would need is the published module to export getToken and verify in addition to the actual express middleware. Then I'd ba able to use it with any HTTP framework

Alternatives and current work-arounds

The only work around I see now is re-implementing most of what is done in this repo manually. Or copy/paste or fork.

@SebT
Copy link

SebT commented Jan 21, 2022

Actually I managed to make it work with an ugly but simple workaround thanks to koa-connect:

import k2c from 'koa-connect';
import { auth } from 'express-oauth2-jwt-bearer'

 app.use(
    k2c((req, res, next) => {
      // @ts-expect-error ugly hack to prevent runtime error. 
      // Should be fine as long as we only use JSON request types
      req.is = () => false
      // @ts-expect-error wrong `req` type
      return checkJwtExpressMiddleware(req, res, next)
    })
  )

@adamjmcgrath adamjmcgrath added the enhancement New feature or request label Jan 26, 2022
@adamjmcgrath
Copy link
Contributor

Hi @SebTVisage - thanks for raising this

We'd like to support more frameworks in the future - we're still gathering feedback so your request for koa is useful, thanks

fyi @kevlil83

@rpf3
Copy link

rpf3 commented Mar 30, 2022

I was also trying to implement this using SvelteKit so exposing some of the underlying automation around the jwks verifier would be awesome. There is a workaround by using the node-adapter and building my own express server but it's a bit hacky.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants