{"action":"created","issue":{"url":"https://api.github.com/repos/spring-projects/spring-security/issues/4479","repository_url":"https://api.github.com/repos/spring-projects/spring-security","labels_url":"https://api.github.com/repos/spring-projects/spring-security/issues/4479/labels{/name}","comments_url":"https://api.github.com/repos/spring-projects/spring-security/issues/4479/comments","events_url":"https://api.github.com/repos/spring-projects/spring-security/issues/4479/events","html_url":"https://github.com/spring-projects/spring-security/issues/4479","id":246593051,"node_id":"MDU6SXNzdWUyNDY1OTMwNTE=","number":4479,"title":"Spring security does not redirect to success login after authentication success","user":{"login":"pooyaho","id":2623596,"node_id":"MDQ6VXNlcjI2MjM1OTY=","avatar_url":"https://avatars3.githubusercontent.com/u/2623596?v=4","gravatar_id":"","url":"https://api.github.com/users/pooyaho","html_url":"https://github.com/pooyaho","followers_url":"https://api.github.com/users/pooyaho/followers","following_url":"https://api.github.com/users/pooyaho/following{/other_user}","gists_url":"https://api.github.com/users/pooyaho/gists{/gist_id}","starred_url":"https://api.github.com/users/pooyaho/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pooyaho/subscriptions","organizations_url":"https://api.github.com/users/pooyaho/orgs","repos_url":"https://api.github.com/users/pooyaho/repos","events_url":"https://api.github.com/users/pooyaho/events{/privacy}","received_events_url":"https://api.github.com/users/pooyaho/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2017-07-30T16:12:29Z","updated_at":"2018-08-22T14:09:40Z","closed_at":null,"author_association":"NONE","body":"I have a problem in spring security, when I login successfully, the home page that I've set, does not load and the page redirects to the login page. in application logs I've found this two lines after each other :\r\n\r\n    AuditEvent [timestamp=Sun Jul 30 16:45:40 IRDT 2017, principal=pooya, type=AUTHENTICATION_SUCCESS, data={details=org.springframework.security.web.authentication.WebAuthenticationDetails@957e: RemoteIpAddress: 127.0.0.1; SessionId: null}]\r\n\r\n    AuditEvent [timestamp=Sun Jul 30 16:45:41 IRDT 2017, principal=anonymousUser, type=AUTHORIZATION_FAILURE, data={details=org.springframework.security.web.authentication.WebAuthenticationDetails@957e: RemoteIpAddress: 127.0.0.1; SessionId: null, type=org.springframework.security.access.AccessDeniedException, message=Access is denied}]\r\n\r\nThe user information is :\r\n\r\n    username:pooya\r\n    role:ROLE_ADMIN\r\n    \r\nand this is my security configuration:\r\n\r\n\r\n    @Configuration\r\n    @EnableGlobalMethodSecurity(prePostEnabled = true)\r\n    @EnableWebSecurity\r\n    public class SecurityConfiguration extends WebSecurityConfigurerAdapter {\r\n\r\n        @Autowired\r\n        private TypeScanner typeScanner;\r\n   \r\n        @Bean\r\n        public Object userRestService() {\r\n            Set<Class<? extends AbstractUserRestService>> subTypesOf = typeScanner.getSubTypesOf(AbstractUserRestService.class);\r\n            if (subTypesOf.size() <= 1) {\r\n                return new UserRestService();\r\n            }\r\n            return null;\r\n        }\r\n\r\n        @Bean\r\n        public Object userLoginController() {\r\n            Set<Class<? extends AbstractLoginController>> subTypesOf = typeScanner.getSubTypesOf(AbstractLoginController.class);\r\n            if (subTypesOf.size() <= 1) {\r\n                return new UserLoginController();\r\n            }\r\n            return null;\r\n        }\r\n\r\n        @Override\r\n        protected void configure(HttpSecurity http) throws Exception {\r\n            http.authorizeRequests()\r\n                    .antMatchers(\r\n                            \"/login**\",\r\n                            \"/resources/**\",\r\n                            \"/app/resources/**\",\r\n                            \"/vendors/**\"\r\n                    )\r\n                    .permitAll()\r\n                    .anyRequest()\r\n                    .hasRole(\"ADMIN\")\r\n                    .and()\r\n                    .formLogin()\r\n                    .failureUrl(\"/login.html?error\")\r\n                    .loginProcessingUrl(\"/login\")\r\n                    .loginPage(\"/login.html\")\r\n                    .passwordParameter(\"password\")\r\n                    .usernameParameter(\"username\")\r\n                    .defaultSuccessUrl(\"/#\",true)\r\n                    .and()\r\n                    .logout()\r\n                    .logoutUrl(\"/logout\")\r\n                    .and()\r\n                    .csrf()\r\n                    .disable()\r\n                    .sessionManagement()\r\n                    .maximumSessions(1000)\r\n                    .expiredUrl(\"/logout?expired\");\r\n\r\n        }\r\n \r\n        @Bean\r\n        public PasswordEncoder passwordEncoder() {\r\n            return new BCryptPasswordEncoder(10);\r\n        }\r\n\r\n        @Bean\r\n        public DaoAuthenticationProvider authProvider() {\r\n            DaoAuthenticationProvider authProvider = new DaoAuthenticationProvider();\r\n            authProvider.setUserDetailsService(securityProvider());\r\n            authProvider.setPasswordEncoder(passwordEncoder());\r\n            return authProvider;\r\n        }\r\n\r\n        @Bean\r\n        public AbstractUserSecurityProvider securityProvider(){\r\n            return new AbstractUserSecurityProvider(){\r\n\r\n            };\r\n        }\r\n\r\n\r\n        @Override\r\n        protected void configure(AuthenticationManagerBuilder auth) throws Exception {\r\n            auth.authenticationProvider(authProvider());\r\n        }\r\n\r\n    }\r\n\r\nand this is my user detail service:\r\n\r\n     public abstract class AbstractUserSecurityProvider<S extends AbstractUserService> implements UserDetailsService {\r\n\r\n        @Autowired\r\n        private S service;\r\n        @Override\r\n        public UserDetails loadUserByUsername(String s) throws UsernameNotFoundException {\r\n    \r\n            User user = new User(s, \"\", Collections.EMPTY_LIST);\r\n            user.eraseCredentials();\r\n    \r\n            UserEntity userEntity = service.findByUsername(user.getUsername());\r\n            if(userEntity == null){\r\n                throw new UsernameNotFoundException(\"Invalid username/password.\");\r\n            }\r\n            User result = basicTransformer.convert(userEntity, User.class);\r\n            return new User(result.getUsername().trim(), result.getPassword().trim(), result.getAuthorities());\r\n        }\r\n    \r\n    }"},"comment":{"url":"https://api.github.com/repos/spring-projects/spring-security/issues/comments/415045064","html_url":"https://github.com/spring-projects/spring-security/issues/4479#issuecomment-415045064","issue_url":"https://api.github.com/repos/spring-projects/spring-security/issues/4479","id":415045064,"node_id":"MDEyOklzc3VlQ29tbWVudDQxNTA0NTA2NA==","user":{"login":"rwinch","id":362503,"node_id":"MDQ6VXNlcjM2MjUwMw==","avatar_url":"https://avatars0.githubusercontent.com/u/362503?v=4","gravatar_id":"","url":"https://api.github.com/users/rwinch","html_url":"https://github.com/rwinch","followers_url":"https://api.github.com/users/rwinch/followers","following_url":"https://api.github.com/users/rwinch/following{/other_user}","gists_url":"https://api.github.com/users/rwinch/gists{/gist_id}","starred_url":"https://api.github.com/users/rwinch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rwinch/subscriptions","organizations_url":"https://api.github.com/users/rwinch/orgs","repos_url":"https://api.github.com/users/rwinch/repos","events_url":"https://api.github.com/users/rwinch/events{/privacy}","received_events_url":"https://api.github.com/users/rwinch/received_events","type":"User","site_admin":false},"created_at":"2018-08-22T14:09:39Z","updated_at":"2018-08-22T14:09:39Z","author_association":"MEMBER","body":"Can anyone reproduce the issue without using JHipster? If so, please log the HTTP Request / Response of requesting the log in page, submitting the credentials, the result of submitting the credentials and any subsequent redirects."}}
{"actor":{"display_login":"rwinch"}}