In AngularJS web app, How to show a custom error message / page for 403 http response.
I use Spring security and check if a user has a appropriate roles..and if he does not have the role the application returns http error code 403.
At the moment I am not showing any error message / page in such case. And would like to implement this. How can we do this ?
Spring boot java code
http.httpBasic()
.and()
.authorizeRequests()
// Permit these resources
.antMatchers("/login", "/4_security/login.html", "/bower_components/**", "/4_security/*.js", "/")
.permitAll()
// URL based Authorization control
.antMatchers("/1_reportingEntities/*.html").hasAnyAuthority(authorities)
// All other requests needs authentication
.anyRequest().authenticated()
// Access denied page (403 error)
.and().exceptionHandling().accessDeniedPage("/0_common/accessDenied.html")
.and()
// CSRF protection
.csrf().csrfTokenRepository(csrfTokenRepository()).and().addFilterAfter(csrfHeaderFilter(), CsrfFilter.class);