Repository navigation
Add session endpoints #626
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
base: main
Are you sure you want to change the base?
Changes from all commits
84bb221
3274c55
df0ecf7
64ce109
949204e
260c7e0
ba0bb0f
4ffef4c
f588667
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,9 +15,9 @@ use v_model::{ | |
| NewApiUserProvider, Permissions, UserId, UserProviderId, | ||
| permissions::{AsScope, Caller, Permission, PermissionError, PermissionStorage}, | ||
| storage::{ | ||
| AccessGroupFilter, AccessGroupStore, AccessTokenStore, ApiKeyFilter, ApiKeyStore, | ||
| ApiUserContactEmailStore, ApiUserFilter, ApiUserProviderFilter, ApiUserProviderStore, | ||
| ApiUserStore, ListPagination, StoreError, | ||
| AccessGroupFilter, AccessGroupStore, AccessTokenFilter, AccessTokenStore, ApiKeyFilter, | ||
| ApiKeyStore, ApiUserContactEmailStore, ApiUserFilter, ApiUserProviderFilter, | ||
| ApiUserProviderStore, ApiUserStore, ListPagination, StoreError, | ||
| }, | ||
| }; | ||
|
|
||
|
|
@@ -699,6 +699,44 @@ where | |
| expires_in: claims.exp - Utc::now().timestamp(), | ||
| }) | ||
| } | ||
|
|
||
| pub async fn list_access_tokens( | ||
| &self, | ||
| caller: &Caller<T>, | ||
| api_user: &TypedUuid<UserId>, | ||
| ) -> ResourceResult<Vec<AccessToken>, UserContextError> { | ||
| if caller.can(&VPermission::GetApiUser(*api_user).into()) { | ||
| let filter = AccessTokenFilter { | ||
| api_user_id: Some(vec![*api_user]), | ||
| revoked: true, | ||
| ..Default::default() | ||
| }; | ||
|
|
||
| let tokens = | ||
| AccessTokenStore::list(&*self.storage, filter, &ListPagination::unlimited()) | ||
| .await?; | ||
| Ok(tokens) | ||
| } else { | ||
| resource_restricted() | ||
| } | ||
| } | ||
|
|
||
| pub async fn revoke_access_tokens( | ||
| &self, | ||
| caller: &Caller<T>, | ||
| api_user: &TypedUuid<UserId>, | ||
| ) -> ResourceResult<usize, UserContextError> { | ||
| if caller.can(&VPermission::ManageApiUser(*api_user).into()) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we want to support users logging themselves out or only admins?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Eventually yes, but didn't want to hold this up on determining the required permission for it. |
||
| let filter = AccessTokenFilter { | ||
| api_user_id: Some(vec![*api_user]), | ||
| ..Default::default() | ||
| }; | ||
|
|
||
| Ok(AccessTokenStore::revoke(&*self.storage, filter).await?) | ||
| } else { | ||
| resource_restricted() | ||
| } | ||
| } | ||
| } | ||
|
|
||
| #[cfg(test)] | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.