-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Getting the roles by Id when using client credentials grant type #2743 (Lombiq Technologies: TOTA-2) #2872
Merged
Merged
Getting the roles by Id when using client credentials grant type #2743 (Lombiq Technologies: TOTA-2) #2872
Changes from 5 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
f24b924
Fixing to get the roles by Id instead of name when getting the roles …
LombiqTechnologies c9f32b3
Merge branch 'dev' into clientcredentialsroles
domonkosgabor 6c611fb
Merge branch 'dev' into clientcredentialsroles
domonkosgabor 8e02011
Refactoring RoleStore
domonkosgabor f830454
Moving the resolution of the implementation of the IRoleService outsi…
domonkosgabor 1ceb278
Resolve the IRoleService dependency in an optional way in the Applica…
domonkosgabor 8f4f504
Merge remote-tracking branch 'origin/dev' into clientcredentialsroles
domonkosgabor 4004da2
Updating ApplicationControllerTests
domonkosgabor b760cdc
Fixing ApplicationController for tests
domonkosgabor 13cd14e
Remove unnecessary null propagation operators
kevinchalet File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
src/OrchardCore.Modules/OrchardCore.Roles/Services/RoleService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Security.Claims; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Microsoft.AspNetCore.Identity; | ||
using OrchardCore.Security; | ||
using OrchardCore.Security.Services; | ||
|
||
namespace OrchardCore.Roles.Services | ||
{ | ||
public class RoleService : IRoleService | ||
{ | ||
private readonly RoleManager<IRole> _roleManager; | ||
|
||
public RoleService(RoleManager<IRole> roleManager) | ||
{ | ||
_roleManager = roleManager; | ||
} | ||
|
||
public async Task<IEnumerable<Claim>> GetRoleClaimsAsync(string role, CancellationToken cancellationToken = default) | ||
{ | ||
if (string.IsNullOrEmpty(role)) | ||
{ | ||
throw new ArgumentException("The role name cannot be null or empty.", nameof(role)); | ||
} | ||
|
||
var entity = await _roleManager.FindByNameAsync(role); | ||
if (entity == null) | ||
{ | ||
return Array.Empty<Claim>(); | ||
} | ||
|
||
return await _roleManager.GetClaimsAsync(entity); | ||
} | ||
|
||
public Task<IEnumerable<string>> GetRoleNamesAsync() | ||
{ | ||
return Task.FromResult<IEnumerable<string>>(_roleManager.Roles.Select(a => a.RoleName)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@domonkosgabor any chance you could also resolve this dependency in an optional way, like you did for the main OpenID controller? Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. What do you think, what should we do if there aren't any service available that implements
IRoleService
when creating/editing an application?Just simply show a warning message in this page to the user about there will be no RoleEntrys in the list?