java - Configure security schemas and contexts in Springfox and Spring MVC -


i have simple rest services implemented spring mvc. decided describe them springfox , swagger 2.0. seemed ok until started adding security schemas , contexts. use http basic authentication endpoints , token-based authentication others. whatever do, cannot see option set http basic authentication credentials or specify token in swagger ui. below configuration. simplicity's sake apply both schemas endpoints here.

@configuration @enableswagger2 public class swaggerconfig {      @bean     public docket apiv1() {         return new docket(documentationtype.swagger_2)             .select()             .apis(requesthandlerselectors.any())             .paths(pathselectors.any())             .build()         .pathmapping("/api/v1")         .securityschemes(newarraylist(new basicauth("xbasic"), new apikey("x-auth-token", "xauthtoken", "header")))         .securitycontexts(newarraylist(xbasicsecuritycontext(), xauthtokensecuritycontext()))     }      private securitycontext xbasicsecuritycontext() {         securitycontext.builder()             .securityreferences(newarraylist(new securityreference("xbasic", new authorizationscope[0])))             .build()     }      private securitycontext xauthtokensecuritycontext() {         securitycontext.builder()             .securityreferences(newarraylist(new securityreference("xauthtoken", new authorizationscope[0])))             .build()     } 


Comments

Popular posts from this blog

javascript - How to get current YouTube IDs via iMacros? -

c# - Maintaining a program folder in program files out of date? -

emulation - Android map show my location didn't work -