Skip to content
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

App Token API #9755

Merged
merged 5 commits into from
Aug 9, 2024
Merged

App Token API #9755

merged 5 commits into from
Aug 9, 2024

Conversation

kobergj
Copy link
Collaborator

@kobergj kobergj commented Aug 7, 2024

Adds an API to create, list and delete app tokens to the auth-app service

# POST needs expiry and creates a token for executing user
    ~/:curl --insecure -XPOST -u admin:admin https://localhost:9200/auth-app/tokens\?expiry\=24h | jq
{
  "token": "3s2K7816M4vuSpd5",
  "expiration_date": "2024-08-08T13:42:42.796888022+02:00",
  "created_date": "2024-08-07T13:42:42+02:00",
  "label": "Generated via API"
}

# POST takes 'userName' param to impersonate other users (needs AUTH_APP_ENABLE_IMPERSONATION)
    ~/:curl --insecure -XPOST -u admin:admin https://localhost:9200/auth-app/tokens\?expiry\=24h\&userName\=einstein 
{
  "token": "8T6kmxj5307S4lP9",
  "expiration_date": "2024-08-08T13:44:31.025199075+02:00",
  "created_date": "2024-08-07T13:44:31+02:00",
  "label": "Generated via Impersonation API"
}

# same works with 'userID' either
    ~/:curl --insecure -XPOST -u admin:admin https://localhost:9200/auth-app/tokens\?expiry\=24h\&userID\=4c510ada-c86b-4815-8820-42cdf82c3d51 | jq
{
  "token": "Ho14ER30t6W7l58O",
  "expiration_date": "2024-08-08T13:46:41.936052281+02:00",
  "created_date": "2024-08-07T13:46:42+02:00",
  "label": "Generated via Impersonation API"
}

# GET lists app-tokens of authenticated user
    ~/:curl --insecure -XGET -u einstein:relativity https://localhost:9200/auth-app/tokens | jq                                       
[
  {
    "token": "$2a$11$EyudDGAJ18bBf5NG6PL9Ru9gygZAu0oPyLawdieNjGozcbXyyuUhG",
    "expiration_date": "2024-08-08T13:44:31.025199075+02:00",
    "created_date": "2024-08-07T13:44:31+02:00",
    "label": "Generated via Impersonation API"
  },
  {
    "token": "$2a$11$dfRBQrxRMPg8fvyvkFwaX.IPoIUiokvhzK.YNI/pCafk0us3MyPzy",
    "expiration_date": "2024-08-08T13:46:41.936052281+02:00",
    "created_date": "2024-08-07T13:46:42+02:00",
    "label": "Generated via Impersonation API"
  }
]

# DELETE takes 'token' parameter to remove unexpired app tokens
~/:curl --insecure -XDELETE -u einstein:relativity https://localhost:9200/auth-app/tokens\?token\="\$2a\$11\$EyudDGAJ18bBf5NG6PL9Ru9gygZAu0oPyLawdieNjGozcbXyyuUhG"

@kobergj kobergj requested a review from DeepDiver1975 August 9, 2024 10:42
Copy link

sonarqubecloud bot commented Aug 9, 2024

@DeepDiver1975
Copy link
Member

tested with the migrate to ocis app 👍

@kobergj kobergj merged commit a47cd02 into owncloud:master Aug 9, 2024
3 checks passed
@kobergj kobergj deleted the AppTokenApi branch August 9, 2024 11:06
ownclouders pushed a commit that referenced this pull request Aug 9, 2024
@ScharfViktor ScharfViktor mentioned this pull request Aug 20, 2024
21 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants