Swagger UI Springfox Basic Authentication

I am trying to add custom headers only using the Java configuration in the Swagger UI (without changing the html file). I am using springfox and do not want to have a separate html file to access swagger ui.

Swagger UI Responses

@Bean SecurityConfiguration security() { return new SecurityConfiguration( "test-app-client-id", "test-app-client-secret", "test-app-realm", "test-app", "Basic dXNlcm5hbWU6cGFzc3dvcmQ=", ApiKeyVehicle.Header, "Authorization", ","); } 

Using this code, I tried to change

 --header "api_key: apiKey" 

in

 --header "Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=" 

or

 --user username:password 

but I could not do it.

 --header "Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=" 

could be changed to

 --header "Authorization: Basic%20dXNlcm5hbWU6cGFzc3dvcmQ%3D" 

and I'm not sure how to fix it. It would be perfect to get

 --user username:password 

but ApiKeyVehicle only has -header, and I don't know if there is a way to change this.

Can someone give me a hand?

Sorry, everything is so messy

+5
source share

All Articles