spring-security-oauth2

Spring Boot OAuth 2.0 UserDetails user not found

一笑奈何 提交于 2019-12-21 01:59:11
问题 I am new to Spring Boot, and I am trying to configure OAuth 2.0. The problem I am having at this moment is that I keep getting the following message when I attempt to request for an access token: { "error": "invalid_grant", "error_description": "Bad credentials" } The error message in the Spring Boot console says that the user cannot be found. : Authentication attempt using org.springframework.security.authentication.dao.DaoAuthenticationProvider : User 'stromero' not found : Returning cached

Need to create oAuth2 token manually without password

孤街醉人 提交于 2019-12-21 00:38:07
问题 I have implemented oAuth2 with spring security and it is working fine for me. But Now I want to create user token from back-end manually without password. Because I have only username of user. Can any one help me. 回答1: Got Answer!!! HashMap<String, String> authorizationParameters = new HashMap<String, String>(); authorizationParameters.put("scope", "read"); authorizationParameters.put("username", "user"); authorizationParameters.put("client_id", "client_id"); authorizationParameters.put(

Spring-boot oauth2 splitting authorization server and resource server

十年热恋 提交于 2019-12-20 14:25:05
问题 Im trying to split the resource server from the authorization server in spring-boot. I have two different applications that i'm running separately. In the authorization server i can get the bearer token from oauth/token but when i'm trying to get access to the resource(sending the token in header) i'm getting an invalid token error. My intention is to use the InMemoryTokenStore and the bearer token. Can anyone tell me what is wrong in my code? Authorization Server: @SpringBootApplication

Extract Currently Logged in User information from JWT token using Spring Security

女生的网名这么多〃 提交于 2019-12-20 12:26:34
问题 I have implemented JWT and LDAP Authentication using Spring Security Oauth2. It seems to be working fine and I can login with my LDAP credentials. Now, there is one requirement that I need to use the currently logged in user info to save details in database - specifically like when that user add/update a new record. I tried to get that using Spring security way using SecurityContextHolder.getContext().getAuthentication().getDetails() but it doesn't return all that information which I have in

Spring Boot 1.3.3 @EnableResourceServer and @EnableOAuth2Sso at the same time

南楼画角 提交于 2019-12-20 11:55:11
问题 I want my server be a ResourceServer, which can accept a Bearer Access token However, If such token doesn't exist, I want to use the OAuth2Server to authenticate my user. I try to do like: @Configuration @EnableOAuth2Sso @EnableResourceServer public class SecurityConfiguration extends WebSecurityConfigurerAdapter{ @Override protected void configure(HttpSecurity http) throws Exception { http.authorizeRequests().anyRequest().authenticated(); } } However, in this case, only the

Spring security with Oauth2 or Http-Basic authentication for the same resource

醉酒当歌 提交于 2019-12-20 08:35:45
问题 I'm attempting to implement an API with resources that are protected by either Oauth2 OR Http-Basic authentication. When I load the WebSecurityConfigurerAdapter which applies http-basic authentication to the resource first, Oauth2 token authentication is not accepted. And vice-versa. Example configurations: This applies http-basic authentication to all /user/** resources @Configuration @EnableWebMvcSecurity public class WebSecurityConfig extends WebSecurityConfigurerAdapter { private LoginApi

Does JpaTokenStore have any downsides when compared to JdbcTokenStore for spring security oauth

妖精的绣舞 提交于 2019-12-19 21:52:50
问题 I currently use Jpa via Hibernate in my application. Since spring security oauth2 provides JdbcTokenStore, I started using it. But the problem with that is, I cannot use cache (which all my entities in the application currently share). It hits the database in a separate flow. I am thinking implementing JpaTokenStore thats backed by Jpa & leverage the cache advantages that comes with it. Did anyone try implementing this/see any downsides using this approach? 回答1: There is nothing stopping you

Spring Security OAuth2 with custom TokenGranter in version 2.0.+

拈花ヽ惹草 提交于 2019-12-19 16:37:00
问题 In previous versions of OAuth2 it was possible to add a custom token granter by adding it to the xml configuration in the <authorization-server> element. I wonder how I could extend the authorization server with Java Config using a AuthorizationServerConfigurerAdapter, without losing the default configuration, which contains the implicit, client credentials, refresh token and authorization code grant types. First attempt was using creating the TokenGranter with @Component: @Component(

What does resourceId mean in OAuth 2.0 with Spring Security

时间秒杀一切 提交于 2019-12-19 12:51:12
问题 OAuth2ProtectedResourceFilter in org.springframework.security.oauth2.provider.filter: Collection<String> resourceIds = auth.getClientAuthentication().getResourceIds(); if (resourceIds!=null && !resourceIds.isEmpty() && !resourceIds.contains(resourceId)) { throw new InvalidTokenException("Invalid token does not contain resource id ("+resourceId+"): " + token); } I think it is not useful. What does this code check for? 回答1: Based on what I've gathered, it is the id of the resource service. It

spring-security-oauth2 2.0.7 refresh token UserDetailsService Configuration - UserDetailsService is required

徘徊边缘 提交于 2019-12-18 21:49:41
问题 I would have one question regarding the configuration of spring-security-oauth2 2.0.7 please. I am doing the Authentication using LDAP via a GlobalAuthenticationConfigurerAdapter: @SpringBootApplication @Controller @SessionAttributes("authorizationRequest") public class AuthorizationServer extends WebMvcConfigurerAdapter { public static void main(String[] args) { SpringApplication.run(AuthorizationServer.class, args); } @Override public void addViewControllers(ViewControllerRegistry registry)