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

OAuth2 authentication redirect page isn't served #51

Open
sunpeinju opened this issue Nov 29, 2018 · 4 comments
Open

OAuth2 authentication redirect page isn't served #51

sunpeinju opened this issue Nov 29, 2018 · 4 comments

Comments

@sunpeinju
Copy link

When doing OAuth2 authentication from swagger-ui, the OAuth server will do user authorization and return the result to swagger (Koa) server's /oauth2-redirect.html endpoint. koa2-swagger-ui doesn't handle this endpoint, so authorization fails.

  • 'oauth2-redirect.html' page is part of 'swagger-ui-dist', it's not available through cdn https://cdnjs.cloudflare.com/ajax/libs/swagger-ui/3.20.0/.
  • Why does this lib choose to serve swagger-ui resources through cdn? Could it directly uses resources from swagger-ui-dist?
@sunpeinju
Copy link
Author

BTW, currently I'm using koa-send in my app to serve the missing page:

  • 'my_redirect_uri' is my server's oauth callback endpoint.
  • the endpoint is passed to swagger-ui through oauth2RedirectUrl option.
  • add route for 'my_redirect_uri' and send the '/oauth2-redirect.html' page to browser.
app.use(koaSwagger({
  oauthOptions: {...},
  swaggerOptions: {
    oauth2RedirectUrl: my_redirect_uri,
  }
}));

const router = new Router();
router.get(my_redirect_uri, async (ctx) => {
  await send(ctx, '/oauth2-redirect.html', { root: swagger.getAbsoluteFSPath() });
});
app.use(router.routes());

@scttcper
Copy link
Owner

scttcper commented Dec 3, 2018

its using the cdn because, for our use case, the server was a raspberry pi and it was really slow at serving large blobs because it couldn't compress them quickly and the network isn't great. probably open to a pr

@sunpeinju
Copy link
Author

it could be fine if 'oauth2-redirect.html' is also available through cdn. Don't know how to do that.

@aorlowskiddm
Copy link

This needs to be handled. The issue does not exist in e.g. Swagger editor.

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

No branches or pull requests

3 participants