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

[WIP] feat: add access token UI #2210

Closed
wants to merge 1 commit into from
Closed

Conversation

hacksparrow
Copy link
Contributor

Add UI for specifying the access token in API Explorer. Also makes additional UI improvements.

Old
image

New
image

Add UI for specifying the access token in API Explorer
@hacksparrow hacksparrow self-assigned this Jan 3, 2019
@bajtos
Copy link
Member

bajtos commented Jan 4, 2019

I am confused. How do you envision to use the access token set in the UI? In your pull request, I don't see how the value is passed to the underlying swagger-ui or swagger-js implementation.

Also note that by default, LoopBack 4 applications don't have authentication enabled, they don't accept any access tokens!

@bajtos
Copy link
Member

bajtos commented Jan 4, 2019

IMO, we need to implement first few parts of Authentication epic #1035, most notably #1997, before it makes sense to work on API Explorer enablement.

@hacksparrow
Copy link
Contributor Author

I don't see how the value is passed to the underlying swagger-ui or swagger-js implementation.

Work in progress.

After discussing with you on Slack, looks like this is indeed early.

@sbacem
Copy link

sbacem commented Jan 4, 2019

I think is better to use like this in SwaggerUI

capture

and

capture2

@bajtos
Copy link
Member

bajtos commented Jan 4, 2019

I think is better to use like this in SwaggerUI

+1 to use swagger-ui's built-in controls and don't reinvent the wheel.

@hacksparrow
Copy link
Contributor Author

@sbacem is that an in-built feature in SwaggerUI? How do you bring it up?

@sbacem
Copy link

sbacem commented Jan 7, 2019

@hacksparrow you can see this https://editor.swagger.io

In first step is to define your security strategy

securityDefinitions:
  petstore_auth:
    type: "oauth2"
    authorizationUrl: "http://petstore.swagger.io/oauth/dialog"
    flow: "implicit"
    scopes:
      write:pets: "modify pets in your account"
      read:pets: "read your pets"
  api_key:
    type: "apiKey"
    name: "api_key"
    in: "header"

After this you can use this definition in path like this

      security:
      - petstore_auth:
        - "write:pets"
        - "read:pets"

@bajtos
Copy link
Member

bajtos commented Jan 7, 2019

Thank you @sbacem for an example of how to configure auth/auth in OpenAPI. The full spec can be found here: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#securitySchemeObject

Here are the valid auth types: "apiKey", "http", "oauth2", "openIdConnect". We have been using "apiKey" type in LoopBack 3.x, I think that's the direction we are investigating for LB4 too.

cc @jannyHou

@hacksparrow
Copy link
Contributor Author

Thanks @sbacem!

@raymondfeng
Copy link
Contributor

As we improve the authentication/authorization support, security related metadata should be generated into the OpenAPI spec.

@hacksparrow
Copy link
Contributor Author

Closing this as we won't need to work on additional UI.

@shendkardevesh
Copy link

hi , confuse how to get ui changed for accepting authentication key

@dougal83
Copy link
Contributor

@shendkardevesh The UI is not ready yet, for implementation progress see issue: #2027

You can use a tool like Postman to query the API with an access token in the meantime.

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

Successfully merging this pull request may close these issues.

6 participants