owncloud / ocis

:atom_symbol: ownCloud Infinite Scale Stack
https://doc.owncloud.com/ocis/next/
Apache License 2.0
1.42k stars 183 forks source link

Minimal description in dev docs for auth-app token generation via API necessary #10605

Closed mmattel closed 3 days ago

mmattel commented 6 days ago

Referencing: https://github.com/owncloud/ocis/issues/10292#issuecomment-2468888596 and https://github.com/owncloud/ocis/issues/10292#issuecomment-2482315480

We have a minimal auth-app via API documentation, just saying that there is an endpoint.

We should add some basic documentation as described in the linked issue how the endpoint is used.

@micbar @2403905

mmattel commented 5 days ago

Examples so we dont forget: Note that auth basic is here only a placeholder/dev for a full bearer except if otherwise configured.

List tokens:
curl --location --request GET 'https://localhost:9200/auth-app/tokens' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--header 'Authorization: Basic ZWluc3RlaW46cmVsYXRpdml0eQ=='

Create token:
curl --location --request POST 'https://localhost:9200/auth-app/tokens?expiry=2m' \
--header 'Accept: application/json' \
--header 'Authorization: Basic ZWluc3RlaW46cmVsYXRpdml0eQ=='

Delete token:
curl --location --request DELETE 'https://localhost:9200/auth-app/tokens?token=%242a%2411%24hT5F3WidzRcz5yWIz1TGdu6w3QEbozGdKO9zTpdyV6zWpuloQi7Xe' \
--header 'Accept: application/json' \
--header 'Authorization: Basic ZWluc3RlaW46cmVsYXRpdml0eQ=='

User admin creates the token for user einstein. https://owncloud.dev/services/auth-app/#via-impersonation-api The auth-app service provides an Impersonation API to create (POST) tokens at /auth-app/tokens.

curl --location --request POST 'https://localhost:9200/auth-app/tokens?userID=4c510ada-c86b-4815-8820-42cdf82c3d51&userName=einstein&expiry=4h' \
--header 'Accept: application/json' \
--header 'Authorization: Basic YWRtaW46YWRtaW4='
micbar commented 4 days ago

Referencing https://github.com/owncloud/ocis/pull/9755#issue-2453271785