|
| 1 | +# Scim2SelfService |
| 2 | + |
| 3 | +`Scim2SelfService` is a SCIM2-compliant `/Me` endpoint. |
| 4 | + |
| 5 | +`Scim2SelfService` is an API service of [UnityCatalogServer](UnityCatalogServer.md) to handle HTTP requests at `/api/1.0/unity-control/scim2/Me` URL. |
| 6 | + |
| 7 | +Method | URL | Handler | Params |
| 8 | +-|-|-|- |
| 9 | + GET | - | [getCurrentUser](#getCurrentUser) | - |
| 10 | + |
| 11 | +```console |
| 12 | +# 🛑 Start the UC server with server authorization enabled |
| 13 | +$ http http://localhost:8080/api/1.0/unity-control/scim2/Me |
| 14 | +HTTP/1.1 401 Unauthorized |
| 15 | +content-length: 173 |
| 16 | +content-type: application/json |
| 17 | +date: Tue, 17 Dec 2024 21:23:01 GMT |
| 18 | +server: Armeria/1.28.4 |
| 19 | + |
| 20 | +{ |
| 21 | + "details": [ |
| 22 | + { |
| 23 | + "@type": "google.rpc.ErrorInfo", |
| 24 | + "metadata": {}, |
| 25 | + "reason": "UNAUTHENTICATED" |
| 26 | + } |
| 27 | + ], |
| 28 | + "error_code": "UNAUTHENTICATED", |
| 29 | + "message": "No authorization found.", |
| 30 | + "stack_trace": null |
| 31 | +} |
| 32 | +``` |
| 33 | + |
| 34 | +```console |
| 35 | +$ http -A bearer -a $(cat etc/conf/token.txt) \ |
| 36 | + http://localhost:8080/api/1.0/unity-control/scim2/Me |
| 37 | +HTTP/1.1 200 OK |
| 38 | +content-length: 345 |
| 39 | +content-type: application/scim+json |
| 40 | +date: Tue, 17 Dec 2024 21:23:29 GMT |
| 41 | +server: Armeria/1.28.4 |
| 42 | + |
| 43 | +{ |
| 44 | + "active": true, |
| 45 | + "displayName": "Admin", |
| 46 | + "emails": [ |
| 47 | + { |
| 48 | + "primary": true, |
| 49 | + "value": "admin" |
| 50 | + } |
| 51 | + ], |
| 52 | + "id": "cd941442-6635-45b9-bc7a-c9b527600b3b", |
| 53 | + "meta": { |
| 54 | + "created": "2024-11-08T17:40:16.216+00:00", |
| 55 | + "lastModified": "2024-12-17T21:23:29.251+00:00", |
| 56 | + "resourceType": "User" |
| 57 | + }, |
| 58 | + "photos": [ |
| 59 | + { |
| 60 | + "value": "" |
| 61 | + } |
| 62 | + ], |
| 63 | + "schemas": [ |
| 64 | + "urn:ietf:params:scim:schemas:core:2.0:User" |
| 65 | + ], |
| 66 | + "userName": "admin" |
| 67 | +} |
| 68 | +``` |
| 69 | + |
| 70 | +## Creating Instance |
| 71 | + |
| 72 | +`Scim2SelfService` takes the following to be created: |
| 73 | + |
| 74 | +* <span id="authorizer"> [UnityCatalogAuthorizer](../server-authorization/UnityCatalogAuthorizer.md) |
| 75 | + |
| 76 | +`Scim2SelfService` is created when: |
| 77 | + |
| 78 | +* `UnityCatalogServer` is requested to [register the API services](UnityCatalogServer.md#addServices) |
| 79 | + |
| 80 | +## UserRepository { #USER_REPOSITORY } |
| 81 | + |
| 82 | +`Scim2SelfService` looks up the system-wide [UserRepository](../persistent-storage/UserRepository.md#getInstance) when [created](#creating-instance). |
| 83 | + |
| 84 | +## Get Current User { #getCurrentUser } |
| 85 | + |
| 86 | +```java |
| 87 | +UserResource getCurrentUser() |
| 88 | +``` |
| 89 | + |
| 90 | +`getCurrentUser` finds a [JSON web token](../server-authorization/AuthDecorator.md#DECODED_JWT_ATTR) in the server-side request context. |
| 91 | + |
| 92 | +`getCurrentUser` uses the `sub` claim (of the decoded JSON web token) as the email of a user to look up. |
| 93 | + |
| 94 | +`getCurrentUser` requests the system-wide [UserRepository](#USER_REPOSITORY) instance to [look up a user by the email](../persistent-storage/UserRepository.md#getUserByEmail). |
| 95 | + |
| 96 | +??? note "Scim2RuntimeException" |
| 97 | + `getCurrentUser` reports a `Scim2RuntimeException` when there is no [JSON web token](../server-authorization/AuthDecorator.md#DECODED_JWT_ATTR) in the server-side request context: |
| 98 | + |
| 99 | + ```text |
| 100 | + No user found. |
| 101 | + ``` |
0 commit comments