Numero 21
Numero 21

Reputation: 265

How to expose Swagger UI without authentication?

I'm trying to make the SwaggerUi interface not ask for authorization every time I boot.

I tried to enter in my Configure class:

.authorizeRequests().antMatchers("/actuator/**","/mypath/**").permitAll()

and

 .authorizeRequests().antMatchers("/mypath/**").permitAll()

but without success.

Actuator on the other hand works fine without authorization with this code structure

Thanks everyone for a possible answer!

Upvotes: 3

Views: 2909

Answers (2)

Jacket
Jacket

Reputation: 393

The basic problem is that even in the Sprinc-doc documentation they put you the case that you entered too. In order to make the code work you have to enter multiple permissions, one for each path. In your case it will have to be something like this:

.authorizeRequests().antMatchers("/actuator/**","/v2/**","/mypath/**","/swagger.yml","/anypath/").permitAll()

Upvotes: 1

Renis1235
Renis1235

Reputation: 4700

Try this:

 .authorizeRequests().antMatchers("/swagger-ui/**").permitAll()

Then just go here:

http://localhost:[YOUR PORT]/swagger-ui/

p.s Don't forget the / at the end of the URL :)

Upvotes: 1

Related Questions