Identity Service
Features
-
Management of User Account and Role entities
-
User-to-Role associations with arbitrary scoping
-
User account creation using any of the following options: self-service, by privileged user, by invitation
-
Password change as self-service
-
Password recovery as self-service
-
Un-registration as self-service
-
Customizable, optional email notifications to drive processes
-
Access token management service
-
Authentication log audit log
Configuration
The following service specific configuration properties are available:
-
uniqueEmailConstraint
[true
]:name
andemail
fields for registering/ creating user are unique, if set tofalse
it allows to register/ create users with same email identifier, howevername
must always be unique. -
loginIdentifierProperty
[name
,email
]: list of identifiers to enable user to login, if the config is missing then by default user can login with either name or email. -
userActivationRequired
[true
]: if set tofalse
, users do not require account activation to be able to log in and use their account. -
register
[true
]: if set tofalse
, theRegister
endpoint is disabled and users cannot self sign up but only be created through the bulk creation methodCreate
which is usually only available to adminstrative user roles. -
enableEmail
[true
]: if set totrue
, emails are sent out upon specific events, like account creation and email change. -
activationURL
: URL used for link in activation email to activate the account. -
inactivatedAccountExpiry
in seconds [undefined
]: if set to a number of seconds, the account will completely be removed from the system (log date will be retained) if no activation has been performed since the given number of seconds. -
emailConfirmationURL
: URL used for link in confirmation email to confirm email address change. -
invitationURL
: URL used for link in invitation email to accept invitation. -
data
: additional fields can be provided inside data. These fields can then be used inside the hbs templates. -
hbsTemplates
: contains URLs for externally served Handlebars templates. These templates are used in emails sent by system for different operations likeRegister
,RequestEmailChange
andRequestPasswordChange
. -
minUsernameLength
: minimum length for the user’sname
. -
maxUsernameLength
: maximum length for the user’sname
. -
obfuscateAuthNErrorReason
:`false`, if set totrue
the login error details are obfuscated and generalized error message is shown. -
authorization:enable
[true
]: if set totrue
then access-control check is performed, if set tofalse
then access-control check is overridden. -
authorization:enforce
[true
]: if set totrue
then result of access-control-check is enforced, if value is set tofalse
the result of access-control check is logged and ignored. -
defaultRegisterUserRoles
: default role associations granted to newly registered users.
Example: We can add a field called url
nested inside the data
field in
the config.json
file, and then use this field in registration_body.hbs
to
generate some html with the interpolated url.
Multiple fields are supported as-well.
-
config.json:
{ "service": { "data": { "url": "https://www.google.com/" } } }
-
registration_body.hbs:
<a href="{{data.url}}">Google Main Page</a>
API
This microservice exposes the following gRPC endpoints:
User
A list of User resources.
io.restorecommerce.user.UserList
Field | Type | Label | Description |
---|---|---|---|
items |
|
required |
List of Users |
total_count |
number |
optional |
number of Users |
subject |
|
required |
Subject details |
A User resource.
io.restorecommerce.user.User
Field | Type | Label | Description |
---|---|---|---|
id |
string |
optional |
User ID, unique, key |
meta |
optional |
Meta info |
|
name |
string |
required |
Username |
first_name |
string |
optional |
User’s first name |
last_name |
string |
optional |
User’s last name |
string |
required |
Email address |
|
new_email |
string |
optional |
Property in which the email is stored upon an email change request until its confirmation |
active |
bool |
optional |
Value is |
activation_code |
string |
optional |
Activation code used in the activation process (cleared after successful activation) |
password |
string |
required |
Raw password, not stored |
password_hash |
bytes |
optional |
Hashed password, stored |
timezone_id |
string |
optional |
The User’s timezone setting (defaults to `Europe/Berlin') |
locale_id |
string |
optional |
The User’s locale ID |
default_scope |
string |
optional |
default scope of user |
unauthenticated |
bool |
optional |
Set automatically to |
guest |
bool |
optional |
If user is guest |
role_associations |
optional |
Role associations |
|
user_type |
|
optional |
User Type - individual, organization or guest user |
image |
|
optional |
Image |
invite |
bool |
optional |
used for user invitation |
invited_by_user_name |
string |
optional |
inviting User’s name |
invited_by_user_first_name |
string |
optional |
inviting User’s first name |
invited_by_user_last_name |
string |
optional |
inviting User’s last name |
tokens |
optional |
list of Tokens |
|
last_access |
|
optional |
timestamp of user’s last access |
io.restorecommerce.auth.RoleAssociation
Field | Type | Label | Description |
---|---|---|---|
role |
string |
optional |
Role ID |
attributes |
optional |
Attributes associated with the User’s role |
|
id |
string |
optional |
role association identifier (referred in Tokens list) |
io.restorecommerce.attribute.Attribute
Field | Type | Label | Description |
---|---|---|---|
id |
string |
optional |
attribute identifier |
value |
string |
optional |
attribute value |
io.restorecommerce.user.UserType
Field | Type | Label | Description |
---|---|---|---|
ORG_USER |
enum |
optional |
organizational User |
INDIVIDUAL_USER |
enum |
optional |
private User |
GUEST |
enum |
optional |
guest User |
TECHNICAL_USER |
enum |
optional |
technical User |
io.restorecommerce.image.Image
Field | Type | Label | Description |
---|---|---|---|
id |
string |
optional |
image identifier |
caption |
string |
optional |
image caption |
filename |
string |
optional |
image file name |
content_type |
string |
optional |
image content type |
url |
string |
required |
image URL |
width |
string |
optional |
image width |
height |
string |
optional |
image height |
length |
string |
optional |
image length |
io.restorecommerce.auth.Subject
Field | Type | Label | Description |
---|---|---|---|
id |
string |
optional |
user id of the authenticated user |
scope |
string |
optional |
target scope of user |
role_associations |
|
optional |
A list of roles with their associated attributes |
hierarchical_scopes |
|
optional |
A list of hierarchical scopes of the authenticated user |
unauthenticated |
bool |
optional |
for unauthenticated users |
token |
string |
optional |
token value |
io.restorecommerce.user.HierarchicalScope
Field | Type | Label | Description |
---|---|---|---|
id |
string |
optional |
role scoping instance / root node value of Organization |
role |
|
optional |
role identifier associated with role scoping instance |
children |
|
optional |
hierarchical organizational tree |
CRUD Operations
The microservice exposes the below CRUD operations for creating or modifying User resources.
io.restorecommerce.user.UserService
Method Name | Request Type | Response Type | Description |
---|---|---|---|
Create |
|
|
Create a list of User resources |
Read |
|
|
Read a list of User resources |
Update |
|
|
Update a list of User resources |
Delete |
|
Empty |
Delete a list of User resources |
Upsert |
|
|
Create or Update a list of User resources |
Create
Used to create a User (usually by privileged user). Requests are performed providing io.restorecommerce.user.UserList
protobuf message as input and responses are an io.restorecommerce.user.UserList
message. The User-to-Role associations
assignment is optionally secured by access-control-srv with
configuration.
If authorization is enabled this service uses acs-client
to invoke access-control-srv
to verify the role and its associations are valid. When authorization is enabled the creating
user should have a valid authentication subject io.restorecommerce.auth.Subject
in request else the request is denied.
The User is allowed to create other Users with valid User-to-Role associations io.restorecommerce.user.RoleAssociation.Attribute
with in his io.restorecommerce.user.HierarchicalScope
. The creating User can assign roles if io.restorecommerce.role.Role.assignable_by_roles
is with in his hierarchical scope context io.restorecommerce.user.HierarchicalScope.role
.
This API also checks if user name is complying with the following set of rules:
-
If the user name contains an "@" symbol, then the username must also be a valid email.
-
The user name must respect the minimum and maximum number of characters allowed.
-
The user name must begin with a letter (a-z, A-Z, äöüÄÖÜß).
-
The user name must contain only characters from the allowed characters list (a-z, A-Z, 0-9, äöüÄÖÜß, @_.-).
-
The user name should not contain forbidden character repetitions (__, .., --).
Register
Used to register a User. Requests are performed providing io.restorecommerce.user.RegisterRequest
protobuf message as
input and responses are an io.restorecommerce.user.User
message. The io.restorecommerce.user.RoleAssociation
are associated using the preconfigured
role association from the defaultRegisterUserRoles. If a valid configuration for retrieving email-related
handlebars templates from a remote server is provided, an email request is performed upon a
successful registration. Such configuration should correspond to the service/hbsTemplates
element in the config files.
The email contains the user’s activation code. Email requests are done by emitting a`sendEmail` notification event,
which is consumed by notification-srv to send an email.
Please note that this email operation also implies template rendering, which is performed by emitting a renderRequest
event,
which is consumed by the rendering-srv. Therefore, the email sending
step requires both a running instance of the rendering-srv and the notification-srv (or similar services which implement
the given interfaces) as well as a remote server containing a set of email templates. This is decoupled from the service’s
core functionalities, and it is automatically disabled if no template configuration is provided.
Moreover, the Register
operation itself is optional and one can enable or disable it through the service.register
configuration value. If disabled, the only endpoint for user creation is Create
.
io.restorecommerce.user.RegisterRequest
Field | Type | Label | Description |
---|---|---|---|
guest |
bool |
optional |
Guest user, default value is |
name |
string |
required |
Username |
first_name |
string |
optional |
User’s first name |
last_name |
string |
optional |
User’s last name |
string |
required |
User email ID |
|
password |
string |
required |
User password |
timezone |
string |
optional |
The User’s timezone setting (defaults to `Europe/Berlin') |
locale_id |
string |
optional |
The User’s locale setting identifier (defaults to `de-DE') |
user_type |
|
optional |
User Type |
captcha_code |
string |
optional |
captcha code |
Activate
Used to activate a User. The service.userActivationRequired
config value turns the user activation process on or off.
Requests are performed providing io.restorecommerce.user.ActiveRequest
protobuf message as input and responses are a google.protobuf.Empty
message.
io.restorecommerce.user.ActiveRequest
Field | Type | Label | Description |
---|---|---|---|
identifier |
string |
required |
User name or User email |
activation_code |
string |
required |
activation code for User |
subject |
|
required |
Subject details |
ChangePassword
Used to change password for the User (this User should be activated to perform this operation).
Requests are performed providing io.restorecommerce.user.ChangePasswordRequest
protobuf message as input and responses are an io.restorecommerce.user.User
message.
io.restorecommerce.user.ChangePasswordRequest
Field | Type | Label | Description |
---|---|---|---|
password |
string |
required |
old password |
new_password |
string |
required |
new password |
subject |
|
required |
Subject details |
RequestPasswordChange
Used to change password for the User in case they forget it. It generates and persists an activation code for the user
and issues an email with a confirmation URL. Requests are performed providing io.restorecommerce.user.RequestPasswordChangeRequest
protobuf message as input and responses are google.protobuf.Empty
messages. Either user name or email should be
specified upon the request.
io.restorecommerce.user.RequestPasswordChangeRequest
Field | Type | Label | Description |
---|---|---|---|
identifier |
string |
required |
User name or User email |
subject |
|
required |
Subject details |
ConfirmPasswordChange
Used to confirm the user’s password change request. The input is an io.restorecommerce.user.ConfirmPasswordChangeRequest
message and the response is a google.protobuf.Empty
message. If the received activation code matches the previously
generated activation code, the stored password hash value is replaced by a hash derived from the new password, and the
activation code is reset.
io.restorecommerce.user.ConfirmPasswordChangeRequest
Field | Type | Label | Description |
---|---|---|---|
identifier |
string |
required |
User name or User email |
activation_code |
string |
required |
Activation code |
password |
string |
required |
New password |
subject |
|
required |
Subject details |
RequestEmailChange
Used to change the user’s email. Requests are performed providing the io.restorecommerce.user.ChangeEmailRequest
protobuf message as input and responses is a google.protobuf.Empty
message. when receiving this request, the service
assigns the new email value to the user’s new_email
property and triggers an email with a confirmation URL containing
a newly-generated activation code.
io.restorecommerce.user.ChangeEmailRequest
Field | Type | Label | Description |
---|---|---|---|
identifier |
string |
required |
User name or User email |
new_email |
string |
required |
New email |
subject |
|
required |
Subject details |
ConfirmEmailChange
Used to confirm the user’s email change request. The input is an io.restorecommerce.user.ConfirmEmailChangeRequest
message and the response is a google.protobuf.Empty
message. If the received activation code matches the previously
generated activation code, the value assigned to the new_email
property is then assigned to the email
property and
new_email
is set to null.
io.restorecommerce.user.ConfirmEmailChangeRequest
Field | Type | Label | Description |
---|---|---|---|
identifier |
string |
required |
User name or User email |
activation_code |
string |
required |
Activation code |
subject |
|
required |
Subject details |
ConfirmUserInvitation
Used to confirm user invitation. Requests are performed providing io.restorecommerce.user.ConfirmUserInvitationRequest
protobuf message as input and responses are a google.protobuf.Empty
message. For Create
operation if the invite
flag io.restorecommerce.user.invite
is set to true then an invitation mail would be sent if invitationURL
and hbsTemplates
configuration values are setup accordingly.
io.restorecommerce.user.ConfirmUserInvitationRequest
Field | Type | Label | Description |
---|---|---|---|
identifier |
string |
required |
User name or User email |
password |
string |
required |
User password |
activation_code |
string |
required |
User’s activation_code sent via email |
subject |
|
required |
Subject details |
Login
Used to verify the User name or email with a password and return User’s information in case the operation is successful.
Requests are performed providing io.restorecommerce.user.LoginRequest
protobuf message as input, and the response is
io.restorecommerce.user.User
message.
io.restorecommerce.user.LoginRequest
Field | Type | Label | Description |
---|---|---|---|
identifier |
string |
required |
User name or User email |
password |
string |
optional |
Raw password |
token |
string |
optional |
Token for users |
Unregister
Used to unregister a User. Requests are performed providing io.restorecommerce.user.UnregisterRequest
protobuf message
as input and responses are a google.protobuf.Empty
message.
io.restorecommerce.user.UnregisterRequest
Field | Type | Label | Description |
---|---|---|---|
identifier |
string |
required |
User name or User email |
subject |
|
required |
Subject details |
Find
A simplified version of read
, which only filters users by a username, email and/or ID. Requests are performed providing
io.restorecommerce.user.FindRequest
protobuf message as input and responses contain a list io.restorecommerce.user.User
messages.
io.restorecommerce.user.FindRequest
Field | Type | Label | Description |
---|---|---|---|
id |
string |
optional |
User ID |
name |
string |
optional |
User name |
string |
optional |
User EmailID |
|
subject |
|
required |
Subject details |
FindByRole
A custom endpoint in order to filter a user by its role and any attributes associated with it. Requests are performed
providing io.restorecommerce.user.FindByRoleRequest
protobuf message as input and responses contain a list
io.restorecommerce.user.User
messages.
io.restorecommerce.user.FindByRoleRequest
Field | Type | Label | Description |
---|---|---|---|
role |
string |
required |
Role name |
attributes |
|
optional |
Role attributes |
subject |
|
required |
Subject details |
FindByToken
This endpoint returns the user data based on the provided token value. Requests are performed providing io.restorecommerce.user.FindByTokenRequest
protobuf message
as input and response is io.restorecommerce.user.User
data. For caching purpose this endpoint also stores the token information in Redis with key as token identifier and user data as value.
The cached data is invalidated when User is logged_out or when token Destroy
or RevokeByGrantId
api is invoked.
io.restorecommerce.user.FindByTokenRequest
Field | Type | Label | Description |
---|---|---|---|
token |
string |
required |
Token value |
SendActivationEmail
This endpoint sends activation email to the email id of the registered user. In case if the User is already activated suitable error response is sent, else activation email
containing activation code is sent back. Requests are performed providing io.restorecommerce.user.SendActivationEmailRequest
protobuf message
as input and response is google.protobuf.Empty
message.
io.restorecommerce.user.SendActivationEmailRequest
Field | Type | Label | Description |
---|---|---|---|
identifier |
string |
required |
User name or email |
subject |
|
required |
Subject details |
Role
A list of Role resources.
io.restorecommerce.role.RoleList
Field | Type | Label | Description |
---|---|---|---|
items |
|
required |
List of Roles |
total_count |
number |
optional |
number of Roles |
subject |
|
required |
subject details |
io.restorecommerce.role.Role
Field | Type | Label | Description |
---|---|---|---|
id |
string |
optional |
Role identifier |
name |
string |
required |
specifies the Role of the User |
description |
string |
optional |
Role description |
assignable_by_roles |
string[] |
optional |
role identifier’s who can assign this role |
meta |
optional |
Meta info |
CRUD Operations
The microservice exposes the below CRUD operations for creating or modifying Role resources.
io.restorecommerce.role.RoleService
Method Name | Request Type | Response Type | Description |
---|---|---|---|
Create |
|
|
Create a list of Role resources |
Read |
|
|
Read a list of Role resources |
Update |
|
|
Update a list of Role resources |
Delete |
|
Empty |
Delete a list of Role resources |
Upsert |
|
|
Create or Update a list of Role resources |
For the detailed protobuf message structure of io.restorecommerce.resourcebase.ReadRequest
and
io.restorecommerce.resourcebase.DeleteRequest
refer resource-base-interface.
Token
A Token resource.
io.restorecommerce.auth.Tokens
Field | Type | Label | Description |
---|---|---|---|
name |
string |
optional |
Token name |
expires_in |
|
optional |
Token expiration timestamp |
token |
string |
optional |
token value |
scopes |
string [] |
optional |
identifier for RoleAssociation |
type |
string |
optional |
token type ex: access_token, refresh_token etc |
last_login |
|
optional |
timestamp of user last logged in |
interactive |
bool |
optional |
flag to indicate a login from GUI |
CRUD Operations
The microservice exposes the below operations for upsert, find and delete Token resources.
io.restorecommerce.token.TokenService
Upsert
This endpoint upserts token data on user entity io.restorecommerce.user.User.tokens
. Request is formed using io.restorecommerce.token.TokenData
and response is
google.protobuf.Any
message containing the status of upsert operation. For upsert operation we use a tech user upsert_user_tokens
configured
in configuration.
io.restorecommerce.token.TokenData
Field | Type | Label | Description |
---|---|---|---|
id |
string |
optional |
Token identifier |
payload |
string |
optional |
Token payload (id_token) |
expires_in |
|
optional |
Token expiration timestamp |
type |
string |
optional |
Token type |
subject |
|
required |
Subject details |
Find
This endpoint is used to find the token information using token identifier. Requests are performed providing io.restorecommerce.token.Identifier
protobuf message as input and response is google.protobuf.Any
message containing token information.
io.restorecommerce.token.Identifier
Field | Type | Label | Description |
---|---|---|---|
id |
string |
optional |
Token identifier |
type |
string |
optional |
Token type |
subject |
|
optional |
Subject details |
Destroy
This endpoint is used to destroy or remove the token information from user entity io.restorecommerce.user.User.tokens
.
Requests are performed providing io.restorecommerce.token.Identifier
protobuf message as input and response is google.protobuf.Any
message containing token information.
Method Name | Request Type | Response Type | Description |
---|---|---|---|
Upsert |
|
|
upserts token and returns success or failure message |
Find |
|
|
find token data |
Destroy |
|
|
destroy token |
RevokeByGrantId |
|
|
destroy token by its grantId property reference |
Consume |
|
|
Mark a stored token as consumed (updates last_access) |
Events
Emitted
List of events emitted by this microservice for below topics:
Topic Name | Event Name | Description |
---|---|---|
|
|
emitted upon user registration |
|
emitted upon user activation |
|
|
emitted when user requests for password change |
|
|
emitted when password was changed successfully |
|
|
emitted when user requests for email change |
|
|
emitted when user’s email was changed successfully |
|
|
emitted when a user is unregistered |
|
|
emitted when a user is created |
|
|
emitted when a user is modified |
|
|
emitted when a user is deleted |
|
|
|
emitted upon role creation |
|
emitted upon role modification |
|
|
emitted when role deletion |
|
|
|
emitted when triggering notification email |
|
|
emitted when rendering is requested |
|
|
system restore response |
|
system reset response |
|
|
system health check response |
|
|
system version response |
|
|
flush ACS Cache response |
|
|
set API Key response |
For renderRequest
and renderResponse
the message structures are defined in rendering-srv
and for sendEmail
they are defined in notification-srv,
Consumed
This microservice consumes messages for the following events by topic:
Topic Name | Event Name | Description |
---|---|---|
|
|
for triggering for system restore |
|
for triggering system reset |
|
|
to get system health check |
|
|
to get system version |
|
|
used to flush ACS Cache |
|
|
used to update configurations |
|
|
|
to get response from render request |