4
I believe I am paranoid, but I could not find any situation similar to mine (if you know pass me the link, I am grateful) so I wanted to ask this question to get a definitive answer.
Before the question some information about our infrastructure:
My company is the one who keeps the Authorization Server, the Resource Servers and the Clients.
There may be Clients of third parties, but will be restricted to some Resources Servers.
A little bit of history:
We recently decided to implement SSO (Single Sing On) with Oauth2 in my company’s systems.
I already have one Authorization Server made with Spring Boot and configured some of our old systems that still used Springframework 3.x + JSF as Client, and so far everything is working properly.
We are currently in the process of creating a new frontend in Reactjs to eventually depress the JSF (so I had to do the frontend separate from the backend).
My strategy was to create an api as a Resource Server along with the Client (JSF) so that the two of them share the logic of business (so that developers who have not yet become familiar with React can continue to maintain the JSF screens and meanwhile we migrate to React little by little).
The Problem:
To log in, I redirect the user to a published url of Resource Server which redirects the user back to the Authorization Server with the credentials of Client (which are hidden within the Resource server) and after the user logs in, the whole process of getting the sponse code and trade for access token is done in the backend, at the end the user is redirected back to the frontend in React with the access token inside a cookie (I opted for a cookie instead of sending in the url only to hide from the user).
My concern is that I have to keep the access token in the Cookie with httpOnly=false so that I can identify in the frontend that the user is logged in as well as to send it in the header Authorization requests to the Resource server.
One of the recommendations I found most for Reactjs applications logged in to Oauth2 was to create a backend to control the sessions and save the access token in the backend, but all these cases are when the Client uses a social login such as Google, Facebook or Twitter and not its own, IE, it has to have a backend to maintain the credentials of the Client. Besides it seems to me redundant to have create a backend just to hide oauth token with what will be essentially another token to identify the session.
TL;DR:
Is there any danger in keeping only the Oauth2 Access Token inside a cookie without the flag httpOnly?
And if so, how can I avoid these dangers?
In my view it is only necessary to protect the client’s credentials, after all, if the user has any malicious software on his computer or is accessing our system from an iframe on a forged website that can steal the token stored in the cookie or localStorage, which prevents this same software/site from stealing the password that the user typed in the browser?
If the token is in the cookie, why send it in the header
Authorization
request? All customer cookies are sent to the server that generated them in all requests. Do you need all these cookies? Can someone actually forge a fake website with an iframe or create malware (or something) to try to swindle your site? If yes, then you probably need a desktop and not web application, where opde have more client control– Costamilam
@Costamilam, it is using Oauth2, which by default sends tokens through the request header
– nullptr