User type
User type (projection) was added in CzechIdM version 10.2.0. Projection defines frontend form to read, create and edit user. We can create and edit user by different form. For example externe and internal employee can be created and edited differently (different attributes has to be filled). Used projection for user creation is set as user type.
Configurable form in product
Form projection with configurable features was added into product core
module:
- Frontend:
- Form projection content is placed on path
src/content/identity/projection/IdentityProjection.js
. - Route (= frontent target)
form/identity-projection/:entityId
' is registed inroutes.js
. - Component
identity-projection
with route usage is registered incomponent-descriptor.js
- Backend:
IdmIdentityProjectionDto
was added - contains all projection data sent between backend and frontend, contains:- identity - identity.
- contract - first (~ prime) contract. If currenly logged user has permission to read prime contract. First other contract is shown otherwise. Contract are sorted by priority the same way, as prime contract is evaluated.
- otherContracts - all other contracts.
- otherPositions - all other positions.
- identityRoles - all assigned identity roles.
IdentityProjectionManager
was added and support get and save identity projection. Projection is processed by event and processors (seeIdentityProjectionSaveProcessor
). Processors can be registed to processIdmIdentityProjectionDto
content (custom validations, generators etc. can be added non invasively). Manager contains overridable protected method to get and save all parts of projection (methods can be overidden invasively to add or change product behavior).IdmIdentityProjectionController
is exposed on url '<server api>/identity-projection' and support get and postIdmIdentityProjectionDto
- callsIdentityProjectionManager
methods.
How to register new form
New projection can be added with the same structure in custom module. Is needed to add new content representing form projection (e.g. copy or reuse form projection from product), register new route in routes.js
, register new component in component-descriptor.js
and expose new edpoint on backend if needed (if provided IdmIdentityProjectionDto
is insuffiscient).
Projection will obtain entityId
route parameter with identity codeable identifier (username or uuid).
Example
Source codes are placed in example module. Product backend is reused and example provides new frontend form for new projection. Form saves identity username only.
Create new form src/content/identity/projection/ExampleIdentityProjection.js
with content:
Register new route in 'routes.js':
{ path: 'example/form/identity-projection/:entityId', component: require('./src/content/identity/projection/ExampleIdentityProjection'), access: [ { type: 'HAS_ANY_AUTHORITY', authorities: ['IDENTITY_READ' ] } ] }
Register new component in component-descriptor.js
{ id: 'example-identity-projection', type: 'form-projection', ownerType: 'IdmIdentity', route: '/example/form/identity-projection' }
Localization
Two projections are localized by default in product. If projection with code identity-externe
or identity-internal
will be configured, then localization will be used.
... "eav": { "form-projection": { "identity-externe": { "label": "Externe user", "help": "Create externe user", "icon": "fa:walking", "level": "primary" }, "identity-internal": { "label": "Internal employee", "help": "Create internal user", "icon": "fa:user", "level": "success" } } }, ...
Localization can be added to newly configured projection in custom module. Projection localization is based on the same convetions as localization for [form definition].
Supported properties:
- label - projection name. Used in select boxes and as label for button to create user with projection usage.
- help - Used as title (tooltip) for button to create user with projection usage.
- icon - Used in select boxes and as icon for button to create user with projection usage (optional,
fa:user-plus
will be used as default). - level - Used as level for button to create user with projection usage (optional,
default
will be used as default).
Future improvement
- Projection could be implemented by graphgl usage on backend (~extendable dto resource).
- Save button can be shown, if any section can be edited - update identity permission is needed now.
- Assigned role attributes cannot be defined, when identity is created - add new assigned roles face mode (support projection properties).