Skip to content

securitySchemes/bearerAuth usage unclear.  #177

@utx0

Description

@utx0

Hey guys,

I have been using this package for some time on a number of public API with great joy. However, I now have a need to set up JWT Bearer token auth on a number of API endpoints and I am finding that the usage patterns for this arent clear from reading the documentation or the code. I would really love some guidance on how this is meant to be implemented.

As a starting point I have defined the following test api endpoint in my openapi.json spec as follows;

components:
  responses:
    UnauthorizedError:
      description: Acces token is missing or invalid
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
paths:
  "/v1/jwt":
    get:
      security:
        - bearerAuth: []
      operationId: GetJWT
      summary: Get JWT info
      description: JWT Test interface
      responses:
        "200":
          description: Return info on the JWT
        "401":
          $ref: '#/components/responses/UnauthorizedError'

In turn, this generated the following in the codegen (Which for the life of me I can't see how this really archives anything useful?):

// GetJWT converts echo context to params.
func (w *ServerInterfaceWrapper) GetJWT(ctx echo.Context) error {
	var err error

	ctx.Set("bearerAuth.Scopes", []string{""})

	// Invoke the callback with all the unmarshalled arguments
	err = w.Handler.GetJWT(ctx)
	return err
}

Be great to know what is now required to turn a simple handler (as follows) into one that requires AUTH?

func (h *Handlers) GetDocs(ctx echo.Context) error {
	return ctx.File("public/rest/v1/api.html")
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions