Skip to content

Commit 77e0685

Browse files
TIcket #901 : Update the documentation
1 parent 1a09538 commit 77e0685

2 files changed

Lines changed: 102 additions & 2 deletions

File tree

website/docs/scim/persistence/entityframework.md

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,4 +130,54 @@ app.UseScim();
130130
app.Run();
131131
```
132132

133-
This setup shows how to accommodate SQLite’s limitations while still benefitting from Entity Framework’s powerful migration and connection capabilities.
133+
This setup shows how to accommodate SQLite’s limitations while still benefitting from Entity Framework’s powerful migration and connection capabilities.
134+
135+
## Running the EF Migration
136+
137+
Once your SCIM server is configured and ready to use a database, you can trigger the EF Core migration by calling the `EnsureEfStoreMigrated` function in your `Program.cs` file.
138+
139+
```csharp title="Program.cs"
140+
var app = builder.Build();
141+
app.Services.EnsureEfStoreMigrated(new List<SCIMSchema>(), new List<SCIMAttributeMapping>(), new List<Realm>());;
142+
```
143+
144+
This function takes three input parameters:
145+
146+
1. **List of SCIM Schemas** : You can use the `SCIMSchemaExtractor` class to extract SCIM schemas from a JSON file. For example:
147+
148+
```
149+
var userSchema = SimpleIdServer.Scim.SCIMSchemaExtractor.Extract(Path.Combine(basePath, "UserSchema.json"), SCIMResourceTypes.User, true);
150+
```
151+
152+
2. **List of attribute mappings** : These mappings define parent-child relationships between two types of representations—for example, between a `Group` and a `User`.
153+
154+
The code snippet below sets up the relationship from a `Group` to a `User`, where the `members` property of a `group` contains a list of `users`:
155+
156+
```csharp
157+
new SCIMAttributeMapping
158+
{
159+
Id = Guid.NewGuid().ToString(),
160+
SourceAttributeId = groupSchema.Attributes.First(a => a.Name == "members").Id,
161+
SourceResourceType = StandardSchemas.GroupSchema.ResourceType,
162+
SourceAttributeSelector = "members",
163+
TargetResourceType = StandardSchemas.UserSchema.ResourceType,
164+
TargetAttributeId = userSchema.Attributes.First(a => a.Name == "groups").Id,
165+
Mode = Mode.PROPAGATE_INHERITANCE
166+
}
167+
```
168+
169+
The following code snippet sets up the inverse relationship from a `User` to a `Group`, where the `groups` property of a `user` contains a list of `groups` :
170+
171+
```
172+
new SCIMAttributeMapping
173+
{
174+
Id = Guid.NewGuid().ToString(),
175+
SourceAttributeId = userSchema.Attributes.First(a => a.Name == "groups").Id,
176+
SourceResourceType = StandardSchemas.UserSchema.ResourceType,
177+
SourceAttributeSelector = "groups",
178+
TargetResourceType = StandardSchemas.GroupSchema.ResourceType,
179+
TargetAttributeId = groupSchema.Attributes.First(a => a.Name == "members").Id
180+
}
181+
```
182+
183+
3. **List of realms** : The third parameter defines the list of realms to be created. For more information, refer to the dedicated section on realms.

website/docs/scim/persistence/mongodb.md

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,54 @@ Several properties can be customized during the configuration process. Understan
4343
| CollectionRealms | Used for storing realms if your SCIM server segregates data based on different domains or contexts. |
4444
| SupportTransaction | Boolean flag indicating if your MongoDB deployment supports transactions. When set to true, the application can take advantage of atomic operations, which are essential in environments requiring strong consistency. |
4545

46-
For more detailed reference, you can check out the example project available on GitHub: [SimpleIdServer Sample](https://github.com/simpleidserver/SimpleIdServer/tree/master/samples/ScimMongodb).
46+
For more detailed reference, you can check out the example project available on GitHub: [SimpleIdServer Sample](https://github.com/simpleidserver/SimpleIdServer/tree/master/samples/ScimMongodb).
47+
48+
## Creating MongoDB Collections
49+
50+
Once your SCIM server is configured and ready to use MongoDB, you can create the necessary collections by calling the `EnsureMongoStoreDataMigrated` function in your `Program.cs` file.
51+
52+
```csharp title="Program.cs"
53+
var app = builder.Build();
54+
app.Services.EnsureMongoStoreDataMigrated(new List<SCIMSchema>(), new List<SCIMAttributeMapping>(), new List<Realm>());;
55+
```
56+
57+
This function takes three input parameters:
58+
59+
1. **List of SCIM Schemas** : You can use the `SCIMSchemaExtractor` class to extract a SCIM schema from a JSON file. For example:
60+
61+
```
62+
var userSchema = SimpleIdServer.Scim.SCIMSchemaExtractor.Extract(Path.Combine(basePath, "UserSchema.json"), SCIMResourceTypes.User, true);
63+
```
64+
65+
2. **List of attribute mappings** : These mappings define parent-child relationships between different representation types. For instance, between a `Group` and a `User`.
66+
67+
The following code snippet defines the relationship from a `Group` to a `User`. The `members` property of a `group` contains a list of `users`:
68+
69+
```csharp
70+
new SCIMAttributeMapping
71+
{
72+
Id = Guid.NewGuid().ToString(),
73+
SourceAttributeId = groupSchema.Attributes.First(a => a.Name == "members").Id,
74+
SourceResourceType = StandardSchemas.GroupSchema.ResourceType,
75+
SourceAttributeSelector = "members",
76+
TargetResourceType = StandardSchemas.UserSchema.ResourceType,
77+
TargetAttributeId = userSchema.Attributes.First(a => a.Name == "groups").Id,
78+
Mode = Mode.PROPAGATE_INHERITANCE
79+
}
80+
```
81+
82+
The next snippet defines the reverse relationship, from a `User` to a `Group`. The `groups` property of a `user` contains a list of `groups`:
83+
84+
```
85+
new SCIMAttributeMapping
86+
{
87+
Id = Guid.NewGuid().ToString(),
88+
SourceAttributeId = userSchema.Attributes.First(a => a.Name == "groups").Id,
89+
SourceResourceType = StandardSchemas.UserSchema.ResourceType,
90+
SourceAttributeSelector = "groups",
91+
TargetResourceType = StandardSchemas.GroupSchema.ResourceType,
92+
TargetAttributeId = groupSchema.Attributes.First(a => a.Name == "members").Id
93+
}
94+
```
95+
96+
3. **List of realms** : The third parameter specifies the list of realms to initialize. For more details, refer to the dedicated chapter on realms.

0 commit comments

Comments
 (0)