JAVA-67:renamed spring-security-mvc-boot-2 to spring-security-web-boot-2
This commit is contained in:
+13
@@ -0,0 +1,13 @@
|
||||
package com.baeldung.customlogouthandler;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class CustomLogoutApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(CustomLogoutApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
package com.baeldung.customlogouthandler;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
|
||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
|
||||
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
|
||||
import org.springframework.security.web.authentication.logout.HttpStatusReturningLogoutSuccessHandler;
|
||||
|
||||
import com.baeldung.customlogouthandler.web.CustomLogoutHandler;
|
||||
|
||||
@Configuration
|
||||
@EnableWebSecurity
|
||||
public class MvcConfiguration extends WebSecurityConfigurerAdapter {
|
||||
|
||||
@Autowired
|
||||
private DataSource dataSource;
|
||||
|
||||
@Autowired
|
||||
private CustomLogoutHandler logoutHandler;
|
||||
|
||||
@Override
|
||||
protected void configure(HttpSecurity http) throws Exception {
|
||||
http.httpBasic()
|
||||
.and()
|
||||
.authorizeRequests()
|
||||
.antMatchers(HttpMethod.GET, "/user/**")
|
||||
.hasRole("USER")
|
||||
.and()
|
||||
.logout()
|
||||
.logoutUrl("/user/logout")
|
||||
.addLogoutHandler(logoutHandler)
|
||||
.logoutSuccessHandler(new HttpStatusReturningLogoutSuccessHandler(HttpStatus.OK))
|
||||
.permitAll()
|
||||
.and()
|
||||
.csrf()
|
||||
.disable()
|
||||
.formLogin()
|
||||
.disable();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
|
||||
auth.jdbcAuthentication()
|
||||
.dataSource(dataSource)
|
||||
.usersByUsernameQuery("select login, password, true from users where login=?")
|
||||
.authoritiesByUsernameQuery("select login, role from users where login=?");
|
||||
}
|
||||
|
||||
}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
package com.baeldung.customlogouthandler.services;
|
||||
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.PersistenceContext;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.baeldung.customlogouthandler.user.User;
|
||||
|
||||
@Service
|
||||
public class UserCache {
|
||||
|
||||
@PersistenceContext
|
||||
private EntityManager entityManager;
|
||||
|
||||
private final ConcurrentMap<String, User> store = new ConcurrentHashMap<>(256);
|
||||
|
||||
public User getByUserName(String userName) {
|
||||
return store.computeIfAbsent(userName, k -> entityManager.createQuery("from User where login=:login", User.class)
|
||||
.setParameter("login", k)
|
||||
.getSingleResult());
|
||||
}
|
||||
|
||||
public void evictUser(String userName) {
|
||||
store.remove(userName);
|
||||
}
|
||||
|
||||
public int size() {
|
||||
return store.size();
|
||||
}
|
||||
|
||||
}
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
package com.baeldung.customlogouthandler.user;
|
||||
|
||||
import javax.persistence.*;
|
||||
|
||||
@Entity
|
||||
@Table(name = "users")
|
||||
public class User {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Integer id;
|
||||
|
||||
@Column(unique = true)
|
||||
private String login;
|
||||
|
||||
private String password;
|
||||
|
||||
private String role;
|
||||
|
||||
private String language;
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getLogin() {
|
||||
return login;
|
||||
}
|
||||
|
||||
public void setLogin(String login) {
|
||||
this.login = login;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public String getRole() {
|
||||
return role;
|
||||
}
|
||||
|
||||
public void setRole(String role) {
|
||||
this.role = role;
|
||||
}
|
||||
|
||||
public String getLanguage() {
|
||||
return language;
|
||||
}
|
||||
|
||||
public void setLanguage(String language) {
|
||||
this.language = language;
|
||||
}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
package com.baeldung.customlogouthandler.user;
|
||||
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
|
||||
public class UserUtils {
|
||||
|
||||
public static String getAuthenticatedUserName() {
|
||||
Authentication auth = SecurityContextHolder.getContext()
|
||||
.getAuthentication();
|
||||
return auth != null ? ((org.springframework.security.core.userdetails.User) auth.getPrincipal()).getUsername() : null;
|
||||
}
|
||||
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
package com.baeldung.customlogouthandler.web;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.security.web.authentication.logout.LogoutHandler;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.baeldung.customlogouthandler.services.UserCache;
|
||||
import com.baeldung.customlogouthandler.user.UserUtils;
|
||||
|
||||
@Service
|
||||
public class CustomLogoutHandler implements LogoutHandler {
|
||||
|
||||
private final UserCache userCache;
|
||||
|
||||
public CustomLogoutHandler(UserCache userCache) {
|
||||
this.userCache = userCache;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void logout(HttpServletRequest request, HttpServletResponse response, Authentication authentication) {
|
||||
String userName = UserUtils.getAuthenticatedUserName();
|
||||
userCache.evictUser(userName);
|
||||
}
|
||||
|
||||
}
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
package com.baeldung.customlogouthandler.web;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import com.baeldung.customlogouthandler.services.UserCache;
|
||||
import com.baeldung.customlogouthandler.user.User;
|
||||
import com.baeldung.customlogouthandler.user.UserUtils;
|
||||
|
||||
@Controller
|
||||
@RequestMapping(path = "/user")
|
||||
public class UserController {
|
||||
|
||||
private final UserCache userCache;
|
||||
|
||||
public UserController(UserCache userCache) {
|
||||
this.userCache = userCache;
|
||||
}
|
||||
|
||||
@GetMapping(path = "/language")
|
||||
@ResponseBody
|
||||
public String getLanguage() {
|
||||
String userName = UserUtils.getAuthenticatedUserName();
|
||||
User user = userCache.getByUserName(userName);
|
||||
return user.getLanguage();
|
||||
}
|
||||
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
package com.baeldung.jdbcauthentication.h2;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.annotation.PropertySource;
|
||||
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
|
||||
|
||||
@SpringBootApplication
|
||||
@EnableWebSecurity
|
||||
@PropertySource("classpath:application-defaults.properties")
|
||||
public class H2JdbcAuthenticationApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(H2JdbcAuthenticationApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
package com.baeldung.jdbcauthentication.h2.config;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
|
||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
|
||||
import org.springframework.security.core.userdetails.User;
|
||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
|
||||
@Configuration
|
||||
public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
|
||||
@Override
|
||||
protected void configure(HttpSecurity httpSecurity) throws Exception {
|
||||
httpSecurity.authorizeRequests()
|
||||
.antMatchers("/h2-console/**")
|
||||
.permitAll()
|
||||
.anyRequest()
|
||||
.authenticated()
|
||||
.and()
|
||||
.formLogin()
|
||||
.permitAll();
|
||||
httpSecurity.csrf()
|
||||
.ignoringAntMatchers("/h2-console/**");
|
||||
httpSecurity.headers()
|
||||
.frameOptions()
|
||||
.sameOrigin();
|
||||
}
|
||||
|
||||
@Autowired
|
||||
private DataSource dataSource;
|
||||
|
||||
@Autowired
|
||||
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
|
||||
auth.jdbcAuthentication()
|
||||
.dataSource(dataSource)
|
||||
.withDefaultSchema()
|
||||
.withUser(User.withUsername("user")
|
||||
.password(passwordEncoder().encode("pass"))
|
||||
.roles("USER"));
|
||||
}
|
||||
|
||||
@Bean
|
||||
public PasswordEncoder passwordEncoder() {
|
||||
return new BCryptPasswordEncoder();
|
||||
}
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
package com.baeldung.jdbcauthentication.h2.web;
|
||||
|
||||
import java.security.Principal;
|
||||
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/principal")
|
||||
public class UserController {
|
||||
|
||||
@GetMapping
|
||||
public Principal retrievePrincipal(Principal principal) {
|
||||
return principal;
|
||||
}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
package com.baeldung.jdbcauthentication.mysql;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.annotation.PropertySource;
|
||||
|
||||
@SpringBootApplication
|
||||
@PropertySource("classpath:application-mysql.properties")
|
||||
public class MySqlJdbcAuthenticationApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(MySqlJdbcAuthenticationApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
package com.baeldung.jdbcauthentication.mysql.config;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
|
||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
|
||||
@Configuration
|
||||
public class SecurityConfiguration {
|
||||
|
||||
@Autowired
|
||||
private DataSource dataSource;
|
||||
|
||||
@Autowired
|
||||
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
|
||||
auth.jdbcAuthentication()
|
||||
.dataSource(dataSource)
|
||||
.usersByUsernameQuery("select email,password,enabled "
|
||||
+ "from bael_users "
|
||||
+ "where email = ?")
|
||||
.authoritiesByUsernameQuery("select email,authority "
|
||||
+ "from authorities "
|
||||
+ "where email = ?");
|
||||
}
|
||||
|
||||
@Bean
|
||||
public PasswordEncoder passwordEncoder() {
|
||||
return new BCryptPasswordEncoder();
|
||||
}
|
||||
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
package com.baeldung.jdbcauthentication.mysql.web;
|
||||
|
||||
import java.security.Principal;
|
||||
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/principal")
|
||||
public class UserController {
|
||||
|
||||
@GetMapping
|
||||
public Principal retrievePrincipal(Principal principal) {
|
||||
return principal;
|
||||
}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
package com.baeldung.jdbcauthentication.postgre;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.annotation.PropertySource;
|
||||
|
||||
@SpringBootApplication
|
||||
@PropertySource("classpath:application-postgre.properties")
|
||||
public class PostgreJdbcAuthenticationApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(PostgreJdbcAuthenticationApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
package com.baeldung.jdbcauthentication.postgre.config;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
|
||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
|
||||
@Configuration
|
||||
public class SecurityConfiguration {
|
||||
|
||||
@Autowired
|
||||
private DataSource dataSource;
|
||||
|
||||
@Autowired
|
||||
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
|
||||
auth.jdbcAuthentication()
|
||||
.dataSource(dataSource);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public PasswordEncoder passwordEncoder() {
|
||||
return new BCryptPasswordEncoder();
|
||||
}
|
||||
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
package com.baeldung.jdbcauthentication.postgre.web;
|
||||
|
||||
import java.security.Principal;
|
||||
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/principal")
|
||||
public class UserController {
|
||||
|
||||
@GetMapping
|
||||
public Principal retrievePrincipal(Principal principal) {
|
||||
return principal;
|
||||
}
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
package com.baeldung.loginredirect;
|
||||
|
||||
import org.apache.http.HttpStatus;
|
||||
import org.springframework.security.authentication.AnonymousAuthenticationToken;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.web.filter.GenericFilterBean;
|
||||
|
||||
import javax.servlet.FilterChain;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.ServletRequest;
|
||||
import javax.servlet.ServletResponse;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
|
||||
class LoginPageFilter extends GenericFilterBean {
|
||||
|
||||
@Override
|
||||
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
|
||||
HttpServletRequest servletRequest = (HttpServletRequest) request;
|
||||
HttpServletResponse servletResponse = (HttpServletResponse) response;
|
||||
|
||||
if (isAuthenticated() && "/loginUser".equals(servletRequest.getRequestURI())) {
|
||||
|
||||
String encodedRedirectURL = ((HttpServletResponse) response).encodeRedirectURL(
|
||||
servletRequest.getContextPath() + "/userMainPage");
|
||||
|
||||
servletResponse.setStatus(HttpStatus.SC_TEMPORARY_REDIRECT);
|
||||
servletResponse.setHeader("Location", encodedRedirectURL);
|
||||
}
|
||||
|
||||
chain.doFilter(servletRequest, servletResponse);
|
||||
}
|
||||
|
||||
private boolean isAuthenticated() {
|
||||
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||
if (authentication == null || AnonymousAuthenticationToken.class.isAssignableFrom(authentication.getClass())) {
|
||||
return false;
|
||||
}
|
||||
return authentication.isAuthenticated();
|
||||
}
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
package com.baeldung.loginredirect;
|
||||
|
||||
import org.apache.http.HttpStatus;
|
||||
import org.springframework.security.authentication.AnonymousAuthenticationToken;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
|
||||
import org.springframework.web.util.UrlPathHelper;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
class LoginPageInterceptor extends HandlerInterceptorAdapter {
|
||||
|
||||
@Override
|
||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) {
|
||||
|
||||
UrlPathHelper urlPathHelper = new UrlPathHelper();
|
||||
if ("/loginUser".equals(urlPathHelper.getLookupPathForRequest(request)) && isAuthenticated()) {
|
||||
|
||||
String encodedRedirectURL = response.encodeRedirectURL(
|
||||
request.getContextPath() + "/userMainPage");
|
||||
response.setStatus(HttpStatus.SC_TEMPORARY_REDIRECT);
|
||||
response.setHeader("Location", encodedRedirectURL);
|
||||
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isAuthenticated() {
|
||||
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||
if (authentication == null || AnonymousAuthenticationToken.class.isAssignableFrom(authentication.getClass())) {
|
||||
return false;
|
||||
}
|
||||
return authentication.isAuthenticated();
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
package com.baeldung.loginredirect;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.annotation.ImportResource;
|
||||
|
||||
@SpringBootApplication
|
||||
@ImportResource({"classpath*:spring-security-login-redirect.xml"})
|
||||
class LoginRedirectApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(LoginRedirectApplication.class, args);
|
||||
}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
package com.baeldung.loginredirect;
|
||||
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
@Configuration
|
||||
class LoginRedirectMvcConfig implements WebMvcConfigurer {
|
||||
|
||||
@Override
|
||||
public void addInterceptors(InterceptorRegistry registry) {
|
||||
registry.addInterceptor(new LoginPageInterceptor());
|
||||
}
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
package com.baeldung.loginredirect;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
|
||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
|
||||
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
|
||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
|
||||
|
||||
@Configuration
|
||||
@EnableWebSecurity
|
||||
class LoginRedirectSecurityConfig extends WebSecurityConfigurerAdapter {
|
||||
|
||||
@Override
|
||||
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
|
||||
auth.inMemoryAuthentication().withUser("user").password(encoder().encode("user")).roles("USER");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configure(HttpSecurity http) throws Exception {
|
||||
|
||||
http
|
||||
.addFilterAfter(new LoginPageFilter(), UsernamePasswordAuthenticationFilter.class)
|
||||
|
||||
.authorizeRequests()
|
||||
.antMatchers("/loginUser").permitAll()
|
||||
.antMatchers("/user*").hasRole("USER")
|
||||
|
||||
.and().formLogin().loginPage("/loginUser").loginProcessingUrl("/user_login")
|
||||
.failureUrl("/loginUser?error=loginError").defaultSuccessUrl("/userMainPage").permitAll()
|
||||
|
||||
.and().logout().logoutUrl("/user_logout").logoutSuccessUrl("/loginUser").deleteCookies("JSESSIONID")
|
||||
.and().csrf().disable();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public static PasswordEncoder encoder() {
|
||||
return new BCryptPasswordEncoder();
|
||||
}
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
package com.baeldung.loginredirect;
|
||||
|
||||
import org.springframework.security.authentication.AnonymousAuthenticationToken;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
|
||||
@Controller
|
||||
class UsersController {
|
||||
|
||||
@GetMapping("/userMainPage")
|
||||
public String getUserPage() {
|
||||
return "userMainPage";
|
||||
}
|
||||
|
||||
@GetMapping("/loginUser")
|
||||
public String getUserLoginPage() {
|
||||
if (isAuthenticated()) {
|
||||
return "redirect:userMainPage";
|
||||
}
|
||||
return "loginUser";
|
||||
}
|
||||
|
||||
private boolean isAuthenticated() {
|
||||
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||
if (authentication == null || AnonymousAuthenticationToken.class.isAssignableFrom(authentication.getClass())) {
|
||||
return false;
|
||||
}
|
||||
return authentication.isAuthenticated();
|
||||
}
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
package com.baeldung.multipleauthproviders;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
import org.springframework.security.authentication.AuthenticationProvider;
|
||||
import org.springframework.security.authentication.BadCredentialsException;
|
||||
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.security.core.AuthenticationException;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class CustomAuthenticationProvider implements AuthenticationProvider {
|
||||
@Override
|
||||
public Authentication authenticate(Authentication auth) throws AuthenticationException {
|
||||
final String username = auth.getName();
|
||||
final String password = auth.getCredentials()
|
||||
.toString();
|
||||
|
||||
if ("externaluser".equals(username) && "pass".equals(password)) {
|
||||
return new UsernamePasswordAuthenticationToken(username, password, Collections.emptyList());
|
||||
} else {
|
||||
throw new BadCredentialsException("External system authentication failed");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supports(Class<?> auth) {
|
||||
return auth.equals(UsernamePasswordAuthenticationToken.class);
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
package com.baeldung.multipleauthproviders;
|
||||
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
public class MultipleAuthController {
|
||||
|
||||
@GetMapping("/api/ping")
|
||||
public String getPing() {
|
||||
return "OK";
|
||||
}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
package com.baeldung.multipleauthproviders;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.annotation.PropertySource;
|
||||
|
||||
@SpringBootApplication
|
||||
@PropertySource("classpath:application-defaults.properties")
|
||||
// @ImportResource({ "classpath*:spring-security-multiple-auth-providers.xml" })
|
||||
public class MultipleAuthProvidersApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(MultipleAuthProvidersApplication.class, args);
|
||||
}
|
||||
}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
package com.baeldung.multipleauthproviders;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
|
||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
|
||||
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
|
||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
|
||||
@EnableWebSecurity
|
||||
public class MultipleAuthProvidersSecurityConfig extends WebSecurityConfigurerAdapter {
|
||||
|
||||
@Autowired
|
||||
CustomAuthenticationProvider customAuthProvider;
|
||||
|
||||
@Override
|
||||
public void configure(AuthenticationManagerBuilder auth) throws Exception {
|
||||
|
||||
auth.authenticationProvider(customAuthProvider);
|
||||
|
||||
auth.inMemoryAuthentication()
|
||||
.withUser("memuser")
|
||||
.password(passwordEncoder().encode("pass"))
|
||||
.roles("USER");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configure(HttpSecurity http) throws Exception {
|
||||
http.httpBasic()
|
||||
.and()
|
||||
.authorizeRequests()
|
||||
.antMatchers("/api/**")
|
||||
.authenticated();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public PasswordEncoder passwordEncoder() {
|
||||
return new BCryptPasswordEncoder();
|
||||
}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
package com.baeldung.multipleentrypoints;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.annotation.PropertySource;
|
||||
|
||||
@SpringBootApplication
|
||||
@PropertySource("classpath:application-defaults.properties")
|
||||
// @ImportResource({"classpath*:spring-security-multiple-entry.xml"})
|
||||
public class MultipleEntryPointsApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(MultipleEntryPointsApplication.class, args);
|
||||
}
|
||||
}
|
||||
+99
@@ -0,0 +1,99 @@
|
||||
package com.baeldung.multipleentrypoints;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
|
||||
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
|
||||
import org.springframework.security.core.userdetails.User;
|
||||
import org.springframework.security.core.userdetails.UserDetailsService;
|
||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
import org.springframework.security.provisioning.InMemoryUserDetailsManager;
|
||||
import org.springframework.security.web.AuthenticationEntryPoint;
|
||||
import org.springframework.security.web.authentication.LoginUrlAuthenticationEntryPoint;
|
||||
import org.springframework.security.web.authentication.www.BasicAuthenticationEntryPoint;
|
||||
import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
|
||||
|
||||
@Configuration
|
||||
@EnableWebSecurity
|
||||
public class MultipleEntryPointsSecurityConfig {
|
||||
|
||||
@Bean
|
||||
public UserDetailsService userDetailsService() throws Exception {
|
||||
InMemoryUserDetailsManager manager = new InMemoryUserDetailsManager();
|
||||
manager.createUser(User.withUsername("user").password(encoder().encode("userPass")).roles("USER").build());
|
||||
manager.createUser(User.withUsername("admin").password(encoder().encode("adminPass")).roles("ADMIN").build());
|
||||
return manager;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public PasswordEncoder encoder() {
|
||||
return new BCryptPasswordEncoder();
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@Order(1)
|
||||
public static class App1ConfigurationAdapter extends WebSecurityConfigurerAdapter {
|
||||
|
||||
@Override
|
||||
protected void configure(HttpSecurity http) throws Exception {
|
||||
//@formatter:off
|
||||
http.antMatcher("/admin/**")
|
||||
.authorizeRequests().anyRequest().hasRole("ADMIN")
|
||||
.and().httpBasic().authenticationEntryPoint(authenticationEntryPoint())
|
||||
.and().exceptionHandling().accessDeniedPage("/403");
|
||||
//@formatter:on
|
||||
}
|
||||
|
||||
@Bean
|
||||
public AuthenticationEntryPoint authenticationEntryPoint(){
|
||||
BasicAuthenticationEntryPoint entryPoint = new BasicAuthenticationEntryPoint();
|
||||
entryPoint.setRealmName("admin realm");
|
||||
return entryPoint;
|
||||
}
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@Order(2)
|
||||
public static class App2ConfigurationAdapter extends WebSecurityConfigurerAdapter {
|
||||
|
||||
protected void configure(HttpSecurity http) throws Exception {
|
||||
|
||||
//@formatter:off
|
||||
http.antMatcher("/user/**")
|
||||
.authorizeRequests().anyRequest().hasRole("USER")
|
||||
.and().formLogin().loginProcessingUrl("/user/login")
|
||||
.failureUrl("/userLogin?error=loginError").defaultSuccessUrl("/user/myUserPage")
|
||||
.and().logout().logoutUrl("/user/logout").logoutSuccessUrl("/multipleHttpLinks")
|
||||
.deleteCookies("JSESSIONID")
|
||||
.and().exceptionHandling()
|
||||
.defaultAuthenticationEntryPointFor(loginUrlauthenticationEntryPointWithWarning(), new AntPathRequestMatcher("/user/private/**"))
|
||||
.defaultAuthenticationEntryPointFor(loginUrlauthenticationEntryPoint(), new AntPathRequestMatcher("/user/general/**"))
|
||||
.accessDeniedPage("/403")
|
||||
.and().csrf().disable();
|
||||
//@formatter:on
|
||||
}
|
||||
|
||||
@Bean
|
||||
public AuthenticationEntryPoint loginUrlauthenticationEntryPoint(){
|
||||
return new LoginUrlAuthenticationEntryPoint("/userLogin");
|
||||
}
|
||||
|
||||
@Bean
|
||||
public AuthenticationEntryPoint loginUrlauthenticationEntryPointWithWarning(){
|
||||
return new LoginUrlAuthenticationEntryPoint("/userLoginWithWarning");
|
||||
}
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@Order(3)
|
||||
public static class App3ConfigurationAdapter extends WebSecurityConfigurerAdapter {
|
||||
|
||||
protected void configure(HttpSecurity http) throws Exception {
|
||||
http.antMatcher("/guest/**").authorizeRequests().anyRequest().permitAll();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
package com.baeldung.multipleentrypoints;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
@Controller
|
||||
public class PagesController {
|
||||
|
||||
@RequestMapping("/multipleHttpLinks")
|
||||
public String getMultipleHttpLinksPage() {
|
||||
return "multipleHttpElems/multipleHttpLinks";
|
||||
}
|
||||
|
||||
@RequestMapping("/admin/myAdminPage")
|
||||
public String getAdminPage() {
|
||||
return "multipleHttpElems/myAdminPage";
|
||||
}
|
||||
|
||||
@RequestMapping("/user/general/myUserPage")
|
||||
public String getUserPage() {
|
||||
return "multipleHttpElems/myUserPage";
|
||||
}
|
||||
|
||||
@RequestMapping("/user/private/myPrivateUserPage")
|
||||
public String getPrivateUserPage() {
|
||||
return "multipleHttpElems/myPrivateUserPage";
|
||||
}
|
||||
|
||||
@RequestMapping("/guest/myGuestPage")
|
||||
public String getGuestPage() {
|
||||
return "multipleHttpElems/myGuestPage";
|
||||
}
|
||||
|
||||
@RequestMapping("/userLogin")
|
||||
public String getUserLoginPage() {
|
||||
return "multipleHttpElems/login";
|
||||
}
|
||||
|
||||
@RequestMapping("/userLoginWithWarning")
|
||||
public String getUserLoginPageWithWarning() {
|
||||
return "multipleHttpElems/loginWithWarning";
|
||||
}
|
||||
|
||||
@RequestMapping("/403")
|
||||
public String getAccessDeniedPage() {
|
||||
return "403";
|
||||
}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
package com.baeldung.multiplelogin;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.PropertySource;
|
||||
|
||||
@SpringBootApplication
|
||||
@PropertySource("classpath:application-defaults.properties")
|
||||
public class MultipleLoginApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(MultipleLoginApplication.class, args);
|
||||
}
|
||||
}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
package com.baeldung.multiplelogin;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.ViewResolver;
|
||||
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
|
||||
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
import org.springframework.web.servlet.view.InternalResourceViewResolver;
|
||||
import org.springframework.web.servlet.view.JstlView;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
|
||||
@EnableWebMvc
|
||||
@Configuration
|
||||
public class MultipleLoginMvcConfig implements WebMvcConfigurer {
|
||||
|
||||
public MultipleLoginMvcConfig() {
|
||||
super();
|
||||
}
|
||||
|
||||
// API
|
||||
|
||||
@Override
|
||||
public void addViewControllers(final ViewControllerRegistry registry) {
|
||||
registry.addViewController("/anonymous.html");
|
||||
|
||||
registry.addViewController("/login.html");
|
||||
registry.addViewController("/homepage.html");
|
||||
registry.addViewController("/console.html");
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ViewResolver viewResolver() {
|
||||
final InternalResourceViewResolver bean = new InternalResourceViewResolver();
|
||||
|
||||
bean.setViewClass(JstlView.class);
|
||||
bean.setPrefix("/WEB-INF/view/");
|
||||
bean.setSuffix(".jsp");
|
||||
|
||||
return bean;
|
||||
}
|
||||
}
|
||||
+78
@@ -0,0 +1,78 @@
|
||||
package com.baeldung.multiplelogin;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
|
||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
|
||||
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
|
||||
import org.springframework.security.core.userdetails.User;
|
||||
import org.springframework.security.core.userdetails.UserDetailsService;
|
||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
import org.springframework.security.provisioning.InMemoryUserDetailsManager;
|
||||
|
||||
@Configuration
|
||||
@EnableWebSecurity
|
||||
public class MultipleLoginSecurityConfig {
|
||||
|
||||
@Bean
|
||||
public UserDetailsService userDetailsService() throws Exception {
|
||||
InMemoryUserDetailsManager manager = new InMemoryUserDetailsManager();
|
||||
manager.createUser(User.withUsername("user").password(encoder().encode("userPass")).roles("USER").build());
|
||||
manager.createUser(User.withUsername("admin").password(encoder().encode("adminPass")).roles("ADMIN").build());
|
||||
return manager;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public static PasswordEncoder encoder() {
|
||||
return new BCryptPasswordEncoder();
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@Order(1)
|
||||
public static class App1ConfigurationAdapter extends WebSecurityConfigurerAdapter {
|
||||
|
||||
public App1ConfigurationAdapter() {
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
|
||||
auth.inMemoryAuthentication().withUser("admin").password(encoder().encode("admin")).roles("ADMIN");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configure(HttpSecurity http) throws Exception {
|
||||
http.antMatcher("/admin*").authorizeRequests().anyRequest().hasRole("ADMIN")
|
||||
// log in
|
||||
.and().formLogin().loginPage("/loginAdmin").loginProcessingUrl("/admin_login").failureUrl("/loginAdmin?error=loginError").defaultSuccessUrl("/adminPage")
|
||||
// logout
|
||||
.and().logout().logoutUrl("/admin_logout").logoutSuccessUrl("/protectedLinks").deleteCookies("JSESSIONID").and().exceptionHandling().accessDeniedPage("/403").and().csrf().disable();
|
||||
}
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@Order(2)
|
||||
public static class App2ConfigurationAdapter extends WebSecurityConfigurerAdapter {
|
||||
|
||||
public App2ConfigurationAdapter() {
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
|
||||
auth.inMemoryAuthentication().withUser("user").password(encoder().encode("user")).roles("USER");
|
||||
}
|
||||
|
||||
protected void configure(HttpSecurity http) throws Exception {
|
||||
http.antMatcher("/user*").authorizeRequests().anyRequest().hasRole("USER")
|
||||
// log in
|
||||
.and().formLogin().loginPage("/loginUser").loginProcessingUrl("/user_login").failureUrl("/loginUser?error=loginError").defaultSuccessUrl("/userPage")
|
||||
// logout
|
||||
.and().logout().logoutUrl("/user_logout").logoutSuccessUrl("/protectedLinks").deleteCookies("JSESSIONID").and().exceptionHandling().accessDeniedPage("/403").and().csrf().disable();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
package com.baeldung.multiplelogin;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
|
||||
@Controller
|
||||
public class UsersController {
|
||||
|
||||
@GetMapping("/protectedLinks")
|
||||
public String getAnonymousPage() {
|
||||
return "protectedLinks";
|
||||
}
|
||||
|
||||
@GetMapping("/userPage")
|
||||
public String getUserPage() {
|
||||
return "userPage";
|
||||
}
|
||||
|
||||
@GetMapping("/adminPage")
|
||||
public String getAdminPage() {
|
||||
return "adminPage";
|
||||
}
|
||||
|
||||
@GetMapping("/loginAdmin")
|
||||
public String getAdminLoginPage() {
|
||||
return "loginAdmin";
|
||||
}
|
||||
|
||||
@GetMapping("/loginUser")
|
||||
public String getUserLoginPage() {
|
||||
return "loginUser";
|
||||
}
|
||||
|
||||
@GetMapping("/403")
|
||||
public String getAccessDeniedPage() {
|
||||
return "403";
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
package com.baeldung.ssl;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.annotation.PropertySource;
|
||||
|
||||
@SpringBootApplication
|
||||
@PropertySource("classpath:application-defaults.properties")
|
||||
public class HttpsEnabledApplication {
|
||||
|
||||
public static void main(String... args) {
|
||||
SpringApplication application = new SpringApplication(HttpsEnabledApplication.class);
|
||||
application.setAdditionalProfiles("ssl");
|
||||
application.run(args);
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
package com.baeldung.ssl;
|
||||
|
||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
|
||||
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
|
||||
|
||||
@EnableWebSecurity
|
||||
public class SecurityConfig extends WebSecurityConfigurerAdapter {
|
||||
|
||||
@Override
|
||||
protected void configure(HttpSecurity http) throws Exception {
|
||||
http.authorizeRequests()
|
||||
.antMatchers("/**")
|
||||
.permitAll();
|
||||
}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
package com.baeldung.ssl;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
|
||||
@Controller
|
||||
public class WelcomeController {
|
||||
|
||||
@GetMapping("/welcome")
|
||||
public String welcome() {
|
||||
return "ssl/welcome";
|
||||
}
|
||||
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
spring.datasource.url=jdbc:postgresql://localhost:5432/test
|
||||
spring.datasource.username=test
|
||||
spring.datasource.password=test
|
||||
|
||||
spring.jpa.hibernate.ddl-auto=create
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
spring.datasource.driver-class-name=org.h2.Driver
|
||||
spring.datasource.url=jdbc:h2:mem:security_permission;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE
|
||||
spring.datasource.username=sa
|
||||
spring.datasource.password=
|
||||
spring.jpa.hibernate.ddl-auto=create-drop
|
||||
spring.jpa.database=H2
|
||||
spring.jpa.show-sql=false
|
||||
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.H2Dialect
|
||||
|
||||
#logging.level.org.springframework.security.web.FilterChainProxy=DEBUG
|
||||
|
||||
spring.h2.console.enabled=true
|
||||
spring.h2.console.path=/h2-console
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
spring.datasource.platform=mysql
|
||||
spring.datasource.url=jdbc:mysql://localhost:3306/jdbc_authentication
|
||||
spring.datasource.username=root
|
||||
spring.datasource.password=pass
|
||||
|
||||
spring.datasource.initialization-mode=always
|
||||
spring.jpa.hibernate.ddl-auto=none
|
||||
|
||||
spring.profiles.active=mysql
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
spring.datasource.platform=postgre
|
||||
spring.datasource.url=jdbc:postgresql://localhost:5432/jdbc_authentication
|
||||
spring.datasource.username=postgres
|
||||
spring.datasource.password=pass
|
||||
|
||||
spring.datasource.initialization-mode=always
|
||||
spring.jpa.hibernate.ddl-auto=none
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
http.port=8080
|
||||
|
||||
server.port=8443
|
||||
|
||||
server.ssl.enabled=true
|
||||
|
||||
# The format used for the keystore
|
||||
server.ssl.key-store-type=PKCS12
|
||||
# The path to the keystore containing the certificate
|
||||
server.ssl.key-store=classpath:keystore/baeldung.p12
|
||||
# The password used to generate the certificate
|
||||
server.ssl.key-store-password=password
|
||||
# The alias mapped to the certificate
|
||||
server.ssl.key-alias=baeldung
|
||||
|
||||
#trust store location
|
||||
trust.store=classpath:keystore/baeldung.p12
|
||||
#trust store password
|
||||
trust.store.password=password
|
||||
+1
@@ -0,0 +1 @@
|
||||
server.port=8082
|
||||
@@ -0,0 +1,4 @@
|
||||
-- User user@email.com/pass
|
||||
INSERT INTO bael_users (name, email, password, enabled) values ('user', 'user@email.com', '$2a$10$8.UnVuG9HHgffUDAlk8qfOuVGkqRzgVymGe07xd00DMxs.AQubh4a', 1);
|
||||
|
||||
INSERT INTO authorities (email, authority) values ('user@email.com', 'ROLE_USER');
|
||||
@@ -0,0 +1,4 @@
|
||||
-- User user/pass
|
||||
INSERT INTO users (username, password, enabled) values ('user', '$2a$10$8.UnVuG9HHgffUDAlk8qfOuVGkqRzgVymGe07xd00DMxs.AQubh4a', true);
|
||||
|
||||
INSERT INTO authorities (username, authority) values ('user', 'ROLE_USER');
|
||||
BIN
Binary file not shown.
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration>
|
||||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
|
||||
</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<root level="INFO">
|
||||
<appender-ref ref="STDOUT" />
|
||||
</root>
|
||||
</configuration>
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
driverClassName=org.h2.Driver
|
||||
url=jdbc:h2:mem:myDb;DB_CLOSE_DELAY=-1
|
||||
username=sa
|
||||
password=
|
||||
|
||||
hibernate.dialect=org.hibernate.dialect.H2Dialect
|
||||
hibernate.show_sql=false
|
||||
hibernate.hbm2ddl.auto=create-drop
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
DROP TABLE IF EXISTS authorities;
|
||||
DROP TABLE IF EXISTS bael_users;
|
||||
|
||||
CREATE TABLE bael_users (
|
||||
name VARCHAR(50) NOT NULL,
|
||||
email VARCHAR(50) NOT NULL,
|
||||
password VARCHAR(100) NOT NULL,
|
||||
enabled TINYINT NOT NULL DEFAULT 1,
|
||||
PRIMARY KEY (email)
|
||||
);
|
||||
|
||||
CREATE TABLE authorities (
|
||||
email VARCHAR(50) NOT NULL,
|
||||
authority VARCHAR(50) NOT NULL,
|
||||
FOREIGN KEY (email) REFERENCES bael_users(email)
|
||||
);
|
||||
|
||||
CREATE UNIQUE INDEX ix_auth_email on authorities (email,authority);
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
DROP TABLE IF EXISTS authorities;
|
||||
DROP TABLE IF EXISTS users;
|
||||
|
||||
CREATE TABLE users (
|
||||
username varchar(50) NOT NULL PRIMARY KEY,
|
||||
password varchar(100) NOT NULL,
|
||||
enabled boolean not null DEFAULT true
|
||||
);
|
||||
|
||||
CREATE TABLE authorities (
|
||||
username varchar(50) NOT NULL,
|
||||
authority varchar(50) NOT NULL,
|
||||
CONSTRAINT foreign_authorities_users_1 foreign key(username) references users(username)
|
||||
);
|
||||
|
||||
CREATE UNIQUE INDEX ix_auth_username on authorities (username,authority);
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:mvc="http://www.springframework.org/schema/mvc"
|
||||
xmlns:beans="http://www.springframework.org/schema/beans"
|
||||
xmlns:security="http://www.springframework.org/schema/security"
|
||||
xsi:schemaLocation="
|
||||
http://www.springframework.org/schema/mvc
|
||||
http://www.springframework.org/schema/mvc/spring-mvc-4.3.xsd
|
||||
http://www.springframework.org/schema/security
|
||||
http://www.springframework.org/schema/security/spring-security-5.2.xsd
|
||||
http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans.xsd">
|
||||
|
||||
<security:authentication-manager>
|
||||
<security:authentication-provider>
|
||||
<security:user-service>
|
||||
<security:user name="user" password="{noop}user" authorities="ROLE_USER"/>
|
||||
</security:user-service>
|
||||
</security:authentication-provider>
|
||||
</security:authentication-manager>
|
||||
|
||||
<security:http pattern="/**" use-expressions="true" auto-config="true">
|
||||
<security:intercept-url pattern="/loginUser" access="permitAll"/>
|
||||
<security:intercept-url pattern="/user*" access="hasRole('ROLE_USER')"/>
|
||||
|
||||
<security:form-login login-page="/loginUser"
|
||||
login-processing-url="/user_login"
|
||||
authentication-failure-url="/loginUser?error=loginError"
|
||||
default-target-url="/userMainPage"/>
|
||||
<security:csrf disabled="true"/>
|
||||
<security:logout logout-url="/user_logout" delete-cookies="JSESSIONID" logout-success-url="/loginUser"/>
|
||||
|
||||
|
||||
<security:custom-filter after="BASIC_AUTH_FILTER" ref="loginPageFilter"/>
|
||||
</security:http>
|
||||
|
||||
<beans:bean id="loginPageFilter" class="com.baeldung.loginredirect.LoginPageFilter"/>
|
||||
|
||||
<mvc:interceptors>
|
||||
<mvc:interceptor>
|
||||
<mvc:mapping path="/loginUser"/>
|
||||
<bean class="com.baeldung.loginredirect.LoginPageInterceptor"/>
|
||||
</mvc:interceptor>
|
||||
</mvc:interceptors>
|
||||
</beans>
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:security="http://www.springframework.org/schema/security"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-4.2.xsd
|
||||
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
|
||||
|
||||
<security:authentication-manager>
|
||||
<security:authentication-provider>
|
||||
<security:user-service>
|
||||
<security:user name="memuser" password="pass"
|
||||
authorities="ROLE_USER" />
|
||||
</security:user-service>
|
||||
</security:authentication-provider>
|
||||
|
||||
<security:authentication-provider
|
||||
ref="customAuthenticationProvider" />
|
||||
</security:authentication-manager>
|
||||
|
||||
<security:http>
|
||||
<security:http-basic />
|
||||
<security:intercept-url pattern="/api/**"
|
||||
access="isAuthenticated()" />
|
||||
</security:http>
|
||||
</beans>
|
||||
+65
@@ -0,0 +1,65 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:security="http://www.springframework.org/schema/security"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-4.2.xsd
|
||||
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
|
||||
|
||||
<security:authentication-manager>
|
||||
<security:authentication-provider>
|
||||
<security:user-service>
|
||||
<security:user name="user" password="userPass" authorities="ROLE_USER"/>
|
||||
<security:user name="admin" password="adminPass" authorities="ROLE_ADMIN"/>
|
||||
</security:user-service>
|
||||
</security:authentication-provider>
|
||||
</security:authentication-manager>
|
||||
|
||||
<security:http pattern="/user/general/**" use-expressions="true" auto-config="true"
|
||||
entry-point-ref="loginUrlAuthenticationEntryPoint">
|
||||
<security:intercept-url pattern="/**" access="hasRole('ROLE_USER')" />
|
||||
<security:form-login login-processing-url="/user/general/login"
|
||||
authentication-failure-url="/userLogin?error=loginError"
|
||||
default-target-url="/user/myUserPage"/>
|
||||
<security:csrf disabled="true"/>
|
||||
<security:access-denied-handler error-page="/403"/>
|
||||
<security:logout logout-url="/user/logout" delete-cookies="JSESSIONID" logout-success-url="/multipleHttpLinks"/>
|
||||
</security:http>
|
||||
|
||||
<bean id="loginUrlAuthenticationEntryPoint"
|
||||
class="org.springframework.security.web.authentication.LoginUrlAuthenticationEntryPoint">
|
||||
<constructor-arg name="loginFormUrl" value="/userLogin" />
|
||||
</bean>
|
||||
|
||||
<security:http pattern="/user/private/**" use-expressions="true" auto-config="true"
|
||||
entry-point-ref="loginUrlAuthenticationEntryPointWithWarning">
|
||||
<security:intercept-url pattern="/**" access="hasRole('ROLE_USER')"/>
|
||||
<security:form-login login-processing-url="/user/private/login"
|
||||
authentication-failure-url="/userLogin?error=loginError"
|
||||
default-target-url="/user/myUserPage" />
|
||||
<security:csrf disabled="true"/>
|
||||
<security:access-denied-handler error-page="/403"/>
|
||||
<security:logout logout-url="/user/logout" delete-cookies="JSESSIONID" logout-success-url="/multipleHttpLinks"/>
|
||||
</security:http>
|
||||
|
||||
<bean id="loginUrlAuthenticationEntryPointWithWarning"
|
||||
class="org.springframework.security.web.authentication.LoginUrlAuthenticationEntryPoint">
|
||||
<constructor-arg name="loginFormUrl" value="/userLoginWithWarning" />
|
||||
</bean>
|
||||
|
||||
<security:http pattern="/admin/**" use-expressions="true" auto-config="true">
|
||||
<security:intercept-url pattern="/**" access="hasRole('ROLE_ADMIN')"/>
|
||||
<security:http-basic entry-point-ref="authenticationEntryPoint" />
|
||||
<security:access-denied-handler error-page="/403"/>
|
||||
</security:http>
|
||||
|
||||
<bean id="authenticationEntryPoint"
|
||||
class="org.springframework.security.web.authentication.www.BasicAuthenticationEntryPoint">
|
||||
<property name="realmName" value="admin realm" />
|
||||
</bean>
|
||||
|
||||
<security:http pattern="/**" use-expressions="true" auto-config="true">
|
||||
<security:intercept-url pattern="/guest/**" access="permitAll()"/>
|
||||
</security:http>
|
||||
|
||||
|
||||
</beans>
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
|
||||
<title></title>
|
||||
</head>
|
||||
<body>
|
||||
You do not have permission to view this page.
|
||||
</body>
|
||||
</html>
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
|
||||
<title>Insert title here</title>
|
||||
</head>
|
||||
<body>
|
||||
Welcome admin! <a th:href="@{/admin_logout}" >Logout</a>
|
||||
|
||||
<br /><br />
|
||||
<a th:href="@{/protectedLinks}" >Back to links</a>
|
||||
</body>
|
||||
</html>
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<title>Spring Security Thymeleaf</title>
|
||||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css"/>
|
||||
</head>
|
||||
<body>
|
||||
<nav class="navbar navbar-default">
|
||||
<div class="container-fluid">
|
||||
<div class="navbar-header">
|
||||
<a class="navbar-brand">Spring Security Thymeleaf</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<div class="container">
|
||||
Welcome
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
<html>
|
||||
<head></head>
|
||||
|
||||
<body>
|
||||
<h1>Login</h1>
|
||||
|
||||
<form name='f' action="login" method='POST'>
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<td>User:</td>
|
||||
<td><input type="text" name="username"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Password:</td>
|
||||
<td><input type="password" name="password" /></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><input name="submit" type="submit" value="submit" /></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</form>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
|
||||
<title>Insert title here</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<p>Admin login page</p>
|
||||
<form name="f" action="admin_login" method="POST">
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<td>User:</td>
|
||||
<td><input type="text" name="username" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Password:</td>
|
||||
<td><input type="password" name="password" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><input name="submit" type="submit" value="submit" /></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</form>
|
||||
|
||||
<p th:if="${param.error}">Login failed!</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
|
||||
<title>Login</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<p>User login page</p>
|
||||
|
||||
<form name="f" action="user_login" method="POST">
|
||||
<table>
|
||||
<tr>
|
||||
<td>User:</td>
|
||||
<td><input type="text" name="username" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Password:</td>
|
||||
<td><input type="password" name="password" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><input name="submit" type="submit" value="submit" /></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</form>
|
||||
<p th:if="${param.error}">Login failed!</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
<html>
|
||||
<head></head>
|
||||
|
||||
<body>
|
||||
<h1>Login</h1>
|
||||
|
||||
<form name='f' action="user/login" method='POST'>
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<td>Username:</td>
|
||||
<td><input type="text" name="username" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Password:</td>
|
||||
<td><input type="password" name="password" /></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><input name="submit" type="submit" value="submit" /></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</form>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
<html>
|
||||
<head></head>
|
||||
|
||||
<body>
|
||||
<h1>Login</h1>
|
||||
<h3>Warning! You are about to access sensible data!</h3>
|
||||
|
||||
<form name='f' action="user/login" method='POST'>
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<td>Username:</td>
|
||||
<td><input type="text" name="username" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Password:</td>
|
||||
<td><input type="password" name="password" /></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td><input name="submit" type="submit" value="submit" /></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</form>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="ISO-8859-1" />
|
||||
<title>Multiple Http Elements Links</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<a th:href="@{/admin/myAdminPage}">Admin page</a>
|
||||
<br />
|
||||
<a th:href="@{/user/general/myUserPage}">User page</a>
|
||||
<br />
|
||||
<a th:href="@{/user/private/myPrivateUserPage}">Private user page</a>
|
||||
<br />
|
||||
<a th:href="@{/guest/myGuestPage}">Guest page</a>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="ISO-8859-1" />
|
||||
<title>Admin Page</title>
|
||||
</head>
|
||||
<body>
|
||||
Welcome admin!
|
||||
|
||||
<br /><br />
|
||||
<a th:href="@{/multipleHttpLinks}" >Back to links</a>
|
||||
</body>
|
||||
</html>
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="ISO-8859-1" />
|
||||
<title>Guest Page</title>
|
||||
</head>
|
||||
<body>
|
||||
Welcome guest!
|
||||
|
||||
<br /><br />
|
||||
<a th:href="@{/multipleHttpLinks}" >Back to links</a>
|
||||
</body>
|
||||
</html>
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="ISO-8859-1" />
|
||||
<title>Insert title here</title>
|
||||
</head>
|
||||
<body>
|
||||
Welcome user to your private page! <a th:href="@{/user/logout}" >Logout</a>
|
||||
|
||||
<br /><br />
|
||||
<a th:href="@{/multipleHttpLinks}" >Back to links</a>
|
||||
</body>
|
||||
</html>
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="ISO-8859-1" />
|
||||
<title>User Page</title>
|
||||
</head>
|
||||
<body>
|
||||
Welcome user! <a th:href="@{/user/logout}" >Logout</a>
|
||||
|
||||
<br /><br />
|
||||
<a th:href="@{/multipleHttpLinks}" >Back to links</a>
|
||||
</body>
|
||||
</html>
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org"
|
||||
xmlns:sec="http://www.thymeleaf.org/extras/spring-security">
|
||||
<head>
|
||||
<title>Private</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Congrats!</h1>
|
||||
</body>
|
||||
</html>
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
|
||||
<title>Insert title here</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<a th:href="@{/userPage}">User page</a>
|
||||
<br />
|
||||
<a th:href="@{/adminPage}">Admin page</a>
|
||||
</body>
|
||||
</html>
|
||||
+1
@@ -0,0 +1 @@
|
||||
<h1>Welcome to Secured Site</h1>
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
|
||||
<title>Baeldung Login Redirect</title>
|
||||
</head>
|
||||
<body>
|
||||
Welcome user! <a th:href="@{/user_logout}" >Logout</a>
|
||||
</body>
|
||||
</html>
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
|
||||
<title>Insert title here</title>
|
||||
</head>
|
||||
<body>
|
||||
Welcome user! <a th:href="@{/user_logout}" >Logout</a>
|
||||
<br /><br />
|
||||
<a th:href="@{/protectedLinks}" >Back to links</a>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user