org.springframework.social.security.SpringSocialConfigurer Java Examples

The following examples show how to use org.springframework.social.security.SpringSocialConfigurer. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SecurityConfiguration.java    From blog-social-login-with-spring-social with Apache License 2.0 6 votes vote down vote up
@Override
protected void configure(HttpSecurity http) throws Exception {

    http
        .formLogin()
            .loginPage("/login")
            .loginProcessingUrl("/login/authenticate")
            .failureUrl("/login?param.error=bad_credentials")
            .permitAll()
    .and()
        .logout()
            .logoutUrl("/logout")
            .deleteCookies("JSESSIONID")
    .and()
        .authorizeRequests()
            .antMatchers("/favicon.ico", "/static-resources/**").permitAll()
            .antMatchers("/**").authenticated()
    .and()
        .rememberMe()
    .and()
        .apply(new SpringSocialConfigurer()
            .postLoginUrl("/")
            .alwaysUsePostLoginUrl(true));
}
 
Example #2
Source File: SocialWebAutoConfiguration.java    From cola with MIT License 5 votes vote down vote up
/**
 * 社交登录配类
 *
 * @return
 */
@Bean
public SpringSocialConfigurer socialConfigurer(SocialProperties socialProperties) {
	SocialSecurityConfigurer configurer = new SocialSecurityConfigurer(socialProperties.getLoginProcessUrl());
	configurer.signupUrl(socialProperties.getSignupUrl());
	return configurer;
}
 
Example #3
Source File: SocialConfig.java    From pre with GNU General Public License v3.0 5 votes vote down vote up
@Bean
    public SpringSocialConfigurer mySpringSocialSecurityConfig() {
        String filterProcessesUrl = preSecurityProperties.getSocial().getFilterProcessesUrl();
        PreSpringSocialConfigurer configurer = new PreSpringSocialConfigurer(filterProcessesUrl);
        //1、认证失败跳转注册页面
        // 跳转到signUp controller,从session中获取用户信息并通过生成的uuid保存到redis里面,然后跳转bind页面
        // 前端绑定后发送用户信息到后台bind controller,1)保存到自己系统用户;2)保存一份userconnection表数据,Spring Social通过这里面表数据进行判断是否绑定
        configurer.signupUrl("/signUp");
        //2、认证成功跳转后处理器,跳转带token的成功页面
//        configurer.setSocialAuthenticationFilterPostProcessor(socialAuthenticationFilterPostProcessor);

        return configurer;
    }
 
Example #4
Source File: SocialConfig.java    From paascloud-master with Apache License 2.0 5 votes vote down vote up
/**
 * 社交登录配置类,供浏览器或app模块引入设计登录配置用。
 *
 * @return spring social configurer
 */
@Bean
public SpringSocialConfigurer pcSocialSecurityConfig() {
	String filterProcessesUrl = securityProperties.getSocial().getFilterProcessesUrl();
	PcSpringSocialConfigurer configurer = new PcSpringSocialConfigurer(filterProcessesUrl);
	configurer.signupUrl(securityProperties.getBrowser().getSignUpUrl());
	configurer.setSocialAuthenticationFilterPostProcessor(socialAuthenticationFilterPostProcessor);
	return configurer;
}
 
Example #5
Source File: FebsSocialConfig.java    From FEBS-Security with Apache License 2.0 5 votes vote down vote up
@Bean
public SpringSocialConfigurer febsSocialSecurityConfig(FebsSecurityProperties securityProperties) {
    FebsSpringSocialConfigurer febsSpringSocialConfigurer = new FebsSpringSocialConfigurer(securityProperties.getSocial().getFilterProcessesUrl());
    febsSpringSocialConfigurer.setFebsSecurityProperties(securityProperties);
    febsSpringSocialConfigurer.setFebsAuthenticationSucessHandler(febsAuthenticationSucessHandler);
    return febsSpringSocialConfigurer;
}
 
Example #6
Source File: StatelessAuthenticationSecurityConfig.java    From boot-stateless-social with MIT License 5 votes vote down vote up
@Override
protected void configure(HttpSecurity http) throws Exception {
	// Set a custom successHandler on the SocialAuthenticationFilter
	final SpringSocialConfigurer socialConfigurer = new SpringSocialConfigurer();
	socialConfigurer.addObjectPostProcessor(new ObjectPostProcessor<SocialAuthenticationFilter>() {
		@Override
		public <O extends SocialAuthenticationFilter> O postProcess(O socialAuthenticationFilter) {
			socialAuthenticationFilter.setAuthenticationSuccessHandler(socialAuthenticationSuccessHandler);
			return socialAuthenticationFilter;
		}
	});

	http.exceptionHandling().and().anonymous().and().servletApi().and().headers().cacheControl().and()
			.authorizeRequests()

			//allow anonymous font and template requests
			.antMatchers("/").permitAll()
			.antMatchers("/favicon.ico").permitAll()
			.antMatchers("/resources/**").permitAll()

			//allow anonymous calls to social login
			.antMatchers("/auth/**").permitAll()

			//allow anonymous GETs to API
			.antMatchers(HttpMethod.GET, "/api/**").permitAll()

			//defined Admin only API area
			.antMatchers("/admin/**").hasRole("ADMIN")

			//all other request need to be authenticated
			.antMatchers(HttpMethod.GET, "/api/users/current/details").hasRole("USER")
			.anyRequest().hasRole("USER").and()

			// add custom authentication filter for complete stateless JWT based authentication
			.addFilterBefore(statelessAuthenticationFilter, AbstractPreAuthenticatedProcessingFilter.class)

			// apply the configuration from the socialConfigurer (adds the SocialAuthenticationFilter)
			.apply(socialConfigurer.userIdSource(userIdSource));
}
 
Example #7
Source File: SocialWebAutoConfiguration.java    From cola with MIT License 4 votes vote down vote up
@Bean
public SocialChannelSecurityConfigurer socialChannelSecurityConfigurer(SpringSocialConfigurer socialConfigurer,
																	   SocialProperties socialProperties) {
	return new SocialChannelSecurityConfigurer(socialProperties, socialConfigurer);
}
 
Example #8
Source File: SocialChannelSecurityConfigurer.java    From cola with MIT License 4 votes vote down vote up
public SocialChannelSecurityConfigurer(SocialProperties socialProperties, SpringSocialConfigurer springSocialConfigurer) {
	super(springSocialConfigurer);
	this.socialProperties = socialProperties;
}