-
Notifications
You must be signed in to change notification settings - Fork 9.1k
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
Using Authorization annotation in JAVA #1479
Comments
Hi, I have the same problem. I want to have an API first design and I want to get the security definition (path and roles) from the swagger specification so I can use it in my spring security configuration. If I can do this, it means that the secured services and the roles that can access them should be defined in swagger and not in the application. Thanks, |
Hi, I decided to write a class that get the beans that implement and interface annotated with
After that I process the interface annotations to get the authorization scope if present. For each method in the interface is possible to get the authorization scopes and included them in a list:
So for each method in the interface is possible to obtain the authorization scopes and also the request mapping and the request method (both present in the Finally, I put all that information (http method, request mapping and scopes) in a spring bean and then I configure spring security using mvc matchers. Doing this you can configure your application's authorization in the OpenApi specification and nowhere else. Thanks, |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Solution given in 2018, closing. |
Hi,
We've defined a yaml file with Swagger version 2.0 with the following security definitions:
After compiling it using Swagger JAVA compiler version 2.2.3 we see the security labels as annotations in all the operation, but we can't access the values entered for them in the request header.
@io.swagger.annotations.Authorization(value = "PasswordSecurity"),
@io.swagger.annotations.Authorization(value = "TenantSecurity"),
@io.swagger.annotations.Authorization(value = "UserNameSecurity")
Do you know how can the apiKey values, supplied in the header, can be accessed in the generated code?
Thanks,
Kfir
The text was updated successfully, but these errors were encountered: