I configured my swagger to use HTTP Simple authentication to authenticate each endpoint call.
The configuration I used is like this:
private Docket docket () {
return new Docket(SWAGGER_2)
....
.build()
.securitySchemes(securitySchemes())
.securityContexts(securityContexts())
....
}
private List<SecurityScheme> securitySchemes() {
return ImmutableList.of(new BasicAuth("Authorization"));
}
private List<SecurityContext> securityContexts() {
SecurityContext securityContext = SecurityContext.builder()
.securityReferences(defaultAuth())
.operationSelector(operationContext -> true)
.build();
return ImmutableList.of(securityContext);
}
private List<SecurityReference> defaultAuth() {
AuthorizationScope authorizationScope = new AuthorizationScope("basicAuth", "HTTP Basic Authentication");
AuthorizationScope[] authorizationScopes = new AuthorizationScope[]{authorizationScope};
SecurityReference securityReference = new SecurityReference("Authorization", authorizationScopes);
return ImmutableList.of(securityReference);
}
The Swagger UI allows me to put username and password to authenticate each API call.
However, after I login, make a successful request and logout, the Swagger can still makes calls using my credential. This is because a Cookie still exist in the browser which can be used to authenticate against the endpoint.
How can I configure Swagger to remove the cookie upon logout?