The only actions that can be executed with your OIDC token are the user registration, fetching user info and API token creation/deletion.
For every action afterwards inside the AOS the user needs a generated API token with sufficient permissions.
Permissions can be granted either through scoped API tokens for projects or collections themselves or through user specific permissions which will be enforced by a global/personal token.
S3 Secret Access Key / Access Key ID
With the creation of an API token you will also receive credentials which can be used for the S3 compatible interface of the respective AOS instance DataProxy.
These credentials consist of a randomly generated S3 Secret Key and the S3 Access Key ID, which is the same as the ID of the generated token.
The permissions/scope provided at the creation of the API token also apply to the S3 credentials.
Generate API token
An API token can be created with different scopes and/or different permissions.
Available token permissions
NONE ("PERMISSION_NONE"): No permissions granted
READ ("PERMISSION_READ"): Read only access
APPEND ("PERMISSION_APPEND"): Can create new resources but cannot modify existing
MODIFY ("PERMISSION_MODIFY"): Can create new resources and modify existing
ADMIN ("PERMISSION_ADMIN"): Can create new resources, modify existing and additionally delete
So when we talk about minimum requirements for authorization, we get the following order:
ADMIN > MODIFY > APPEND > READ
Available API token scopes
Global/Personal
The fields projectId and collectionId are empty on creation.
This token is valid with nearly every request and inherits the permissions which are set user-specific on projects.
For example, when a user is added to a project with READ permission,
this token "inherits and enforces" the user's READ permission with every request regarding the project or its resources.
Project:
The field projectId is filled and the field collectionId is empty.
This token is valid for the specific Project and all the resources which are associated with it.
These tokens can be used to give general access to a Project and all resources registered under it, however, should not be distributed carelessly.
Collection:
The field collectionId is filled and the field projectId is empty.
This token is valid only for the specific Collection and its containing Objects/ObjectGroups.
These tokens can be used to give users access to a more specific selection of Collections.
Add users to Project
Users can be granted specific permissions for projects, which are inherited and enforced by their global/personal tokens.
This makes it easy to add users to projects without them having to create an additional token per project or even collection.
It also makes it easy to restrict or extend a user's permissions for a project without having to revoke, re-generate and/or re-distribute tokens.
Info
This request needs at least ADMIN permissions on the specific Project.
1 2 3 4 5 6 7 8 910111213
# Native JSON request to add user with admin permissions to a project
curl-d' { "userPermission": { "userId": "<user-id>", "projectId": "<project-id>", "permission": "PERMISSION_ADMIN", "serviceAccount": "false" } }'\-H'Authorization: Bearer <API_TOKEN>'\-H'Content-Type: application/json'\-XPOSThttps://<URL-to-AOS-instance-API-gateway>/v1/project/<project-id>/add_user
1 2 3 4 5 6 7 8 91011121314
# Native JSON request to add user with read only permissions to a project
curl-d' { "userPermission": { "userId": "<user-id>", "projectId": "<project-id>", "permission": "PERMISSION_READ", "serviceAccount": "false" } }'\-H'Authorization: Bearer <API_TOKEN>'\-H'Content-Type: application/json'\-XPOSThttps://<URL-to-AOS-instance-API-gateway>/v1/project/<project-id>/add_user
1 2 3 4 5 6 7 8 91011121314
# Native JSON request to add service acount user with read only permissions to a project
curl-d' { "userPermission": { "userId": "<user-id>", "projectId": "<project-id>", "permission": "PERMISSION_READ", "serviceAccount": true } }'\-H'Authorization: Bearer <API_TOKEN>'\-H'Content-Type: application/json'\-XPOSThttps://<URL-to-AOS-instance-API-gateway>/v1/project/<project-id>/add_user
1 2 3 4 5 6 7 8 910111213141516171819
// Create tonic/ArunaAPI request to add user with admin permissions to a projectletadd_request=AddUserToProjectRequest{project_id: "<project-id>".to_string(),user_permission: Some(ProjectPermission{user_id: "<user-id>".to_string(),project_id: "<project-id>".to_string(),permission: Permission::Adminasi32,service_account: false,}),};// Send the request to the AOS instance gRPC gatewayletresponse=project_client.add_user_to_project(add_request).await.unwrap().into_inner();// Do something with the responseprintln!("{:#?}",response);
1 2 3 4 5 6 7 8 910111213141516171819
// Create tonic/ArunaAPI request to add user with read only permissions to a projectletadd_request=AddUserToProjectRequest{project_id: "<project-id>".to_string(),user_permission: Some(ProjectPermission{user_id: "<user-id>".to_string(),project_id: "<project-id>".to_string(),permission: Permission::Readasi32,service_account: false,}),};// Send the request to the AOS instance gRPC gatewayletresponse=project_client.add_user_to_project(add_request).await.unwrap().into_inner();// Do something with the responseprintln!("{:#?}",response);
1 2 3 4 5 6 7 8 910111213141516171819
// Create tonic/ArunaAPI request to service account user with read only permissions to a projectletadd_request=AddUserToProjectRequest{project_id: "<project-id>".to_string(),user_permission: Some(ProjectPermission{user_id: "<user-id>".to_string(),project_id: "<project-id>".to_string(),permission: Permission::Readasi32,service_account: true,}),};// Send the request to the AOS instance gRPC gatewayletresponse=project_client.add_user_to_project(add_request).await.unwrap().into_inner();// Do something with the responseprintln!("{:#?}",response);
1 2 3 4 5 6 7 8 910111213141516
# Create tonic/ArunaAPI request to add user with admin permissions to a projectrequest=AddUserToProjectRequest(project_id="<project-id>",user_permission=ProjectPermission(user_id="<user-id>",project_id="<project-id>",permission=Permission.Value("PERMISSION_ADMIN"),# Needs int, therefore .Value()service_account=False# Parameter can also be omitted if False))# Send the request to the AOS instance gRPC gatewayresponse=client.project_client.AddUserToProject(request=request)# Do something with the responseprint(f'{response}')
1 2 3 4 5 6 7 8 910111213141516
# Create tonic/ArunaAPI request to add user with read only permissions to a projectrequest=AddUserToProjectRequest(project_id="<project-id>",user_permission=ProjectPermission(user_id="<user-id>",project_id="<project-id>",permission=Permission.Value("PERMISSION_READ"),# Needs int, therefore .Value()service_account=False# Parameter can also be omitted if False))# Send the request to the AOS instance gRPC gatewayresponse=client.project_client.AddUserToProject(request=request)# Do something with the responseprint(f'{response}')
1 2 3 4 5 6 7 8 910111213141516
# Create tonic/ArunaAPI request to add service account user with read only permissions to a projectrequest=AddUserToProjectRequest(project_id="<project-id>",user_permission=ProjectPermission(user_id="<user-id>",project_id="<project-id>",permission=Permission.Value("PERMISSION_READ"),# Needs int, therefore .Value()service_account=True))# Send the request to the AOS instance gRPC gatewayresponse=client.project_client.AddUserToProject(request=request)# Do something with the responseprint(f'{response}')
Edit Project user permission
The assigned permissions to the users can be changed by project administrators afterwards.
Info
This request needs at least ADMIN permissions on the specific Project.
1 2 3 4 5 6 7 8 9101112
# Native JSON request to set a users permission to read only for the specific project
curl-d' { "userPermission": { "userId": "<user-id>", "projectId": "<project-id>", "permission": "PERMISSION_READ" } }'\-H'Authorization: Bearer <API_TOKEN>'\-H'Content-Type: application/json'\-XPOSThttps://<URL-to-AOS-instance-API-gateway>/v1/project/<project-id>/edit_user
1 2 3 4 5 6 7 8 910111213141516171819
// Create tonic/ArunaAPI request to set a users permission to read only for the specific projectletedit_request=EditUserPermissionsForProjectRequest{project_id: "<project-id>".to_string(),user_permission: Some(ProjectPermission{user_id: "<user-id>".to_string(),display_name: "".to_string(),project_id: "<project-id>".to_string(),permission: Permission::Readasi32,}),};// Send the request to the AOS instance gRPC gatewayletresponse=project_client.edit_user_permissions_for_project(edit_request).await.unwrap().into_inner();// Do something with the responseprintln!("{:#?}",response);
1 2 3 4 5 6 7 8 9101112131415
# Create tonic/ArunaAPI request to set a users permission to read only for the specific projectrequest=EditUserPermissionsForProjectRequest(project_id="<project-id>",user_permission=ProjectPermission(user_id="<user-id>",project_id="<project-id>",permission=Permission.Value("PERMISSION_READ")# Needs int, therefore .Value()))# Send the request to the AOS instance gRPC gatewayresponse=client.project_client.EditUserPermissionsForProject(request=request)# Do something with the responseprint(f'{response}')
Remove Project user
Users can, of course, also be completely removed from projects again, depriving them of any access with personalized tokens.
However, access with project/collection scoped tokens is not restricted with the removal of the user.
Info
This request needs at least ADMIN permissions on the specific Project.
1234
# Native JSON request to remove a user from a specific project
curl-H'Authorization: Bearer <API_TOKEN>'\-H'Content-Type: application/json'\-XPOSThttps://<URL-to-AOS-instance-API-gateway>/v1/project/<project-id>/remove_user?userId=<user-id>
1 2 3 4 5 6 7 8 91011121314
// Create tonic/ArunaAPI request to remove a user from a specific projectletdelete_request=RemoveUserFromProjectRequest{project_id: "<project-id>".to_string(),user_id: "<user-id>".to_string(),};// Send the request to the AOS instance gRPC gatewayletresponse=project_client.remove_user_from_project(edit_request).await.unwrap().into_inner();// Do something with the responseprintln!("{:#?}",response);
1 2 3 4 5 6 7 8 91011
# Create tonic/ArunaAPI request to remove a user from a specific projectrequest=RemoveUserFromProjectRequest(project_id="<project-id>",user_id="<user-id>")# Send the request to the AOS instance gRPC gatewayresponse=client.project_client.RemoveUserFromProject(request=request)# Do something with the responseprint(f'{response}')
Generate API Tokens
Here are some API examples on generating API tokens with individual scopes and permissions.
Warning
The token secret and S3 secret key is only available once in the response and cannot be re-generated!
Store the received secret keys in a secure location for further usage.
If a token secret is lost or compromised, delete the old token and generate a new one.
1 2 3 4 5 6 7 8 910111213141516
# Native JSON request to create a global/personal token# This token inherits the permissions from the projects the user is a member of
curl-d' { "projectId": "", "collectionId": "", "name": "MyPersonalToken", "expiresAt": { "timestamp": "2024-01-01T00:00:00.000Z" }, "permission": "PERMISSION_NONE", "isSession": "false" }'\-H'Authorization: Bearer <OIDC-or-API_token'\-H'Content-Type: application/json'\-XPOSThttps://<URL-to-AOS-instance-API-gateway>/v1/auth/token
// Create tonic/ArunaAPI request to create a global/personal API token with expiration dateletexpires_at=NaiveDate::from_ymd(2024,01,01).and_hms(0,0,0);letcreate_request=CreateApiTokenRequest{project_id: "".to_string(),collection_id: "".to_string(),name: "MyPersonalToken".to_string(),expires_at: Some(ExpiresAt{timestamp: Some(Timestamp::date_time(expires_at.date().year().into(),expires_at.date().month()asu8,expires_at.date().day()asu8,expires_at.time().hour()asu8,expires_at.time().minute()asu8,expires_at.time().second()asu8,).unwrap(),),}),permission: Permission::Noneasi32,is_session: false,};// Send the request to the AOS instance gRPC gatewayletresponse=user_client.create_api_token(create_request).await.unwrap().into_inner();// Do something with the responseprintln!("{:#?}",response);
// Create tonic/ArunaAPI request to create a project scoped token with MODIFY permissionsletexpires_at=NaiveDate::from_ymd(2024,01,01).and_hms(0,0,0);letcreate_request=CreateApiTokenRequest{project_id: "<project-id>".to_string(),collection_id: "".to_string(),name: "Project-Modify-Token".to_string(),expires_at: Some(ExpiresAt{timestamp: Some(Timestamp::date_time(expires_at.date().year().into(),expires_at.date().month()asu8,expires_at.date().day()asu8,expires_at.time().hour()asu8,expires_at.time().minute()asu8,expires_at.time().second()asu8,).unwrap(),),}),permission: Permission::Modifyasi32,is_session: false,};// Send the request to the AOS instance gRPC gatewayletresponse=user_client.create_api_token(create_request).await.unwrap().into_inner();// Do something with the responseprintln!("{:#?}",response);
// Create tonic/ArunaAPI request to create a collection scoped token with READ permissionsletexpires_at=NaiveDate::from_ymd(2024,01,01).and_hms(0,0,0);letcreate_request=CreateApiTokenRequest{project_id: "".to_string(),collection_id: "<collection-id>".to_string(),name: "Collection-ReadOnly-Token".to_string(),expires_at: Some(ExpiresAt{timestamp: Some(Timestamp::date_time(expires_at.date().year().into(),expires_at.date().month()asu8,expires_at.date().day()asu8,expires_at.time().hour()asu8,expires_at.time().minute()asu8,expires_at.time().second()asu8,).unwrap(),),}),permission: Permission::Readasi32,is_session: false,};// Send the request to the AOS instance gRPC gatewayletresponse=user_client.create_api_token(create_request).await.unwrap().into_inner();// Do something with the responseprintln!("{:#?}",response);
1 2 3 4 5 6 7 8 910111213141516
# Create tonic/ArunaAPI request to create a global/personal API token with expiration daterequest=CreateAPITokenRequest(project_id="",# Parameter can also be omitted if emptycollection_id="",# Parameter can also be omitted if emptyname="MyPersonalToken",expires_at=ExpiresAt(timestamp=Timestamp(seconds=int(datetime.datetime(2023,1,1).timestamp()))),permission=Permission.Value("PERMISSION_NONE")# Parameter can also be omitted for personal tokens)# Send the request to the AOS instance gRPC gatewayresponse=client.user_client.CreateAPIToken(request=request)# Do something with the responseprint(f'{response}')
1 2 3 4 5 6 7 8 91011121314
# Create tonic/ArunaAPI request to create a project scoped API token with MODIFY permissionrequest=CreateAPITokenRequest(project_id="<project-id>",collection_id="",# Parameter can also be omitted if emptyname="Project-Modify-Token",expires_at=None,# Parameter can also be omitted if Nonepermission=Permission.Value("PERMISSION_MODIFY"))# Send the request to the AOS instance gRPC gatewayresponse=client.user_client.CreateAPIToken(request=request)# Do something with the responseprint(f'{response}')
1 2 3 4 5 6 7 8 91011121314
# Create tonic/ArunaAPI request to create a collection scoped API token with READ permissionrequest=CreateAPITokenRequest(project_id="",# Parameter can also be omitted if emptycollection_id="<collection-id>",name="Collection-ReadOnly-Token",expires_at=None,# Parameter can also be omitted if Nonepermission=Permission.Value("PERMISSION_READ"))# Send the request to the AOS instance gRPC gatewayresponse=client.user_client.CreateAPIToken(request=request)# Do something with the responseprint(f'{response}')
Get API token(s)
API examples to fetch info of a specific token or all tokens of the current user.
Info
This request does not re-display the generated API token secret. See Generate API Tokens.
1234
# Native JSON request to get info on a specific API token by its id
curl-H'Authorization: Bearer <OIDC-Or-API_TOKEN>'\-H'Content-Type: application/json'\-XGEThttps://<URL-to-AOS-instance-API-gateway>/v1/auth/token/{token-id}
1234
# Native JSON request to get info on all tokens associated with the current user
curl-H'Authorization: Bearer <OIDC-Or-API_TOKEN>'\-H'Content-Type: application/json'\-XGEThttps://<URL-to-AOS-instance-API-gateway>/v1/auth/tokens
1 2 3 4 5 6 7 8 910111213
// Create tonic/ArunaAPI request to get info on a specific API token by its idletget_request=GetApiTokenRequest{token_id: "<token-id>".to_string(),};// Send the request to the AOS instance gRPC gatewayletresponse=user_client.get_api_token(get_request).await.unwrap().into_inner();// Do something with the responseprintln!("{:#?}",response);
1 2 3 4 5 6 7 8 91011
// Create tonic/ArunaAPI request to get info on all tokens associated with the current userletget_request=GetApiTokensRequest{};// Send the request to the AOS instance gRPC gatewayletresponse=user_client.get_api_tokens(get_request).await.unwrap().into_inner();// Do something with the responseprintln!("{:#?}",response);
1 2 3 4 5 6 7 8 910
# Create tonic/ArunaAPI request to get info on a specific API token by its idrequest=GetAPITokenRequest(token_id="<token-id>")# Send the request to the AOS instance gRPC gatewayresponse=client.user_client.GetAPIToken(request=request)# Do something with the responseprint(f'{response}')
12345678
# Create tonic/ArunaAPI request to get info on all tokens associated with the current userrequest=GetAPITokensRequest()# Send the request to the AOS instance gRPC gatewayresponse=client.user_client.GetAPITokens(request=request)# Do something with the responseprint(f'{response}')
Revoke token(s)
API examples to revoke/delete a specific API token or all tokens of the current user.
Note
Only AOS instance administrators can revoke API tokens of other users.
1234
# Native JSON request to revoke the specific API token
curl-H'Authorization: Bearer <OIDC-Or-API_TOKEN>'\-H'Content-Type: application/json'\-XDELETEhttps://<URL-to-AOS-instance-API-gateway>/v1/auth/token/{token-id}
1234
# Native JSON request to revoke all tokens of the current user
curl-H'Authorization: Bearer <OIDC-Or-API_TOKEN>'\-H'Content-Type: application/json'\-XDELETEhttps://<URL-to-AOS-instance-API-gateway>/v1/auth/tokens
1 2 3 4 5 6 7 8 910111213
// Create tonic/ArunaAPI request to revoke the specific API tokenletdelete_request=DeleteApiTokenRequest{token_id: "<token-id>".to_string(),};// Send the request to the AOS instance gRPC gatewayletresponse=user_client.delete_api_token(delete_request).await.unwrap().into_inner();// Do something with the responseprintln!("{:#?}",response);
1 2 3 4 5 6 7 8 910111213
// Create tonic/ArunaAPI request to to revoke all tokens of the current userletdelete_request=DeleteApiTokensRequest{user_id: "".to_string(),};// Send the request to the AOS instance gRPC gatewayletresponse=user_client.delete_api_tokens(delete_request).await.unwrap().into_inner();// Do something with the responseprintln!("{:#?}",response);
1 2 3 4 5 6 7 8 910
# Create tonic/ArunaAPI request to revoke the specific API tokenrequest=DeleteAPITokenRequest(token_id="<token-id>")# Send the request to the AOS instance gRPC gatewayresponse=client.user_client.DeleteAPIToken(request=request)# Do something with the responseprint(f'{response}')
12345678
# Create tonic/ArunaAPI request to to revoke all tokens of the current userrequest=DeleteAPITokensRequest()# Send the request to the AOS instance gRPC gatewayresponse=client.user_client.DeleteAPITokens(request=request)# Do something with the responseprint(f'{response}')