spring-security-oauth2

How to inject WebResponseExceptionTranslator in TokenEndPoint Spring oAuth2

蹲街弑〆低调 提交于 2019-12-06 11:29:40
问题 I am trying to customize the way the Spring Security oAuth TokenEndpoint class handles exceptions. I want to return a more customized JSON response than the DefaultWebResponseExceptionTranslator currently does. I cannot figure out how to inject a custom Translator via XML. Here are my code snippets: spring-security.xml <oauth:authorization-server client-details-service-ref="clientDetails" token-services-ref="tokenServices" user-approval-handler-ref="userApprovalHandler" request-validator-ref=

Spring Oauth2 login - anonymous not allowed?

孤街浪徒 提交于 2019-12-06 09:39:45
Following the manual I achieve to connect to the Facebook graph API and retrieve info from the user. The problem comes when I wanted give access (Login) with Facebook, I got this error: org.springframework.security.authentication.InsufficientAuthenticationException: Authentication is required to obtain an access token (anonymous not allowed) at org.springframework.security.oauth2.client.token.AccessTokenProviderChain.obtainAccessToken(AccessTokenProviderChain.java:88) ~[spring-security-oauth2-2.0.7.RELEASE.jar:na] at org.springframework.security.oauth2.client.OAuth2RestTemplate

Why does filter chain continue if no token is passed in header with OAuth2 spring security?

女生的网名这么多〃 提交于 2019-12-06 08:14:32
I am trying to use OAuth2 with spring security, with the following config xml: <http pattern="/oauth/token" create-session="stateless" authentication-manager-ref="oauthUserAuthenticationManager" xmlns="http://www.springframework.org/schema/security"> <intercept-url pattern="/oauth/token" access="IS_AUTHENTICATED_FULLY"/> <anonymous enabled="false"/> <http-basic entry-point-ref="clientAuthenticationEntryPoint"/> <custom-filter ref="clientCredentialsTokenEndpointFilter" before="BASIC_AUTH_FILTER"/> </http> <http auto-config="true" pattern="/services/rest/**" create-session="never" entry-point

Spring OAuth2 JDBCTokenStore performance and database schema

一曲冷凌霜 提交于 2019-12-06 08:05:27
问题 I use MySQL5.5 + REST(Jersey) + Spring Security + Spring OAuth2. Right now I'm doing performance testing and noticed that org.springframework.security.oauth2.provider.token.store.JdbcTokenStore.readAuthentication method is working really slow.. especialy this part of the method: authentication = jdbcTemplate.queryForObject(selectAccessTokenAuthenticationSql, new RowMapper<OAuth2Authentication>() { public OAuth2Authentication mapRow(ResultSet rs, int rowNum) throws SQLException { return

How to get oAuth2 access token when user call signup rest API in springboot?

夙愿已清 提交于 2019-12-06 07:40:09
currently I am working on Springboot security, its quite new for me. I followed youtube video tutorial Video I am getting oauth2 access_token successfully when I use bellow code snippet:- @SpringBootApplication public class MathifyApplication { @Autowired private PasswordEncoder passwordEncoder; public static void main(String[] args) { SpringApplication.run(MathifyApplication.class, args); } @Autowired public void authenticationManager(AuthenticationManagerBuilder builder, UserRepository repository, UserService service) throws Exception { //Setup a default user if db is empty User students =

RestAssured oAuth2 http status code 401

大憨熊 提交于 2019-12-06 07:30:33
问题 I'm trying to implement integration test using RestAssured library and Spring MVC REST oAuth2 secured endpoint. This is my test: @Test public void testCreateDecision() throws Exception { File createDecisionJsonFile = ResourceUtils.getFile(getClass().getResource("/json/decisions/create-decision.json")); // @formatter:off final String createDecisionRequest = FileUtils.readFileToString(createDecisionJsonFile) .replace("{{name}}", "Test decision name") .replace("{{description}}", "Test decision

Can not resolve FirebaseOptions using latest Firebase SDK dependency

社会主义新天地 提交于 2019-12-06 07:12:32
I am trying to integrate my spring-boot rest api with Firebase by these following tutorial: savicprvoslav I need to verify the userTokenId using Firebase SDK which is generated by a front end application. The above git guide used <dependency> <groupId>com.google.firebase</groupId> <artifactId>firebase-server-sdk</artifactId> <version>3.0.3</version> </dependency> which is already deprecated and suggesting to use latest Firebase SDK [ maven repository ] According to the Firebase SDK integration guide we should use <dependency> <groupId>com.google.firebase</groupId> <artifactId>firebase-admin<

spring-security : How to get OAuth2 userInfo during sso logged in?

岁酱吖の 提交于 2019-12-06 04:53:36
I implement oauth2 sso by using @EnableOAuth2Sso on spring-boot:1.3.0.M1 I want to use my userInfo from my resource server ( http://oauth2_resource_server/me ). So I try to implement my own ResourceServerTokenServices refering to UserInfoTokenServices @Configuration @EnableWebSecurity @EnableOAuth2Sso public class OAuth2Config { @Autowired ResourceServerProperties sso; @Bean public ResourceServerTokenServices userInfoTokenServices() { return new MyTokenService(sso.getUserInfoUri(), sso.getClientId()); } } public class MyTokenService implements ResourceServerTokenServices { @Override public

How to wrap an OAuth2 exception?

三世轮回 提交于 2019-12-06 03:37:33
问题 We have a rest API that uses Spring OAuth2 . After the user is authenticated, all the JSON responses are in the following format: {"code" : 12345, "data" : "..." } But the JSON response for authentication failures is not inline with the above format, as that is handled by Spring. For example in case of incorrect credentials, the clients get HTTP status code 400 with JSON response as follows: {"error": "invalid_grant", "error_description": "Bad credentials" } In case the user account is locked

RequestEnhancer not used for AuthorizationCodeAccessTokenProvider during getRedirectForAuthorization

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-06 03:26:20
问题 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