beaulebens / keyring

Keyring is an authentication framework for WordPress. It comes with definitions for a variety of HTTP Basic, OAuth1 and OAuth2 web services. Use it as a common foundation for working with other web services from within WordPress code.
http://dentedreality.com.au/projects/wp-keyring/
77 stars 50 forks source link

Keyring core support for standalone keys/tokens #110

Open mdrovdahl opened 1 year ago

mdrovdahl commented 1 year ago

While writing a proof-of-concept importer for the 1Password Events API, I wanted to store the API token in Keyring and leverage the Keyring Social Importer framework (for continuous import). The 1Password API token is generated in a standalone manner on 1Password.com (not an OAuth flow). From what I could tell, there are no existing Keying Services for such a use-case, where the input to Keyring is a pre-generated token.

For my purposes, I implement this as a new "Core" service (token.php) which accepts for input via UI a key/token, stores it, does the basic validation request and then makes it available via standard Keyring methods.

I think this use-case may have overlap with what @pablinos has written up in #93 and probably has more general use as well.

So, my question is...does this approach make sense? As a new "Core" service? If so, I'm happy to share my code...though it will definitely need review, as it's prototype quality, not production "ready", and only used on my local machine.

There are obviously more lightweight ways to store a key in the database, but I like the idea of centralizing key/token storage within Keyring. Hope you do too =)

cc: @beaulebens

beaulebens commented 1 year ago

What you've described makes sense to me, and does have a certain elegance (symmetry?) to it.

I'm definitely curious to see what you had to write to make it work -- I'm picturing there being a lot of stubs for your Service definition, but maybe that's not such a big deal.

mdrovdahl commented 1 year ago

Alright then, I'll polish it up a bit and get it ready to share =)

mdrovdahl commented 1 year ago

Well, let's give this a try https://github.com/beaulebens/keyring/pull/111