Setting access token to cookie in Spring Security OAuth2 - spring

I would like to write OAuth2 access token to a cookie instead of writing to response. Since my OAuth request uses /oauth/token endpoint defined in TokenEndpoint.java of Spring Security OAuth2 module, the token is always written to response.
How can I remove this token from response and set to cookie? Should I implement my own TokenEndpoint?

Related

Spring Boot SAML SSO custom JWT token refresh

I have followed below URL to configure SAML SSO to the existing spring boot application, which already have User name - password authentication and JWT authorization for APIs.
https://github.com/pateluday07/saml-sso-and-slo-demo-idp-azure-sp-springboot
Also in onSSOSuccessHandler() I have generated custom JWT token and returned to the Angular front end as cookie. The JWT token expiry set for 1 Hour. The spring boot application is configured with stateless session policy.
On JWT token expiry how we can refresh the token by validating the SSO session? Do we have to call /saml/login endpoint on token expiry?

OAuth in Spring security question to get userInfo

My application has frontend build with angular and backend build with spring boot, and I use openam by Forgerock as an authentication server. I got the access_token in frontend and pass this access_token to backend through Bearer authentication, But now I have to check if the token is valid in backend by calling /userInfo endpoint. My question is how to config in spring boot to call this endpoint everytime when get the request? Thanks
I may case I didn't had any explicit configuration for access token. You just have to call end points and the tokens will be stored in the header for authentication. Though you can set the timer for it.

Spring Security - SPA OpenID Implicit flow

We have implemented an SPA (Angular 5 with angular-auth-oidc) which requests an id_token and an access_token to from an OpenID Connect provider (for the moment we are testing with google), and then sends the id_token to the back-end (a REST API using Spring Boot 5)
My questions are:
what is the approach to send the access_token instead of the id_token ?
Once I am able to validate the access_token, how can I request another access_token and refresh_token ?
Does Spring Security provides a store (in memory) to keep temporarily the access_token and the refresh_token ?
I used the #EnableResourceServer to validate the id_token (jwt) and it works, but when I send the access_token (not a jwt), I get an exception, such as : Invalid characters (CR/LF) in header WWW-Authenticate.

Spring sso oauth2 client unable to request for access token

on spring boot 1.4, using #EnableOAuth2Sso for sso client and a kong third party authorization server, i'm able to receive the authorization code but unable to retrieve the access token.
the authorization code is part of the redirect url after which is there any configuration or a process for retrieving the access token?
Once you get the Authz code, you need to make a server side call(so that access token flow doesn't go through end user browser) to Authz Server for access_token, Look at this section of OAuth 2.0 Spec.

Relay OAuth2 Bearer token with Spring Boot

I'm working on a service that will accept an OAuth2 Bearer token and validate the token then relay that token to other backend services.
I can pull the token from the request and pass it along, but is there anything already in Spring's OAuth2 support for retrieving a token from the request and passing it along?
Or should I create a custom OAuth2ProtectedResourceDetails and OAuth2ClientContext to handle this?

Resources