SwaggerLume icon indicating copy to clipboard operation
SwaggerLume copied to clipboard

Bearer Authorization setup

Open karthikavkannan24 opened this issue 5 years ago • 5 comments

Hi,

I'm using DarkaOnLine/SwaggerLume in my Lumen project. Everything works fine except the Authorization. I'm using JWT authentication and I want to pass a Bearer .

I've added following codes:

  • @OAS\SecurityScheme(
  •  securityScheme="bearerAuth",
    
  •  type="apiKey",
    
  •  in="header",
    
  •  name="Authorization",
    
  • ) **/

and /** * @OA\Get( * tags={"User Managment"}, * path="/getusers", * description="", * summary="Get users list", * operationId="getUsers", * @OA\Response( * response=200, * description="Users Listed", * ), * security : { bearerAuth: []} * ) */

But still I'm getting token not provided issue.

Please feedback.

Thanks


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

karthikavkannan24 avatar Apr 18 '19 08:04 karthikavkannan24

@karthikavkannan24 Please try this.

// Somewhere in your middleware or any other place

/**
 * @OA\SecurityScheme(
 *     type="http",
 *     description="Login with email and password to get the authentication token",
 *     name="Token based Based",
 *     in="header",
 *     scheme="bearer",
 *     bearerFormat="JWT",
 *     securityScheme="apiAuth",
 * )
 */
/**
 * @OA\Get(
 *  path="/resources",
 *  summary="Get the list of resources",
 *  tags={"Resource"},
 *  @OA\Response(response=200, description="Return a list of resources"),
 *  security={{ "apiAuth": {} }}
 * )
 */

This repository is just a nice wrapper to the swagger-php and lumen, so, it is not a good place to find solution for how to do this in swagger-php. swagger-php would be a place to go for these issues.

Hope this helps 🍻

sudkumar avatar May 05 '19 04:05 sudkumar

@sudkumar , Thanks for the reply. It works

karthikavkannan24 avatar Jul 03 '19 09:07 karthikavkannan24

I am using lume api 8, darkaonline/swagger-lume:8.* and openapi 3.0.0, i am try

/**
 * @OA\SecurityScheme(
 *     securityScheme="bearerAuth",
 *     type="apiKey",
 *     name="Authorization",
 *     in="header",
 * )
 */

and /** * @OA\POST( * path="/v1/api/me", * summary="Get info current user login", * security={{ "bearerAuth": {} }}, ..... but still not working, any body can help me and help me check reson? Thanks so much

ducpm0301 avatar Jun 20 '21 03:06 ducpm0301

I am using lume api 8, darkaonline/swagger-lume:8.* and openapi 3.0.0, i am try

/**
 * @OA\SecurityScheme(
 *     securityScheme="bearerAuth",
 *     type="apiKey",
 *     name="Authorization",
 *     in="header",
 * )
 */

and /**

  • @OA\POST(
  • path="/v1/api/me",
  • summary="Get info current user login",
  • security={{ "bearerAuth": {} }}, ..... but still not working, any body can help me and help me check reson? Thanks so much

Which one is not working? Only authorisation?

karthikavkannan24 avatar Jun 21 '21 05:06 karthikavkannan24

https://swagger.io/docs/specification/authentication/bearer-authentication/ https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#jwt-bearer-sample

"components": {
		"securitySchemes": {
			"bearerAuth": {
				"type": "http",
				"description": "Passport security.",
				"scheme": "bearer",
				"bearerFormat": "JWT"
			}
		}
}

mtracz avatar Jul 21 '21 13:07 mtracz