spring-oauth2

Change Authorities/Roles of Authenticated User from SSO in Spring OAuth2 Client

被刻印的时光 ゝ 提交于 2019-12-11 05:49:18
问题 I am trying to authenticate a user from facebook and store it's username and provide custom permission to subset of users who will be admin for my application. My question is, How do I provide custom roles like "Admin" to the authenticated and authorize it in Oauth2Client. @Configuration class WebSecurityConfiguration extends GlobalAuthenticationConfigurerAdapter { @Autowired UserRepository userRepository; @Override public void init(AuthenticationManagerBuilder auth) throws Exception { auth

Spring oauth2 hasRole access denied

Deadly 提交于 2019-12-10 17:34:56
问题 I am really new to OAuth2 and trying to build one server in roles auth.server for authorizing users and one keeping a protected resource... I've got issues to secure with the ResourceServerConfigurerAdapter. It seems like he is ignoring all it's roles fetching form userInfoUrl... so here the code: AuthServer @SpringBootApplication @EnableAuthorizationServer @EnableResourceServer @RestController public class Oa2AuthServerApplication { @RequestMapping("/user") public Principal user(Principal

Getting 404 after oauth2 authentication success and an anonymous token

☆樱花仙子☆ 提交于 2019-12-10 15:25:40
问题 I am using oauth2 with springboot 1.5.6.RELEASE and I am using jdbc authentication with oauth2. I added the property: security.oauth2.resource.filter-order = 3 1- AuthorizationServerConfigurerAdapter: @Configuration @EnableAuthorizationServer public class OAuth2Config extends AuthorizationServerConfigurerAdapter { @Autowired @Qualifier("authenticationManagerBean") @Lazy private AuthenticationManager authenticationManager; @Autowired private Environment env; @Override public void configure

Authentication is required to obtain an access token (anonymous not allowed)

天涯浪子 提交于 2019-12-10 12:54:03
问题 I try to modify existing example - Tonr2 and Sparklr2. Also I viewed this tutorial based on Spring Boot Spring Boot OAuth2. I try to build application like in Tonr2 example but without first login (on tonr2). I just need one Authentication on Sparklr2 side. I do this: @Bean public OAuth2ProtectedResourceDetails sparklr() { AuthorizationCodeResourceDetails details = new AuthorizationCodeResourceDetails(); details.setId("sparklr/tonr"); details.setClientId("tonr"); details.setTokenName("oauth

Spring Boot OAuth2 implicit flow + form login and Request method 'POST' not supported error

不想你离开。 提交于 2019-12-10 10:33:23
问题 In my Spring Boot application I'm trying to configure OAuth2 implicit flow. For this purpose I'm trying to configure custom login form. This is my config: @Configuration public class WebMvcConfig extends WebMvcConfigurerAdapter { @Override public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) { configurer.enable(); } @Override public void addViewControllers(ViewControllerRegistry registry) { registry.addViewController("/").setViewName("index"); registry

Official Spring security oauth2 example doesn't work because of cookies clashing(authorization code mechanism)

老子叫甜甜 提交于 2019-12-09 14:03:41
问题 According the tutorial Spring Boot and OAuth2 I have following project structure: And following source code: SocialApplication.class: @SpringBootApplication @RestController @EnableOAuth2Client @EnableAuthorizationServer @Order(200) public class SocialApplication extends WebSecurityConfigurerAdapter { @Autowired OAuth2ClientContext oauth2ClientContext; @RequestMapping({ "/user", "/me" }) public Map<String, String> user(Principal principal) { Map<String, String> map = new LinkedHashMap<>(); map

use spring cloud gateway with oauth2

我是研究僧i 提交于 2019-12-09 02:49:38
问题 i face a problem when i using spring cloud gateway is if any dependency call spring-boot-starter-tomcat directly or recursively it will not work because it will start the embedded tomcat server not the netty server that spring cloud gateway use i started to solve this problem by excluding this dependency <exclusions> <exclusion> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-tomcat</artifactId> </exclusion> </exclusions> the spring cloud gateway worked

CORS semi working between Angular App and Spring backend

丶灬走出姿态 提交于 2019-12-08 09:48:49
问题 Following this Spring tutorial I've added the following bean to my configuration logic. Note that I am using Spring Boot. If you are using Spring Boot, it is recommended to just declare a WebMvcConfigurer bean as following: @Bean public WebMvcConfigurer corsConfigurer() { return new WebMvcConfigurer() { @Override public void addCorsMappings(CorsRegistry registry) { registry.addMapping("/**") // Just slightly modified .allowedMethods("HEAD", "GET", "PUT", "POST", "DELETE", "PATCH", "OPTIONS")

Spring Oauth2 JDBC Client configuration add same client multiple times

给你一囗甜甜゛ 提交于 2019-12-08 04:02:10
问题 I am configuring an OAuth2 authorization server in a Spring project. Here is configuration. @Override public void configure(ClientDetailsServiceConfigurer clients) throws Exception { clients.jdbc(dataSource) .withClient("user") .secret("secret") .scopes("read", "write") .autoApprove(true) .authorizedGrantTypes( "password","authorization_code", "refresh_token") } The problem is that each time I restart application, it tries to add those clients in database, which I don't want. I am getting the

spring boot OAuth2 role based authorization

被刻印的时光 ゝ 提交于 2019-12-07 00:39:45
问题 We have a dedicated authorization server extending AuthorizationServerConfigurerAdapter, where we have set authorities overriding void configure(ClientDetailsServiceConfigurer clients) method. @Configuration @EnableAuthorizationServer protected static class OAuth2Config extends AuthorizationServerConfigurerAdapter { @Value('${oauth.clientId}') private String clientId @Value('${oauth.secret:}') private String secret @Value('${oauth.resourceId}') private String resourceId @Autowired @Qualifier(