Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Roles mapping #1

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,20 @@ public class JaneDoeUserRepository : IUserRepository
/// </summary>
static JaneDoeUserRepository()
{
var rng = new Random();
var rolesList = new List<string>() { "User", "Moderator", "Admin", "Client_Bicsa", "Client_Bpa" };
for (var i = 0; i < 1000; i++)
{
var rolesSeparateComma = "";
var cant = rng.Next(0, rolesList.Count);
for (var j = 0; j < cant; j++)
{
rolesSeparateComma += rolesList.ElementAt(j);
if (j < cant - 1)
{
rolesSeparateComma += ",";
}
}
var guid = Guid.NewGuid();
Users[guid] = new User
{
Expand All @@ -39,6 +51,7 @@ static JaneDoeUserRepository()
Username = $"jane.doe{i}",
Email = $"jane.doe{i}@domain.cu",
Enabled = true,
Roles = rolesSeparateComma,
};
Passwords[guid] = "Password123!";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,20 @@ public class JohnDoeUserRepository : IUserRepository
/// </summary>
static JohnDoeUserRepository()
{
var rng = new Random();
var rolesList = new List<string>() { "User", "Moderator", "Admin", "Client_Bicsa", "Client_Bpa" };
for (var i = 0; i < 1000; i++)
{
var rolesSeparateComma = "";
var cant = rng.Next(0, rolesList.Count);
for (var j = 0; j < cant; j++)
{
rolesSeparateComma += rolesList.ElementAt(j);
if (j < cant - 1)
{
rolesSeparateComma += ",";
}
}
var guid = Guid.NewGuid();
Users[guid] = new User
{
Expand All @@ -41,7 +53,8 @@ static JohnDoeUserRepository()
Username = $"john.doe{i}",
Email = $"john.doe{i}@domain.cu",
Enabled = true,
};
Roles = rolesSeparateComma,
};
Passwords[guid] = "Password123!";
}
}
Expand Down
7 changes: 6 additions & 1 deletion src/StoneAssemblies.Keycloak/Models/User.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,10 @@ public class User
/// Gets or sets the username.
/// </summary>
public string Username { get; set; }
}

/// <summary>
/// List of Roles separates by comma
/// </summary>
public string Roles{ get; set; }
}
}