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

Add bearer auth scheme as the default security scheme #4386

Closed
1 task
jannyHou opened this issue Jan 8, 2020 · 14 comments
Closed
1 task

Add bearer auth scheme as the default security scheme #4386

jannyHou opened this issue Jan 8, 2020 · 14 comments

Comments

@jannyHou
Copy link
Contributor

jannyHou commented Jan 8, 2020

Suggestion

After story #4380 finished, we can add a security spec enhancer to have the bearer auth scheme as the default(or built-in) security scheme. So that explorer has the authorization dialog for people to inject the token per request.

Use Cases

Add an OAI enhancer that add the following spec into OpenAPI spec generated in the rest server:

"components": {
    "securitySchemes": {
      "jwt": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "JWT"
      }
    },

Examples

See the screenshot in https://loopback.io/doc/en/lb4/Authentication-Tutorial.html#specifying-the-security-settings-in-the-openapi-specification

Acceptance criteria

  • add a security spec enhancer to have the bearer auth scheme as the default(or built-in) security scheme
@dougal83

This comment has been minimized.

@jannyHou
Copy link
Contributor Author

jannyHou commented Jan 8, 2020

@dougal83 ah, true jwt is more accurate 👍

@emonddr
Copy link
Contributor

emonddr commented Jan 9, 2020

@dougal83 , @jannyHou ,

Regarding the comment

Good idea to add to develop the schema. Personally I'd be more specific and name it jwt rather than bearerAuth.

Exactly what are we talking about here?

The title of the github issue :
Add bearer auth scheme as the default security scheme ?

Or

image

in https://loopback.io/doc/en/lb4/Authentication-Tutorial.html#specifying-the-security-settings-in-the-openapi-specification ?

Because the OpenAPI spec examples above (not the screen cap) do not have
bearerAuth

Please clarify.

Thanks

:)

@dougal83
Copy link
Contributor

Hey @emonddr

This issue is to enhance the openApi spec by adding to components.

I've just jumped on it to suggest a name change from bearerAuth to jwt. I'm aware that bearerAuth is currently in use so if consensus for change is found then all instances would need to be updated. The bearerFormat property is just arbitrary and so using jwt as security scheme name would be better IMO.

Considering the top level security property of openapi spec, it would be easier to grasp the nature without looking up the schema:

  "security": [
    {
      "jwt": []
    }
  ],

Really me nitpicking atm.

@dhmlau
Copy link
Member

dhmlau commented Jan 15, 2020

@strongloop/loopback-next @strongloop/loopback-maintainers @mschnee

Call for contribution:
This task is part of the epic "Allow out-of-box token based authentication in API Explorer" , that we wish to get it done in 2020Q1. If you're interested in working on it, please leave a message here and we'll assign it to you. We'll take the first person who responds. 😬

Happy contributing!

@dougal83 dougal83 self-assigned this Jan 30, 2020
dougal83 added a commit to dougal83/loopback-next that referenced this issue Feb 3, 2020
add security enhancer to add default security scheme

impl. loopbackio#4386

Signed-off-by: Douglas McConnachie <[email protected]>
dougal83 added a commit to dougal83/loopback-next that referenced this issue Feb 3, 2020
add security enhancer to add default security scheme

impl. loopbackio#4386

Signed-off-by: Douglas McConnachie <[email protected]>
@dougal83
Copy link
Contributor

@jannyHou For clarification, is this story to add jwt strategy /w enhancer to base project generator template?

@dougal83 dougal83 removed their assignment Mar 2, 2020
@dougal83
Copy link
Contributor

dougal83 commented Mar 2, 2020

I have a busy March so unassigned in case someone else wishes to help in the meantime.

@dhmlau
Copy link
Member

dhmlau commented Mar 9, 2020

@jannyHou @raymondfeng, could you please clarify? Thanks.

@jannyHou
Copy link
Contributor Author

after having the jwt authentication component extracted in examples/access-control-migration, I am thinking refactor the strategy in this example to extend the enhancer and provide jwt auth spec by default.

I am not sure if @raymondfeng still wants to have the authorize button enabled for explorer for ANY loopback app w/ or w/o authentication enabled.

cc @raymondfeng WDYT?

@dhmlau
Copy link
Member

dhmlau commented Mar 12, 2020

@jannyHou, is it possible to show/hide the authorize button based on whether the app has authentication enabled?
btw, what's the behavior in LB3?

@dhmlau dhmlau added 2020Q2 and removed 2020Q1 labels Mar 12, 2020
@jannyHou
Copy link
Contributor Author

Screen Shot 2020-03-12 at 2 33 44 PM

I created a LB3 app, disabled the auth system in boot script

// server.enableAuth();

The token field still exists in explorer so I believe it's always provided out of box in LB3.

@dhmlau
Copy link
Member

dhmlau commented Mar 17, 2020

How about we always show the authorize button, as the first iteration? It's better to always show the button/field than always hide!

cc @raymondfeng

@jannyHou
Copy link
Contributor Author

created PR in #5493

@dhmlau
Copy link
Member

dhmlau commented May 27, 2020

Closing as done.

@dhmlau dhmlau closed this as completed May 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants