spring-security-oauth2

Override UserAuthenticationConverter for JWT OAuth Tokens

你说的曾经没有我的故事 提交于 2019-12-22 11:04:05
问题 I am trying to create a spring resource server secured with oauth2. I am using auth0 for my auth2 service, and I have an api and client configured with scopes. I have a resource server that mostly works. It is secured, and I can use @EnableGlobalMethodSecurity and @PreAuthorize("#oauth2.hasScope('profile:read')") to limit access to tokens with that scope. However, when I try to get the Principal or the OAuth2Authentication they are both null. I've configured the resource server to use the JWK

Override UserAuthenticationConverter for JWT OAuth Tokens

天大地大妈咪最大 提交于 2019-12-22 11:01:12
问题 I am trying to create a spring resource server secured with oauth2. I am using auth0 for my auth2 service, and I have an api and client configured with scopes. I have a resource server that mostly works. It is secured, and I can use @EnableGlobalMethodSecurity and @PreAuthorize("#oauth2.hasScope('profile:read')") to limit access to tokens with that scope. However, when I try to get the Principal or the OAuth2Authentication they are both null. I've configured the resource server to use the JWK

How to allow a User only access their own data in Spring Boot / Spring Security?

大城市里の小女人 提交于 2019-12-22 09:23:21
问题 I have some rest api like this: /users/{user_id} /users/{user_id}/orders /users/{user_id}/orders/{order_id} How I must secure them? every user must see only her/his data, But admin can see all of them. How & What I must implement in Spring Security that User by Id == 1 can't see data of user by Id == 2 and vice versa, expect users by role admin that can see all? Do I check before every method User Id in session is equail with user_id param passed to api? is there a better way? p.s: I use JWT

Spring Boot - Using JWT, OAuth, and Separate Resource and Auth Servers

故事扮演 提交于 2019-12-22 08:34:12
问题 I am attempting to build a Spring application that uses JWT tokens and the OAuth2 protocol. I have the Authentication Server running thanks to this tutorial. However, I am struggling with getting the Resource Server to function properly. From following the article, and thanks to a response to a prior question, this is my current attempt: Security config for Resource Server: @Configuration @EnableWebSecurity @EnableGlobalMethodSecurity(prePostEnabled = true) public class SecurityConfig extends

Spring Security OAuth2 AngularJS | Logout Flow

有些话、适合烂在心里 提交于 2019-12-22 06:39:43
问题 Referring to the logout flow in oauth2 spring-guides project, once the the user has authenticated using user/password for the first time, the credentials are not asked next time after logout. How can I ensure that username/password are asked every time after a logout. This is what I am trying to implement:- OAuth2 server issuing JWT token using "authorization_code" grant type with auto approval. This has html/angularjs form to collect username/password. UI/Webfront - Uses @EnableSSO. ALL its

Spring Boot OAuth2 not working properly on version 1.4.1

ぃ、小莉子 提交于 2019-12-22 04:38:05
问题 I was using Spring Boot 1.4.0 with Spring OAuth2. When I requested a token, the server response was: { "access_token": "93f8693a-22d2-4139-a4ea-d787f2630f04", "token_type": "bearer", "refresh_token": "2800ea24-bb4a-4a01-ba87-2d114c1a2235", "expires_in": 899, "scope": "read write" } When I updated my project to Spring Boot 1.4.1, the server response became { "error": "invalid_client", "error_description": "Bad client credentials" } What was changed from version 1.4.0 to 1.4.1 ? And what should

Attach OAuth2 login to existing users in a Spring Boot application

独自空忆成欢 提交于 2019-12-22 01:17:41
问题 I have a Spring Boot application that is "invitation only". Ie. users are sent a signup link and there is no "Sign up" functionality. This works fine and users log on with their username and password. I would like to allow logon with FaceBook and Google using OAuth2 as a supplementary logon method. This would involve mapping the existing users to their social account in some way. The users and their passwords are stored in a MySQL database. I have found a number of articles on OAuth2 and

Using WebSecurityConfigurerAdapter with Spring OAuth2 and user-info-uri

大憨熊 提交于 2019-12-21 23:01:09
问题 I have created an Authorization service as follows @SpringBootApplication @EnableAuthorizationServer public class AuthorizationApplication { ... } With this application.properties . server.port=9000 security.oauth2.client.client-id=monederobingo security.oauth2.client.client-secret=monederobingosecret security.oauth2.client.authorized-grant-types=authorization_code,refresh_token,password,client_credentials security.oauth2.client.scope=company,client Then, in a separate spring boot project I

Spring @FeignClient , OAuth2 and @Scheduled not working

无人久伴 提交于 2019-12-21 20:56:45
问题 Added OAuth2FeignRequestInterceptor to handle OAuth2 @FeignClient request and I'm now seeing the following exception: *org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'scopedTarget.oauth2ClientContext': Scope 'session' is not active for the current thread; consider defining a scoped proxy for this bean if you intend to refer to it from a singleton; nested exception is java.lang.IllegalStateException: No thread-bound request found: Are you referring to

Implement Spring OAuth2 using JDBC with JWT and customize existing grant flows using XML based configuration

心不动则不痛 提交于 2019-12-21 03:00:52
问题 I started to use Spring OAuth2 and in the process, I struggled to find relevant tutorials and content mostly because of the following I did not want to use Spring Boot I did not want to use Java configs rather xml configuration I needed to customize Spring OAuth2 grant flows and other features for our specific needs I needed to disable some grant flows I needed to Spring OAuth2 to use custom Users and Roles I needed to use store oauth_client details in a custom database tab Other stuff I have