question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

403 error on accessing swagger ui - spring boot 2.0 springfox-swagger2 (2.7.0,2.6.0,2.6.1)

See original GitHub issue

Please find below the pom dependency

<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.6.1</version>
			<exclusions>
				<exclusion>
					<groupId>com.fasterxml.jackson.core</groupId>
					<artifactId>jackson-annotations</artifactId>
				</exclusion>
			</exclusions>
		</dependency>
		<dependency>
			<groupId>io.springfox</groupId>
			<artifactId>springfox-swagger-ui</artifactId>
			<version>2.6.1</version>
		</dependency>

tried version 2.7.0, 2.6.1

security has been bypassed for swagger http.authorizeRequests().antMatchers(“/v2/api-docs”, “/configuration/ui”, “/swagger-resources”, “/configuration/security”, “/swagger-ui.html”, “/webjars/**”).permitAll();

it was working fine with spring boot 1.3 after upgrading to 2.0 facing 403 error

What kind of issue is this?

  • There was an unexpected error accessing swagger-ui(type=Forbidden, status=403). Access Denied

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

12reactions
dilipkrishcommented, Mar 27, 2018

That does not match what is prescribed in the documentation. Based on that it should have the following values.

    http.authorizeRequests()
        .antMatchers(
            "/v2/api-docs", 
            "/swagger-resources/**",  
            "/swagger-ui.html", 
            "/webjars/**" ,
             /*Probably not needed*/ "/swagger.json")
        .permitAll();
3reactions
orwtechcommented, Jan 14, 2019

Can only get this to work if I add @EnableSwagger2 just below @SpringBootApplication Then it works out of the box

But putting @EnableSwagger2 in a config class below @Configuration gives this error Not sure why this is?

Read more comments on GitHub >

github_iconTop Results From Across the Web

spring boot - Swagger UI empty and gives 403 - Stack Overflow
The error message you get from the network tab indicates that the browser is able to load the swagger-ui.html file but is unable...
Read more >
Developers - 403 error on accessing swagger ui - Bountysource
403 error on accessing swagger ui - spring boot 2.0 springfox-swagger2 (2.7.0,2.6.0,2.6.1)
Read more >
Swagger UI getting 403 error even after adding resources in ...
Coding example for the question Swagger UI getting 403 error even after adding resources in the ignored list & overriding resourceHandlers-Springboot.
Read more >
[SOLVED] 403 Forbidden for OpenApiSwagger in Spring Boot ...
I have Spring Boot application with Spring Security. After configure configuration-class localhost-Swagger return 403 Forbidden.
Read more >
SpringBoot+Swagger Error: 403 Forbidden [How to Solve]
Springboot + swagger2 reports error 403 Forbidden. Error reporting reason. When creating a springboot project, if spring security ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found