Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor getAccessToken and add getRefreshToken #34

Open
KyleJune opened this issue Dec 7, 2021 · 1 comment
Open

Refactor getAccessToken and add getRefreshToken #34

KyleJune opened this issue Dec 7, 2021 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@KyleJune
Copy link
Member

KyleJune commented Dec 7, 2021

The oak-localstorage example uses a session instead of sending the access token and refresh token to the client. I did this because I wasn't sure about best way to store refresh token in the client.

I now believe it is safe to store the refresh token and access token in http only secure cookies. To avoid sending the refresh token with every request, the refresh token cookie can have the token endpoint specified as the cookie path.

https://stackoverflow.com/questions/68620374/store-access-token-and-refresh-token-in-cookies

To make this change, I will need to update the refresh token grant to have a callback option for an alternative way of getting the refresh token. In the example I will have it check for a refresh token cookie.

The getAccessToken option should be moved to the ResourceServer constructor since there would only ever be one getAccessToken function for a resource server. The Oak adapter for resource server currently takes getAccessToken in the constructor. Once this change is made, that can be removed. The getAccessToken function will no longer need a requireRefresh argument since refreshing will be left to the client.

I have another issue open that will make it easier for the client to handle request failures due to access token expiration and refreshing tokens.

#17

@KyleJune
Copy link
Member Author

KyleJune commented Apr 3, 2022

I've got a work in progress for getAccessToken. Working on getRefreshToken now.

Going to keep it where you can set the getAccessToken function like you can on the adapter but removing requireRefresh.

@KyleJune KyleJune self-assigned this Apr 3, 2022
@KyleJune KyleJune added the enhancement New feature or request label Apr 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant