Add token creation/list/revocation DB, API and UI #5177
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This adds the ability to create, view and revoke tokens through the auth UI. It also adds an auth tokens table to the database, and auth api endpoints to manipulate them.
Note: The UI is not fully in sync with @MarkDennard's vision yet, but has most of the shape, and most importantly plumbs all of the data all the way through the system. There are things like dropdowns and spacing and colors that I will be asking people for help for, but it seems worth getting the meat of this feature in and then iterating.
Features
Code
Vue-wise, there are a couple of little neat things:
useAsyncState
composable to reactively track async operations. It is particularly neato for actions: you callcreateAuthToken.execute()
and it will trigger an async function to start. This can probably be more compact, but I was trying to see how far I could get with (mostly) existing APIs and (mostly) avoided the temptation to write a bunch of my own. (OK, I might have written a bunch of these APIs myself and then removed them when I found a way to use existing stuff. But if it's not in the PR, it never happened ...)new ApiRequest
in actions. This interestingly made theauthTokens
store "headless," in that the page itself does all actual state tracking and uses the authTokenApi. I'm still thinking through the pattern, but for situations like this where we don't want to persist the data forever, it seems to localize stuff and make it a bit more concise.<LoadStatus>
widget provides a "loading" / "error" / "success" view based on an asynchronous operation. It has neat stuff with named slots, too. I haven't plumbed it everywhere it could be used yet, but I've put it in several places. The existing components supportApiRequestStatus
; I expanded it to supportuseAsyncState
as well.