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

Explore Storing Tokens as a Custom Post Type instead of User Meta #232

Open
dshanske opened this issue Dec 27, 2021 · 2 comments
Open

Explore Storing Tokens as a Custom Post Type instead of User Meta #232

dshanske opened this issue Dec 27, 2021 · 2 comments

Comments

@dshanske
Copy link
Member

Prompted by @pfefferle, and something I'd considered in the past. The biggest issue is migration, but I'd deliberately built into the plugin a class the token storage classes are all inherited from. There are currently two...one that stores as a transient, the other as user meta. I would just have to improve that abstraction a bit.

The advantage of the current system is its simplicity, but things have gotten more complicated since I did it. So, proposal is as follows.

  • Introduction of new custom post type to store tokens, mapping the following properties to post properties:
  • 'me' - since this is a function of the author, it would be derived from the post_author property
  • 'scope' - Could be stored in the excerpt or content
  • 'client_id' - Proposed client data be stored as a taxonomy attached here, which could also be attached to posts in micropub
  • We have 3 time properties...
  • 'iat' - When the token was issued, which usually maps to published as an equivalent
  • 'exp' - When the token expires(which is optional), not sure where to store this...I suppose meta is the best place, as the expiry dates of all tokens could be picked up in a single query, but...
  • 'last_accessed' - which is when the token was last used and could reflect modified
  • 'last_ip' - We also store the last IP address.
  • 'uuid' - Never used this, but wanted a way to uniquely identify a token...so this could be replaced with post_id.
@tw2113
Copy link

tw2113 commented Dec 27, 2021

80-90% of the content feels like it'd end up being stored as meta, so my gut tells me just store it all as meta instead of most of it. It's most definitely possible to fetch all meta for a post in one go, and go from there. Realistically how often are these values going to be added to NEW posts as opposed to UPDATED posts? Assuming part of the mitigated problems are intended to be post/post meta bloat? Given that we're often working with personal sites, as opposed to to-be-grown community sites, probably NOT that many new posts.

@dshanske
Copy link
Member Author

dshanske commented May 1, 2022

@tw2113 A token can be used for multiple posts. So, it would be a post to post relationship, but it is many posts to a single token.

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

No branches or pull requests

2 participants