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

Load Balancing in Bluemix using custom domain and DNS SRV records -

oracle - pls-00402 alias required in select list of cursor to avoid duplicate column names -

python - Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>] error -