Registration api
Updated authorization flow:
- created API
- frontend flow
The API can be used as follows:
-
press create user
-
select source type, project, user ID, start date, end date
-
request
POST <backend url>/userswith contentsinterface RestSourceUserRequest {projectId: StringuserId: StringsourceId: StringstartDate: InstantendDate?: InstantsourceType: String}which will have response (for user 1)
HTTP 201 CreatedLocation: <backend url>/users/1interface RestSourceUserResponse {id: StringprojectId: StringuserId: StringsourceId: StringstartDate: InstantendDate?: InstantsourceType: StringcreatedAt: InstanthumanReadableUserId: StringexternalId: StringserviceUserId?: StringisAuthorized: BooleantimesReset: Intversion: String} -
After the user has been created, an account registration request can be created at
POST <backend url>/registrationswith contentsinterface RegistrationCreateRequest {userId: String // matches RestSourceUserResponse.idpersistent?: Boolean // set to true to get a long-living token}with response
interface RegistrationResponse {token: Stringsecret?: String // only defined if the registration is persistentuserId: StringauthEndpointUrl?: String // only defined if the registration is not persistentexpiresAt: Instantpersistent: Boolean} -
The token and secret can be used in a frontend URL to pass to the backend at a later time, or the
authEndpointUrlcan used immediately.-
If the user created a persistent token, the
authEndpointUrlcan be retrieved with a request toPOST <backend url>/registrations/<token>with contentsinterface RegistrationRequest {secret: String}and it will return the authorization URL to be used:
interface RegistrationResponse {token: StringuserId: StringauthEndpointUrl: StringexpiresAt: Instantpersistent: Boolean}
-
-
When the user is authorized, they will be redirected to
<frontend url>/users:newwith a number of query parameters, including thestateparameter. To finalize the authentication procedure, callPOST <backend url>/registrations/<state>/authorizewith contentsinterface AuthorizeRequest {code?: Stringoauth_token?: Stringoauth_verifier?: Stringoauth_token_secret?: String}which on success will respond with the location of
<backend url>/source-clients/<sourceType>/authorization/<service user ID>and with as contentsRegistrationResponsewithout the secret and endpoint URL.- If the response indicated that the token was persistent, the user that can simply be thanked for entering their user details.
- Otherwise, the user can be redirected to the list of users.
- In both cases, the registration is now removed.