spring-security-oauth2

Moving to Spring Boot 1.5.1 and OAuth2 + JWT token - Error 401 Unauthorized

♀尐吖头ヾ 提交于 2019-12-04 12:36:42
I'm trying to move my project to Spring Boot 1.5.1 and right now my configuration of Outh2 + JWT tokens stopped working. Right now I receive 401 error while performing a following test: RestTemplate restTemplate = new RestTemplate(); CreateDecisionRequest decisionRequest = new CreateDecisionRequest(name, description, url, imageUrl, parentDecisionId, tenantId); HttpHeaders headers = new HttpHeaders(); headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON)); headers.add(SecurityTestUtils.AUTH_HEADER_NAME, "Bearer " + accessToken); HttpEntity<CreateDecisionRequest> requestEntity = new

Spring Cloud Zuul API gateway doesn't forward JWT token for stateless sessions

寵の児 提交于 2019-12-04 10:53:58
I am trying to implement Microservices architecture backend using Spring Boot 1.5.6.RELEASE and Spring Cloud Dalston.SR3 that would be consumed by mobile/web endpoints. API Gateway application @SpringBootApplicatio @EnableEurekaClient @EnableZuulProxy public class GatewayApplication { public static void main(String[] args) { SpringApplication.run(GatewayApplication.class, args); } } API security @Configuration @EnableWebSecurity @Order(ManagementServerProperties.ACCESS_OVERRIDE_ORDER) @EnableOAuth2Sso public class WebSecurityConfiguration extends WebSecurityConfigurerAdapter { @Override public

How do /oauth/authorize and /oauth/token interact in Spring OAuth?

烈酒焚心 提交于 2019-12-04 10:42:02
问题 I am doing an in-depth study of Spring OAuth, and I found some conflicting information. Can someone please clarify? Specifically, this tutorial states that the /oauth/token endpoint handles the username and password before granting a refresh token to the client app. By contrast, the Spring OAuth Developer Guide mentions the /oauth/authorize and /oauth/token endpoints, but yet does not get specific about how they work. Does the /oauth/authorize do 100% of the username/password/nOtherFactors

Adding more then one client to the Spring OAuth2 Auth Server

你离开我真会死。 提交于 2019-12-04 09:24:04
问题 I have Spring OAuth Authorization server and I want to add support for more then one client(id). I configured clients like this: clients .inMemory().withClient(client).secret(clientSecret) .resourceIds(resourceId) .authorizedGrantTypes("client_credentials", "password", "refresh_token", "implicit", "authorization_code") .authorities("ROLE_USER") .scopes("read", "write") .autoApprove(true) .and() .inMemory().withClient("acme").secret("acmesecret") .resourceIds(resourceId) .authorizedGrantTypes(

Revoke JWT Oauth2 Refresh Token

冷暖自知 提交于 2019-12-04 09:10:59
问题 I am trying to find a way to revoke Oauth2 JWT Refresh Token with vanilla Spring implementation and JwtTokenStore. First: can somebody confirm that there is no API similar to /oauth/token that allows me to revoke a refresh token? I wanted to add a custom API that would delete the refresh token along the folowing lines: OAuth2RefreshToken oauth2RefreshToken=tokenStore.readRefreshToken(refreshToken); tokenStore.removeRefreshToken(oauth2RefreshToken); Now, looking at the JwtTokenStore, I noticed

RequestEnhancer not used for AuthorizationCodeAccessTokenProvider during getRedirectForAuthorization

孤街醉人 提交于 2019-12-04 08:23:56
What I'm trying to do is to add an extra parameter openid.realm to my authorization request. My problem is very similar to https://github.com/spring-projects/spring-security-oauth/issues/123 and I tried to follow the outlined to way solve it: // Create an enhancer that adds openid.realm DefaultRequestEnhancer enhancer = new DefaultRequestEnhancer(); enhancer.setParameterIncludes(Arrays.asList("openid.realm")); // Create tokenprovider that use the enhancer AuthorizationCodeAccessTokenProvider tokenProvider = new AuthorizationCodeAccessTokenProvider(); tokenProvider

Correctly configure spring security oauth2

狂风中的少年 提交于 2019-12-04 06:09:01
问题 I'm trying to configure an authorization server with spring-security-oauth2 and jwt. My main : @SpringBootApplication @EnableResourceServer public class Application { public static void main(String[] args) { SpringApplication.run(Application.class, args); } } My Security config : @Configuration @EnableGlobalMethodSecurity(prePostEnabled = true) public class SecurityConfig extends WebSecurityConfigurerAdapter { @Override @Bean public AuthenticationManager authenticationManagerBean() throws

How can I use an OAuth2RestTemplate in a scheduled task?

亡梦爱人 提交于 2019-12-04 05:08:58
I have two resource servers: one that has an API for emailing notifications and one that runs scheduled tasks. When a scheduled task starts, I want to call out to the email service to notify users that their task is starting. Both services use OAuth2 for authentication. The scheduled task service has client credentials set up so that it can get an access token by presenting it's client credentials: To accomplish this, I'm using Spring Boot with Spring Security OAuth2. The Task service has an OAuth2RestTemplate to make the call out to the Email service. When the scheduled task fires up and

Spring Boot Security OAuth2 with Form Login

不羁的心 提交于 2019-12-04 04:43:35
I am following Part V of Getting Started with Spring Boot Security to secure my RESTful microservices. The simple flow that I intend to implement is:- If unauthenticated, the user is redirected to a custom login page at say '/login'. User provides his credentials. On successful authentication user is redirected to home page ('/home'). I should be able to access my REST endpoint (behind a Zuul Proxy Server) after providing the access token in the request. The Getting Started guide in the above mentioned link uses Basic Auth and dummy user configured in .properties or .yml file. This is how I

How to secure a MVC application with OAuth2 using Spring?

大兔子大兔子 提交于 2019-12-04 00:26:32
问题 Sorry, my English. I have an application I can login in the usual way. @Configuration @EnableWebSecurity public class LoginSecurityConfig extends WebSecurityConfigurerAdapter { @Override protected void configure(AuthenticationManagerBuilder auth) throws Exception { System.out.println("LoginSecurityConfig :: configure"); auth.jdbcAuthentication().dataSource( getDataSource() ) .passwordEncoder( new BCryptPasswordEncoder(16) ) .usersByUsernameQuery( "select user_name as username,password,enabled