java - Spring - Http Basic Auth - Mark endpoint as public -
i using spring providing basic http authentication. setting user , password in application.properies:
however, expose endpoint/or static file public (no authentication required this). there simple way this?
i find spring documentation quite hard search tips appreciated.
you can use method configure endpoints on application:
protected void configure(httpsecurity http) throws exception { http.authorizerequests() .antmatchers("/", "/public/**").permitall() .antmatchers("/users/**").hasauthority("admin") .anyrequest().fullyauthenticated() .and() .formlogin() .loginpage("/login") .failureurl("/login?error") .usernameparameter("email") .permitall() .and() .logout() .logouturl("/logout") .deletecookies("remember-me") .logoutsuccessurl("/") .permitall() .and() .rememberme(); }
the complete example can found here: https://github.com/bkielczewski/example-spring-boot-security
Comments
Post a Comment