Closed sw-kosaki closed 4 days ago
Hello, and sorry for my late reply :)
It is possible to add custom user attributes in the SCIM project. Below are the steps to add a custom attribute nbConnections
to the User representation:
Schemas
directory.{
"id": "urn:ietf:params:scim:schemas:extension:security:2.0:User",
"name": "EidUser",
"description": "EID User",
"attributes": [
{
"name": "nbConnections",
"type": "decimal",
"multiValued": false,
"description": "Number of conections.",
"required": false,
"caseExact": false,
"mutability": "readWrite",
"returned": "default",
"uniqueness": "none"
}
],
"meta": {
"resourceType": "Schema",
"location": "/v2/Schemas/urn:ietf:params:scim:schemas:extension:security:2.0:User"
}
}
Program.cs
file and register your new schema by making the following modifications:var securityUser = SimpleIdServer.Scim.SCIMSchemaExtractor.Extract(Path.Combine(basePath, "Security.json"), SCIMResourceTypes.User);
userSchema.SchemaExtensions.Add(new SCIMSchemaExtension
{
Id = Guid.NewGuid().ToString(),
Schema = "urn:ietf:params:scim:schemas:extension:security:2.0:User"
});
context.SCIMSchemaLst.Add(securityUser);
HTTP POST : https://localhost:5003/Users
{
"schemas": ["urn:ietf:params:scim:schemas:core:2.0:User","urn:ietf:params:scim:schemas:extension:security:2.0:User"],
"externalId": "external",
"userName": "{{$guid}}",
"nbConnections": 2,
"displayName":"coucou",
"name": {
"formatted": "formatted",
"givenName": "givenName",
"middleName": "middleName",
"familyName": "familyName"
}
}
The response will contain the nbConnections
attribute!
You can download a working version here :)
KR,
SID
Bog thanks for this tutorial, the project and explanations!
Do you have some idea what causes this error when I try to run your ScimEF project?
Do I need to run a separate SQLSERVER instance to avoid it?
Indeed, open the appsettings.json file and edit the connection string. :)
@simpleidserver Thanks again, everything works as you explained in the scimEF project.
If you allow me, I have another important question for me -
How to add this new extension user schema (with new custom attribute) without using of any database?
Ask that because our service just acts as a proxy and has no its on database and maybe we will have serious misconceptions with the POC project in that.
Also, how I can clean the " context.SCIMSchemaLst" and add another one new user schema there? Now the context is fulfilled with existing schemas in this line: context.Database.Migrate();
and in this case does not enter in the if (!context.SCIMSchemaLst.Any())
where I have to add my new schema.
Thanks for your time again!
Hello, I have a task to add a custom user attribute in User's Schema in .Net Core provisioning project which we already have, and now we want to extend the User's schema with a custom (not existing in User's list) attribute. Is that possible at all?
I've read somewhere in the docs, that its possible with adding of additional user's sub schema with this custom attribute in the project (which implements SimpleIdServer), and include this new schema in the main User's Core schema, is that correct?
Now I have to create a simple POC project where I have to prove that this works, so will appreciate if you can you give me some advices how to do that or point me to the proper samples or poc project? Thanks in advance for your time!