-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
For Token Authorization to work need to specify authorizations = { @Authorization(value="Authorization") } #2661
Comments
Same issue with me , am using RepositoryRestResource so couldnt include for all methods |
Sorry , it is working @ngawor u can use the below config,
|
This worked - thank you @selvaebi ! I think the documentation needs to be updated to reflect this is necessary. |
@ngawor can you send me your swagger configuration?? the same bug in my swagger but my conf does not work |
Hi @MartinTopchyan the above config will work perfectly , can you paste ur config , let we check we can help. |
ApiInfo apiInfo() {
return new ApiInfoBuilder()
.title("")
.description("")
.termsOfServiceUrl("")
.version(this.projectVersion)
.contact(new Contact("", "", ""))
.build();
}
@Bean
public Docket api() {
return new Docket(DocumentationType.SWAGGER_2)
.select()
.apis(RequestHandlerSelectors.basePackage(""))
.paths(PathSelectors.any())
.build()
.enable(true)
.apiInfo(apiInfo())
.securitySchemes(Arrays.asList(apiKey()))
.securityContexts(Arrays.asList(securityContext));
}
private ApiKey apiKey() {
return new ApiKey("apiKey", "Authorization", "header");
}
SecurityReference securityReference = SecurityReference.builder()
.reference("Authorization")
.scopes(new AuthorizationScope[0])
.build();
SecurityContext securityContext = SecurityContext.builder()
.securityReferences(Arrays.asList(securityReference))
.build(); This is my swagger config |
ahh the reference name should match , change to SecurityReference.builder() |
@selvaebi am I understand you right?? |
@selvaebi Thank you so much it works perfect |
Thanks everyone for jumping in to answer questions! I'll add a note to document it. Would anyone of you have the bandwidth to help with a PR to help with documenting it? |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
This issue has been automatically closed because it has not had recent activity. Please re-open a new issue if this is still an issue. |
Using swagger2-2.9.2 and swagger-ui-2.9.2:
Previous token authentication stopped working from 2.5 (the token is no longer being passed). In order to resolve this, I had to add:
authorizations = { @authorization(value="Authorization") }
to every method I wanted to pass the token. This wasn't necessary in previous versions, and my code did not change.
I see some discussion of this here:
#2194
but it is marked closed.
The text was updated successfully, but these errors were encountered: