{"id":307921,"date":"2020-08-03T21:00:20","date_gmt":"2020-08-03T21:00:20","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=307921"},"modified":"-0001-11-30T00:00:00","modified_gmt":"2020-08-03T21:00:20","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=307921","title":{"rendered":"\u041a\u043e\u043d\u0442\u0440\u043e\u043b\u0438\u0440\u0443\u0435\u043c \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u0441\u0435\u0441\u0441\u0438\u0438, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f Spring"},"content":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/513668\/\">\u041f\u0440\u0438\u0432\u0435\u0442, \u0425\u0430\u0431\u0440.<\/p>\n<p>  \u041f\u0440\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u043c\u043d\u043e\u0433\u043e\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0433\u043e web-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u043b\u043e\u0441\u044c \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0442\u044c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0445 \u0441\u0435\u0441\u0441\u0438\u0439 \u0434\u043b\u044f \u043e\u0434\u043d\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f. \u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0445\u043e\u0447\u0443 \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u0441 \u0412\u0430\u043c\u0438 \u0441\u0432\u043e\u0438 \u0440\u0435\u0448\u0435\u043d\u0438\u0435\u043c.<\/p>\n<p>  \u041a\u043e\u043d\u0442\u0440\u043e\u043b\u044c \u0441\u0435\u0441\u0441\u0438\u0439 \u0430\u043a\u0442\u0443\u0430\u043b\u0435\u043d \u0434\u043b\u044f \u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432. \u0412 \u043d\u0430\u0448\u0435\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0431\u044b\u043b\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0445 \u0441\u0435\u0441\u0441\u0438\u0439 \u0434\u043b\u044f \u043e\u0434\u043d\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f. \u041f\u0440\u0438 \u0432\u0445\u043e\u0434\u0435 \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0443 (login) \u0434\u043b\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u0430\u043a\u0442\u0438\u0432\u043d\u0430\u044f \u0441\u0435\u0441\u0441\u0438\u044f. \u041f\u0440\u0438 \u0432\u0445\u043e\u0434\u0435 \u044d\u0442\u043e\u0433\u043e \u0436\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0441 \u0434\u0440\u0443\u0433\u043e\u0433\u043e \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043d\u0435 \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0442\u044c \u043d\u043e\u0432\u0443\u044e \u0441\u0435\u0441\u0441\u0438\u044e, \u0430 \u043f\u0440\u043e\u0438\u043d\u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043e\u0431 \u0443\u0436\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0439 \u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0439 \u0441\u0435\u0441\u0441\u0438\u0438 \u0438 \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0438\u0442\u044c \u0435\u043c\u0443 2 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430:<\/p>\n<ul>\n<li>\u0437\u0430\u043a\u0440\u044b\u0442\u044c \u043f\u0440\u043e\u0448\u043b\u0443\u044e \u0441\u0435\u0441\u0441\u0438\u044e \u0438 \u043e\u0442\u043a\u0440\u044b\u0442\u044c \u043d\u043e\u0432\u0443\u044e<\/li>\n<li>\u043d\u0435 \u0437\u0430\u043a\u0440\u044b\u0432\u0430\u0442\u044c \u0441\u0442\u0430\u0440\u0443\u044e \u0441\u0435\u0441\u0441\u0438\u044e \u0438 \u043d\u0435 \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0442\u044c \u043d\u043e\u0432\u0443\u044e \u0441\u0435\u0441\u0441\u0438\u044e<\/li>\n<\/ul>\n<p>  \u0422\u0430\u043a \u0436\u0435 \u043f\u0440\u0438 \u0437\u0430\u043a\u0440\u044b\u0442\u0438\u0435 \u0441\u0442\u0430\u0440\u043e\u0439 \u0441\u0435\u0441\u0441\u0438\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0435 \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044e \u043e\u0431 \u044d\u0442\u043e\u043c \u0441\u043e\u0431\u044b\u0442\u0438\u0435.<\/p>\n<p>  \u0418 \u043d\u0443\u0436\u043d\u043e \u0443\u0447\u0435\u0441\u0442\u044c 2 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0438\u043d\u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438 \u0441\u0435\u0441\u0441\u0438\u0438:<\/p>\n<ul>\n<li>\u0440\u0430\u0437\u043b\u043e\u0433\u0438\u043d \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f (\u0442.\u0435. \u043d\u0430\u0436\u0430\u0442\u0438\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c \u043a\u043d\u043e\u043f\u043a\u0438 logout)<\/li>\n<li>\u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0440\u0430\u0437\u043b\u043e\u0433\u0438\u043d \u043f\u043e\u0441\u043b\u0435 30 \u043c\u0438\u043d\u0443\u0442 \u0431\u0435\u0437\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f<\/li>\n<\/ul>\n<p><a name=\"habracut\"><\/a>  <\/p>\n<h3>\u0421\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0441\u0435\u0441\u0441\u0438\u0439 \u043f\u0440\u0438 \u043f\u0435\u0440\u0435\u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0435<\/h3>\n<p>  \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0443\u0436\u043d\u043e \u043d\u0430\u0443\u0447\u0438\u0442\u044c\u0441\u044f \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0442\u044c \u0441\u0435\u0441\u0441\u0438\u0438(\u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0442\u044c \u0431\u0443\u0434\u0435\u043c \u0432 \u0431\u0434, \u043d\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0442\u044c \u0438 \u0432 redis, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440). \u0412 \u044d\u0442\u043e\u043c \u043d\u0430\u043c \u043f\u043e\u043c\u043e\u0436\u0435\u0442 <i>Spring security<\/i> \u0438 <i>spring session jdbc<\/i>. \u0412 <b>build.gradle<\/b> \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c 2 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438:<\/p>\n<pre><code class=\"xml\">implementation(             'org.springframework.boot:spring-boot-starter-security',             'org.springframework.session:spring-session-jdbc'     )<\/code><\/pre>\n<p>  \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0441\u0432\u043e\u0439 <b>WebSecurityConfig<\/b>, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0432\u043a\u043b\u044e\u0447\u0438\u043c \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0441\u0435\u0441\u0441\u0438\u0439 \u0432 \u0431\u0434 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0430\u043d\u043d\u043e\u0442\u0430\u0446\u0438\u0438 <i>@EnableJdbcHttpSession<\/i><\/p>\n<pre><code class=\"java\">@EnableWebSecurity @EnableJdbcHttpSession @RequiredArgsConstructor public class WebSecurityConfig extends WebSecurityConfigurerAdapter {      private final UserDetailsService userDetailsService;     private final PasswordEncoder passwordEncoder;     private final AuthenticationFailureHandler securityErrorHandler;     private final ConcurrentSessionStrategy concurrentSessionStrategy;     private final SessionRegistry sessionRegistry;      @Override     protected void configure(AuthenticationManagerBuilder auth) throws Exception {         auth.userDetailsService(userDetailsService).passwordEncoder(passwordEncoder);     }      @Override     protected void configure(HttpSecurity http) throws Exception {         http                 .cors().and()                 \/\/\u0434\u043b\u044f \u0437\u0430\u0449\u0438\u0442\u044b \u043e csrf \u0430\u0442\u0430\u043a                 .csrf().csrfTokenRepository(CookieCsrfTokenRepository.withHttpOnlyFalse()).and()                 .httpBasic().and()                 .authorizeRequests()                 .anyRequest()                 .authenticated().and()                 \/\/\u041b\u043e\u0433\u0430\u0443\u0442                 .logout()                 .logoutRequestMatcher(new AntPathRequestMatcher(&quot;\/api\/logout&quot;))                 \/\/\u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u043f\u0440\u0438 \u043b\u043e\u0433\u0430\u0443\u0442\u0435 200(\u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f 203)                 .logoutSuccessHandler(new HttpStatusReturningLogoutSuccessHandler(HttpStatus.OK))                 \/\/\u0418\u043d\u0432\u0430\u043b\u0438\u0434\u0438\u0440\u0443\u0435\u043c \u0441\u0435\u0441\u0441\u0438\u044e \u043f\u0440\u0438 \u043b\u043e\u0433\u0430\u0443\u0442\u0435                 .invalidateHttpSession(true)                 .clearAuthentication(true)                 \/\/\u0423\u0434\u0430\u043b\u044f\u0435\u043c \u0432\u0441\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u0441 \u0444\u0440\u043e\u043d\u0442\u0430 \u043f\u0440\u0438 \u043b\u043e\u0433\u0430\u0443\u0442\u0435(\u0442.\u0435. \u0447\u0438\u0441\u0442\u0438\u043c \u043a\u0443\u043a\u0438, \u0445\u0438\u0434\u0435\u0440\u044b \u0438 \u0442.\u0434.)                 .addLogoutHandler(new HeaderWriterLogoutHandler(new ClearSiteDataHeaderWriter(Directive.ALL)))                 .permitAll().and()                 \/\/\u0412\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440 \u0441\u0435\u0441\u0441\u0438\u0439(\u0434\u043b\u044f \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044f \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0441\u0435\u0441\u0441\u0438\u0439)                 .sessionManagement()                 \/\/\u0423\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u043c\u0430\u043a\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u0435\u0441\u0441\u0438\u0439(\u0442\u0443\u0442 \u0443\u043a\u0430\u0437\u0430\u043d\u043e \u043d\u0435 1, \u0442.\u043a. \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0441\u0432\u043e\u0435\u0439 \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u043e\u0439 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0435\u0439, \u043e\u0431\u044a\u044f\u0441\u043d\u0435\u043d\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 \u043d\u0438\u0436\u0435)                 .maximumSessions(3)                 \/\/\u041f\u0440\u0438 \u043f\u0440\u0435\u0432\u044b\u0448\u0435\u043d\u0438\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0445 \u0441\u0435\u0441\u0441\u0438\u0439(3) \u0432\u044b\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435  SessionAuthenticationException                 .maxSessionsPreventsLogin(true)                 \/\/\u0423\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u043a\u0430\u043a \u0431\u0443\u0434\u0443\u0442 \u0440\u0435\u0433\u0435\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0430\u0448\u0438 \u0441\u0435\u0441\u0441\u0438\u0438(\u0442\u043e\u0433\u0434\u0430 \u0432\u043e \u0432\u0441\u0435\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u043c\u0435\u043d\u043d\u043e \u044d\u0442\u043e\u0442 \u0431\u0438\u043d)                 .sessionRegistry(sessionRegistry).and()                 \/\/\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043d\u0430\u0448\u0443 \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u0443\u044e \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044e \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043a\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0441\u0435\u0441\u0441\u0438\u0439                 .sessionAuthenticationStrategy(concurrentSessionStrategy)                 \/\/\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u0447\u0438\u043a \u0434\u043b\u044f \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0439                 .sessionAuthenticationFailureHandler(securityErrorHandler);     }      \/\/\u0434\u043b\u044f \u0438\u043d\u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438 \u0441\u0435\u0441\u0441\u0438\u0439 \u043f\u0440\u0438 \u043b\u043e\u0433\u0430\u0443\u0442\u0435     @Bean     public static ServletListenerRegistrationBean httpSessionEventPublisher() {         return new ServletListenerRegistrationBean(new HttpSessionEventPublisher());     }      @Bean     public static SessionRegistry sessionRegistry(JdbcIndexedSessionRepository sessionRepository) {         return new SpringSessionBackedSessionRegistry(sessionRepository);     }      @Bean     public static PasswordEncoder passwordEncoder() {         return new BCryptPasswordEncoder(12);     }  }<\/code><\/pre>\n<p>  \u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u044d\u0442\u043e\u0433\u043e \u043a\u043e\u043d\u0444\u0438\u0433\u0430 \u043c\u044b \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u043a\u043b\u044e\u0447\u0438\u043b\u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0445 \u0441\u0435\u0441\u0441\u0438\u0439 \u0432 \u0431\u0430\u0437\u0435, \u043d\u043e \u0438 \u0442\u0430\u043a \u0436\u0435 \u043f\u0440\u043e\u043f\u0438\u0441\u0430\u043b\u0438 \u043b\u043e\u0433\u0438\u043a\u0443 \u043f\u0440\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u043c \u043b\u043e\u0433\u0430\u0443\u0442\u0435, \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0438 \u0441\u0432\u043e\u044e \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044e \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0441\u0435\u0441\u0441\u0438\u0439 \u0438 \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u0447\u0438\u043a \u0434\u043b\u044f \u043e\u0448\u0438\u0431\u043e\u043a.<\/p>\n<p>  \u0414\u043b\u044f \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0441\u0435\u0441\u0441\u0438\u0439 \u0432 \u0431\u0434 \u0442\u0430\u043a \u0436\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0432 <b>application.yml<\/b> \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043f\u0440\u043e\u043f\u0435\u0440\u0442\u0438(\u0432 \u043c\u043e\u0435\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f postgresql):<\/p>\n<pre><code class=\"xml\">spring:   datasource:     url: jdbc:postgresql:\/\/localhost:5432\/test-db     username: test     password: test     driver-class-name: org.postgresql.Driver   session:     store-type: jdbc<\/code><\/pre>\n<p>  \u041c\u043e\u0436\u043d\u043e \u0442\u0430\u043a\u0436\u0435 \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u0432\u0440\u0435\u043c\u044f \u0436\u0438\u0437\u043d\u0438 \u0441\u0435\u0441\u0441\u0438\u0438(\u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e 30 \u043c\u0438\u043d\u0443\u0442) \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043f\u0440\u043e\u043f\u0435\u0440\u0442\u0438:<\/p>\n<pre><code class=\"xml\">server.servlet.session.timeout<\/code><\/pre>\n<p>  <i>\u0415\u0441\u043b\u0438 \u043d\u0435 \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u0441\u0443\u0444\u0444\u0438\u043a\u0441, \u0442\u043e \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0431\u0443\u0434\u0443\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0441\u0435\u043a\u0443\u043d\u0434\u044b.<br \/>  <\/i><br \/>  \u0414\u0430\u043b\u0435\u0435 \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0442\u0430\u0431\u043b\u0438\u0446\u0443, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0431\u0443\u0434\u0443\u0442 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0442\u044c\u0441\u044f \u0441\u0435\u0441\u0441\u0438\u0438. \u0412 \u043d\u0430\u0448\u0435\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c <i>liquibase<\/i>, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0432 \u0447\u0435\u043d\u0434\u0436\u0441\u0435\u0442\u0435:<\/p>\n<pre><code class=\"xml\">&lt;changeSet id=&quot;0.1&quot; failOnError=&quot;true&quot;&gt;     &lt;comment&gt;Create sessions table&lt;\/comment&gt;      &lt;createTable tableName=&quot;spring_session&quot;&gt;       &lt;column name=&quot;primary_id&quot; type=&quot;char(36)&quot;&gt;         &lt;constraints primaryKey=&quot;true&quot;\/&gt;       &lt;\/column&gt;       &lt;column name=&quot;session_id&quot; type=&quot;char(36)&quot;&gt;         &lt;constraints nullable=&quot;false&quot; unique=&quot;true&quot;\/&gt;       &lt;\/column&gt;       &lt;column name=&quot;creation_time&quot; type=&quot;bigint&quot;&gt;         &lt;constraints nullable=&quot;false&quot;\/&gt;       &lt;\/column&gt;       &lt;column name=&quot;last_access_time&quot; type=&quot;bigint&quot;&gt;         &lt;constraints nullable=&quot;false&quot;\/&gt;       &lt;\/column&gt;       &lt;column name=&quot;max_inactive_interval&quot; type=&quot;int&quot;&gt;         &lt;constraints nullable=&quot;false&quot;\/&gt;       &lt;\/column&gt;       &lt;column name=&quot;expiry_time&quot; type=&quot;bigint&quot;&gt;         &lt;constraints nullable=&quot;false&quot;\/&gt;       &lt;\/column&gt;       &lt;column name=&quot;principal_name&quot; type=&quot;varchar(1024)&quot;\/&gt;     &lt;\/createTable&gt;      &lt;createIndex tableName=&quot;spring_session&quot; indexName=&quot;spring_session_session_id_idx&quot;&gt;       &lt;column name=&quot;session_id&quot;\/&gt;     &lt;\/createIndex&gt;      &lt;createIndex tableName=&quot;spring_session&quot; indexName=&quot;spring_session_expiry_time_idx&quot;&gt;       &lt;column name=&quot;expiry_time&quot;\/&gt;     &lt;\/createIndex&gt;      &lt;createIndex tableName=&quot;spring_session&quot; indexName=&quot;spring_session_principal_name_idx&quot;&gt;       &lt;column name=&quot;principal_name&quot;\/&gt;     &lt;\/createIndex&gt;      &lt;createTable tableName=&quot;spring_session_attributes&quot;&gt;       &lt;column name=&quot;session_primary_id&quot; type=&quot;char(36)&quot;&gt;         &lt;constraints nullable=&quot;false&quot; foreignKeyName=&quot;spring_session_attributes_fk&quot; references=&quot;spring_session(primary_id)&quot; deleteCascade=&quot;true&quot;\/&gt;       &lt;\/column&gt;       &lt;column name=&quot;attribute_name&quot; type=&quot;varchar(1024)&quot;&gt;         &lt;constraints nullable=&quot;false&quot;\/&gt;       &lt;\/column&gt;       &lt;column name=&quot;attribute_bytes&quot; type=&quot;bytea&quot;&gt;         &lt;constraints nullable=&quot;false&quot;\/&gt;       &lt;\/column&gt;     &lt;\/createTable&gt;      &lt;addPrimaryKey tableName=&quot;spring_session_attributes&quot; columnNames=&quot;session_primary_id,attribute_name&quot; constraintName=&quot;spring_session_attributes_pk&quot;\/&gt;      &lt;createIndex tableName=&quot;spring_session_attributes&quot; indexName=&quot;spring_session_attributes_idx&quot;&gt;       &lt;column name=&quot;session_primary_id&quot;\/&gt;     &lt;\/createIndex&gt;      &lt;rollback&gt;       &lt;dropIndex tableName=&quot;spring_session_attributes&quot; indexName=&quot;spring_session_attributes_idx&quot;\/&gt;       &lt;dropIndex tableName=&quot;spring_session_attributes&quot; indexName=&quot;spring_session_attributes_pk&quot;\/&gt;       &lt;dropIndex tableName=&quot;spring_session_attributes&quot; indexName=&quot;spring_session_attributes_fk&quot;\/&gt;       &lt;dropIndex tableName=&quot;spring_session&quot; indexName=&quot;spring_session_principal_name_idx&quot;\/&gt;       &lt;dropIndex tableName=&quot;spring_session&quot; indexName=&quot;spring_session_expiry_time_idx&quot;\/&gt;       &lt;dropIndex tableName=&quot;spring_session&quot; indexName=&quot;spring_session_session_id_idx&quot;\/&gt;       &lt;dropTable tableName=&quot;spring_session_attributes&quot;\/&gt;       &lt;dropTable tableName=&quot;spring_session&quot;\/&gt;     &lt;\/rollback&gt;   &lt;\/changeSet&gt;<\/code><\/pre>\n<p>  <\/p>\n<h3>\u041e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0432\u0430\u0435\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u0435\u0441\u0441\u0438\u044f<\/h3>\n<p>  \u0414\u043b\u044f \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0441\u0435\u0441\u0441\u0438\u0439 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0441\u0432\u043e\u044e \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u0443\u044e \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044e. \u0414\u043b\u044f \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u0432 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0435 \u0431\u044b\u043b\u043e \u0431\u044b \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u043e\u043f\u0438\u0441\u0430\u0442\u044c \u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0435:<\/p>\n<pre><code class=\"xml\">.maximumSessions(1)<\/code><\/pre>\n<p>  \u041e\u0434\u043d\u0430\u043a\u043e \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0434\u0430\u0442\u044c \u0432\u044b\u0431\u043e\u0440 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e(\u0437\u0430\u043a\u0440\u044b\u0442\u044c \u043f\u0440\u043e\u0448\u043b\u0443\u044e \u0441\u0435\u0441\u0441\u0438\u044e \u0438\u043b\u0438 \u043d\u0435 \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0442\u044c \u043d\u043e\u0432\u0443\u044e) \u0438 \u0441\u043e\u043e\u0431\u0449\u0430\u0442\u044c \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u043e\u0440\u0443 \u043e \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f(\u0435\u0441\u043b\u0438 \u043e\u043d \u0432\u044b\u0431\u0440\u0430\u043b \u0437\u0430\u043a\u0440\u044b\u0442\u044c \u0441\u0435\u0441\u0441\u0438\u044e). <\/p>\n<p>  \u041d\u0430\u0448\u0430 \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u0430\u044f \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u044f \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u0441\u043b\u0435\u0434\u043d\u0438\u043a\u043e\u043c.<\/p>\n<p>  <i>ConcurrentSessionControlAuthenticationStrategy<\/i>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0438 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043f\u0440\u0435\u0432\u044b\u0448\u0435\u043d \u043b\u0438 \u043b\u0438\u043c\u0438\u0442 \u0441\u0435\u0441\u0441\u0438\u0439 \u0443 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0438\u043b\u0438 \u043d\u0435\u0442.<\/p>\n<pre><code class=\"java\"> @Slf4j @Component public class ConcurrentSessionStrategy extends ConcurrentSessionControlAuthenticationStrategy {     \/\/\u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0432\u044b\u0431\u043e\u0440\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f(true - \u0437\u0430\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u043f\u0440\u043e\u0448\u043b\u0443\u044e \u0430\u043a\u0442\u0438\u0432\u043d\u0443\u044e \u0441\u0435\u0441\u0441\u0438\u044e)     private static final String FORCE_PARAMETER_NAME = &quot;force&quot;;     \/\/\u0441\u0435\u0440\u0432\u0438\u0441 \u0434\u043b\u044f \u043d\u043e\u0442\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f     private final NotificationService notificationService;     \/\/\u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u0439 \u0441\u0435\u0440\u0432\u0438\u0441 \u0434\u043b\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0441\u0435\u0441\u0441\u0438\u044f\u043c\u0438     private final SessionsManager sessionsManager;      public ConcurrentSessionStrategy(SessionRegistry sessionRegistry, NotificationService notificationService,             SessionsManager sessionsManager) {         super(sessionRegistry);         \/\/\u0442\u0430\u043a\u0443\u044e \u0436\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0443 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u043b\u0438 \u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0435         super.setExceptionIfMaximumExceeded(true);        \/\/\u0432 \u043d\u0430\u0448\u0435\u0439 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0438 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c, \u0447\u0442\u043e \u0430\u043a\u0442\u0438\u0432\u043d\u0430\u044f \u0441\u0435\u0441\u0441\u0438\u044f \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e 1         super.setMaximumSessions(1);         this.notificationService = notificationService;         this.sessionsManager = sessionsManager;     }      @Override     public void onAuthentication(Authentication authentication, HttpServletRequest request,             HttpServletResponse response)             throws SessionAuthenticationException {         try {             \/\/\u043e\u0442\u0434\u0430\u0435\u043c \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u043c\u0435\u0442\u043e\u0434\u0443 \u0441\u0443\u043f\u0435\u0440\u043a\u043b\u0430\u0441\u0441\u0430(\u043e\u043d \u0432\u0435\u0440\u043d\u0435\u0442 SessionAuthenticationException \u0435\u0441\u043b\u0438 \u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0445 \u0441\u0435\u0441\u0441\u0438\u0439 \u0431\u043e\u043b\u044c\u0448\u0435 \u0447\u0435\u043c 1)             super.onAuthentication(authentication, request, response);         } catch (SessionAuthenticationException e) {             log.debug(&quot;onAuthentication#SessionAuthenticationException&quot;);             \/\/\u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0434\u0435\u0442\u0430\u043b\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u0441\u0435\u0441\u0441\u0438\u0438(\u0432 \u043d\u0438\u0445 \u043c\u043e\u0436\u0435\u043c \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0432\u0441\u0435, \u0447\u0442\u043e \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435)             UserDetails userDetails = (UserDetails) authentication.getPrincipal();              String force = request.getParameter(FORCE_PARAMETER_NAME);              \/\/\u0435\u0441\u043b\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0438\u0437 \u0445\u0438\u0434\u0435\u0440\u0430  'force' \u043f\u0443\u0441\u0442\u043e\u0439, \u0437\u043d\u0430\u0447\u0438\u0442, \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0435\u0449\u0435 \u043d\u0435 \u0432\u044b\u0431\u0438\u0440\u0430\u043b             if (StringUtils.isBlank(force)) {                 log.debug(&quot;onAuthentication#Multiple choices when login for user: {}&quot;, userDetails.getUsername());                 throw e;             }             \/\/\u0435\u0441\u043b\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0438\u0437 \u0445\u0438\u0434\u0435\u0440\u0430  'force' = false, \u0437\u043d\u0430\u0447\u0438\u0442, \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0432\u044b\u0431\u0440\u0430\u043b \u0438\u043d\u0432\u0430\u043b\u0438\u0434\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0442\u0435\u043a\u0443\u0449\u0443\u044e \u0441\u0435\u0441\u0441\u0438\u044e(\u043f\u043e \u0441\u0443\u0442\u0438 \u043e\u043d\u0430 \u0438 \u0442\u0430\u043a \u0431\u0443\u0434\u0435\u0442 \u043d\u0435 \u0432\u0430\u043b\u0438\u0434\u043d\u043e\u0439)             if (!Boolean.parseBoolean(force)) {                 log.debug(&quot;onAuthentication#Invalidate current session for user: {}&quot;, userDetails.getUsername());                 throw e;             }              log.debug(&quot;onAuthentication#Invalidate old session for user: {}&quot;, userDetails.getUsername());             \/\/\u0443\u0434\u0430\u043b\u044f\u0435\u043c \u0432\u0441\u0435 \u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0435 \u0441\u0435\u0441\u0441\u0438\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f, \u043a\u0440\u043e\u043c\u0435 \u0442\u0435\u043a\u0443\u0449\u0435\u0439             sessionsManager.deleteSessionExceptCurrentByUser(userDetails.getUsername());             \/\/\u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u044f \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u043e\u0440\u0443(\u0442\u0443\u0442 \u043c\u043e\u0436\u043d\u043e \u0443\u0437\u043d\u0430\u0442\u044c ip \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0438\u043b\u0438 \u0435\u0449\u0435 \u043a\u0430\u043a\u0443\u044e-\u043d\u0438\u0431\u0443\u0434\u044c \u0434\u043e\u043f. \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u0430)             notificationService.notify(request, userDetails);         }     } }<\/code><\/pre>\n<p>  \u041e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u043e\u043f\u0438\u0441\u0430\u0442\u044c \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0445 \u0441\u0435\u0441\u0441\u0438\u0439, \u043a\u0440\u043e\u043c\u0435 \u0442\u0435\u043a\u0443\u0449\u0435\u0439. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0432 \u0438\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 <i>SessionsManager<\/i> \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u043c\u0435\u0442\u043e\u0434 <i>deleteSessionExceptCurrentByUser<\/i>:<\/p>\n<pre><code class=\"java\"> @Service @RequiredArgsConstructor @Slf4j public class SessionsManagerImpl implements SessionsManager {      private final FindByIndexNameSessionRepository sessionRepository;      @Override     public void deleteSessionExceptCurrentByUser(String username) {         log.debug(&quot;deleteSessionExceptCurrent#user: {}&quot;, username);         \/\/\u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c session id \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f         String sessionId = RequestContextHolder.currentRequestAttributes().getSessionId();          \/\/\u0423\u0434\u0430\u043b\u044f\u0435\u043c \u0432\u0441\u0435 \u0441\u0435\u0441\u0441\u0438\u0438 \u043a\u0440\u043e\u043c\u0435 \u0442\u0435\u043a\u0443\u0449\u0435\u0439         sessionRepository.findByPrincipalName(username)                 .keySet().stream()                 .filter(key -&gt; !sessionId.equals(key))                 .forEach(key -&gt; sessionRepository.deleteById((String) key));     }  }<\/code><\/pre>\n<p>  <\/p>\n<h3>\u041e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u043e\u0448\u0438\u0431\u043e\u043a \u043f\u0440\u0438 \u043f\u0440\u0435\u0432\u044b\u0448\u0435\u043d\u0438\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u0441\u0435\u0441\u0441\u0438\u0439<\/h3>\n<p>  \u041a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c, \u043f\u0440\u0438 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 <b>force<\/b>(\u0438\u043b\u0438 \u043a\u043e\u0433\u0434\u0430 \u043e\u043d \u0440\u0430\u0432\u0435\u043d <i>false<\/i>) \u043c\u044b \u0431\u0440\u043e\u0441\u0430\u0435\u043c \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 <b>SessionAuthenticationException<\/b> \u0438\u0437 \u043d\u0430\u0448\u0435\u0439 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0438. \u041c\u044b \u0431\u044b \u0445\u043e\u0442\u0435\u043b\u0438 \u0432\u0435\u0440\u043d\u0443\u0442\u044c \u0444\u0440\u043e\u043d\u0442\u0443 \u043d\u0435 \u043e\u0448\u0438\u0431\u043a\u0443, \u0430 <i>300<\/i> \u0441\u0442\u0430\u0442\u0443\u0441(\u0447\u0442\u043e\u0431\u044b \u0444\u0440\u043e\u043d\u0442 \u0437\u043d\u0430\u043b, \u0447\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e \u0434\u043b\u044f \u0432\u044b\u0431\u043e\u0440\u0430 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f). \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u0447\u0438\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0438 \u0432 <\/p>\n<pre><code class=\"xml\">.sessionAuthenticationFailureHandler(securityErrorHandler)<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"java\">@Component @Slf4j public class SecurityErrorHandler extends SimpleUrlAuthenticationFailureHandler {      @Override     public void onAuthenticationFailure(HttpServletRequest request, HttpServletResponse response,             AuthenticationException exception)             throws IOException, ServletException {         if (!exception.getClass().isAssignableFrom(SessionAuthenticationException.class)) {             super.onAuthenticationFailure(request, response, exception);         }         log.debug(&quot;onAuthenticationFailure#set multiple choices for response&quot;);         response.setStatus(HttpStatus.MULTIPLE_CHOICES.value());     } }<\/code><\/pre>\n<p>  <\/p>\n<h3>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h3>\n<p>  \u0423\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0441\u0435\u0441\u0441\u0438\u044f\u043c\u0438 \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u043d\u0435 \u0442\u0430\u043a\u043e\u0435 \u0441\u0442\u0440\u0430\u0448\u043d\u043e\u0435, \u043a\u0430\u043a \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u043b\u043e\u0441\u044c \u0432 \u043d\u0430\u0447\u0430\u043b\u0435. Spring \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0433\u0438\u0431\u043a\u043e \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0442\u044c \u0441\u0432\u043e\u0438 \u0441\u0442\u0440\u0430\u0442\u0435\u0433\u0438\u0438 \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e. \u0410 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u0447\u0438\u043a\u0430 \u043e\u0448\u0438\u0431\u043e\u043a \u043c\u043e\u0436\u043d\u043e \u0432\u0435\u0440\u043d\u0443\u0442\u044c \u0444\u0440\u043e\u043d\u0442\u0443 \u043b\u044e\u0431\u043e\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0438 \u0441\u0442\u0430\u0442\u0443\u0441.<\/p>\n<p>  \u041d\u0430\u0434\u0435\u044e\u0441\u044c, \u0447\u0442\u043e \u044d\u0442\u0430 \u0441\u0442\u0430\u0442\u044c\u044f \u0431\u0443\u0434\u0435\u043c \u043a\u043e\u043c\u0443-\u043d\u0438\u0431\u0443\u0434\u044c \u043f\u043e\u043b\u0435\u0437\u043d\u0430.<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/513668\/\"> https:\/\/habr.com\/ru\/post\/513668\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/513668\/\">\u041f\u0440\u0438\u0432\u0435\u0442, \u0425\u0430\u0431\u0440.<\/p>\n<p>  \u041f\u0440\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u043c\u043d\u043e\u0433\u043e\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0433\u043e web-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u043b\u043e\u0441\u044c \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0442\u044c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0445 \u0441\u0435\u0441\u0441\u0438\u0439 \u0434\u043b\u044f \u043e\u0434\u043d\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f. \u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0445\u043e\u0447\u0443 \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u0441 \u0412\u0430\u043c\u0438 \u0441\u0432\u043e\u0438 \u0440\u0435\u0448\u0435\u043d\u0438\u0435\u043c.<\/p>\n<p>  \u041a\u043e\u043d\u0442\u0440\u043e\u043b\u044c \u0441\u0435\u0441\u0441\u0438\u0439 \u0430\u043a\u0442\u0443\u0430\u043b\u0435\u043d \u0434\u043b\u044f \u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432. \u0412 \u043d\u0430\u0448\u0435\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0431\u044b\u043b\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0445 \u0441\u0435\u0441\u0441\u0438\u0439 \u0434\u043b\u044f \u043e\u0434\u043d\u043e\u0433\u043e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f. \u041f\u0440\u0438 \u0432\u0445\u043e\u0434\u0435 \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0443 (login) \u0434\u043b\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u0430\u043a\u0442\u0438\u0432\u043d\u0430\u044f \u0441\u0435\u0441\u0441\u0438\u044f. \u041f\u0440\u0438 \u0432\u0445\u043e\u0434\u0435 \u044d\u0442\u043e\u0433\u043e \u0436\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0441 \u0434\u0440\u0443\u0433\u043e\u0433\u043e \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043d\u0435 \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0442\u044c \u043d\u043e\u0432\u0443\u044e \u0441\u0435\u0441\u0441\u0438\u044e, \u0430 \u043f\u0440\u043e\u0438\u043d\u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043e\u0431 \u0443\u0436\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0439 \u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0439 \u0441\u0435\u0441\u0441\u0438\u0438 \u0438 \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0438\u0442\u044c \u0435\u043c\u0443 2 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430:<\/p>\n<ul>\n<li>\u0437\u0430\u043a\u0440\u044b\u0442\u044c \u043f\u0440\u043e\u0448\u043b\u0443\u044e \u0441\u0435\u0441\u0441\u0438\u044e \u0438 \u043e\u0442\u043a\u0440\u044b\u0442\u044c \u043d\u043e\u0432\u0443\u044e<\/li>\n<li>\u043d\u0435 \u0437\u0430\u043a\u0440\u044b\u0432\u0430\u0442\u044c \u0441\u0442\u0430\u0440\u0443\u044e \u0441\u0435\u0441\u0441\u0438\u044e \u0438 \u043d\u0435 \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0442\u044c \u043d\u043e\u0432\u0443\u044e \u0441\u0435\u0441\u0441\u0438\u044e<\/li>\n<\/ul>\n<p>  \u0422\u0430\u043a \u0436\u0435 \u043f\u0440\u0438 \u0437\u0430\u043a\u0440\u044b\u0442\u0438\u0435 \u0441\u0442\u0430\u0440\u043e\u0439 \u0441\u0435\u0441\u0441\u0438\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0443\u0432\u0435\u0434\u043e\u043c\u043b\u0435\u043d\u0438\u0435 \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044e \u043e\u0431 \u044d\u0442\u043e\u043c \u0441\u043e\u0431\u044b\u0442\u0438\u0435.<\/p>\n<p>  \u0418 \u043d\u0443\u0436\u043d\u043e \u0443\u0447\u0435\u0441\u0442\u044c 2 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0438\u043d\u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u0438 \u0441\u0435\u0441\u0441\u0438\u0438:<\/p>\n<ul>\n<li>\u0440\u0430\u0437\u043b\u043e\u0433\u0438\u043d \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f (\u0442.\u0435. \u043d\u0430\u0436\u0430\u0442\u0438\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c \u043a\u043d\u043e\u043f\u043a\u0438 logout)<\/li>\n<li>\u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0440\u0430\u0437\u043b\u043e\u0433\u0438\u043d \u043f\u043e\u0441\u043b\u0435 30 \u043c\u0438\u043d\u0443\u0442 \u0431\u0435\u0437\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f<\/li>\n<\/ul>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-307921","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/307921","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=307921"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/307921\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=307921"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=307921"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=307921"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}