-
Notifications
You must be signed in to change notification settings - Fork 16
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
Improve credential handling #432
Conversation
Co-authored-by: echo-bravo-yahoo <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need this .fauna files in source control unless I'm missing something.
Otherwise, the biggest thing I notice is this is OO heavy, but on the query side we're more functional + composition. I wouldn't block it now, but we should figure out what our bless pattern is here before release. Otherwise, some of the codebase will be very oo and the rest will be composition and it will be a pain later.
Ticket(s): FE-6152
Probably most helpful to look in order:
auth/credentials.mjs
(middleware that runs buildCredentials)auth/accountKeys.mjs
- Makes theAccountKeyStore
and adds some methods for refreshing account keysauth/databaseKeys.mjs
- MakesDatabaseKeyStore
and has refresh methodsauthNZ
stuff and using the newcontainer.resolve("credentials")
Problem
Solution
Similar to dashboard short-lived keys, make them truly just-in-time by handling 401s with a single refresh and retry attempt.
Build a singleton
Credentials
class that gets injected.Credentials
class buildsAccountKeys
andDatabaseKeys
classes.AccountKeyStore
,DatabaseKeyStore
), and also provide helpers to get and refresh keys when necessaryWrap up
makeAccountRequest
andclient.query
for the account api and fauna api, respectivelyResult
database
andsecret
arg together)Example:
Testing
Need to update
login
test and add newcredentials
test that verifies middleware sets things up properlyauthNZ
test file.