This page demonstrates how to configure the schemas to allow entities to set their own password and walks you through the create and invite Registry APIs using the example of a Student to set the password.
Configuring A Schema
We can create a schema in the registry using the Schema API Endpoint and using JSON schema files as well
Here we are creating a Student schema, we would configure as following
{"$schema":"http://json-schema.org/draft-07/schema","type":"object","properties": { "Student": { "$ref":"#/definitions/Student" } },"required": ["Student"],"title":"Student","definitions": {"Student": {"$id":"#/properties/Student","type":"object","title":"Studentschema","required": ["name","phoneNumber","email","school"],"uniqueIndexFields": ["phoneNumber"],"properties": {"name": { "type":"string" },"phoneNumber": { "type":"string" },"email": { "type":"string" },"school": { "type":"string" },// this field will be considered as password"password": { "type":"string","minLength":8 } } } },"_osConfig": {"ownershipAttributes": [ {"email":"/email","mobile":"/phoneNumber","userId":"/phoneNumber",// password ownership attribute required// to map field to password"password":"/password" } ],"inviteRoles": ["anonymous"] }}
This will configure the entity to create a password while creating the entity object. Here ownership attribute password is required, Its value can be any path in the Student object we decide. If we don't set the password ownership attribute, It will take the default password configured in the registry environment.
Note: _Password will only be used while creation of the Student object and Updating password using update entity API Endpoint is not supported._
Note: _If the user is already created by another entity, the password will not be updated to the existing user account._
This will store the entity in the registry, create the user account in IAM (keycloak) with given password for the Student and return the following object:
Here, registry-frontend is the pre-configured client we use to make requests to keycloak and pranav@1234 is the password for the Student entity, we created.
This API call should return a JSON object as follows:
http get \
'http://localhost:8081/api/v1/Student' \
'authorization: bearer {access-token}'
Replace the {id} above with the entity's osid you saved from the create entity request. Replace the {access-token} with the Student entity's access token from the consent/authentication step.
This will return the entity's JSON representation as follows:
{"name":"Pranav Agate","phoneNumber":"1234567890","email":"pranav@upps.in","school":"UP Public School","osid":"xxxxxx","osOwner": ["xxxxxx"],"_osState/school":"DRAFT"}
Here password won't be returned. Password is used only in the creation of the Student entity in Keycloak and not stored directly in the database.