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

Save Oauth2 Access Token in User Meta #155

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

ChristianMaidhof
Copy link

Now, the Access Token and Refresh Token are stored in the database. After login, the tokens are encrypted using the login key of the WordPress system and stored as usermeta in the database as “encrypted_token”. Before logout, the corresponding entry is removed from the metadata. The token can then be used by other plugins, e.g., for calling APIs.

Now, the Access Token and Refresh Token are stored in the database. After login, the tokens are encrypted using the login key of the WordPress system and stored as usermeta in the database as “encrypted_token”.
Before logout, the corresponding entry is removed from the metadata.
The token can then be used by other plugins, e.g., for calling APIs.
@figureone
Copy link
Member

Thanks for the pull request, we'll work on reviewing it and let you know if we have any comments/questions. Since caching OAuth tokens has security implications, we'll want to do a more thorough review.

Can you let us know your use case for reusing the tokens in another plugin?

@ChristianMaidhof
Copy link
Author

We have an API that is secured with OAuth2. Therefore, we need the access and refresh tokens to obtain the relevant information. I thought I would share the change with you, as we have already made it.

If you decide that it does not fit into your strategy, I won't be upset if you choose not to merge it. Maybe you can add a checkbox in the settings for this feature if needed.

@figureone
Copy link
Member

Thanks for keeping this updated; we'll work on getting it merged in the next release cycle. These are the open chores as I see them:

  1. Add an option to Authorizer Settings to enabled/opt-in to this behavior (we can tackle this one, the code for options is super messy :)
  2. Reference the code forked from Google Site Kit: https://github.com/google/site-kit-wp/blob/develop/includes/Core/Storage/Data_Encryption.php (it is Apache licensed so we should be able to include it in this GPLv3 project: https://www.apache.org/licenses/GPL-compatibility.html)
  3. Use WordPress PHP Coding Standards: https://developer.wordpress.org/coding-standards/wordpress-coding-standards/php/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants