forked from abpframework/abp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request abpframework#16168 from abpframework/AttachScopes
Add `AttachScopes` handler.
- Loading branch information
Showing
5 changed files
with
44 additions
and
1 deletion.
There are no files selected for viewing
5 changes: 4 additions & 1 deletion
5
...ations/20230307054116_Initial.Designer.cs → ...ations/20230404033745_Initial.Designer.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
34 changes: 34 additions & 0 deletions
34
.../openiddict/src/Volo.Abp.OpenIddict.AspNetCore/Volo/Abp/OpenIddict/Scopes/AttachScopes.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,34 @@ | ||
using System; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using OpenIddict.Server; | ||
|
||
namespace Volo.Abp.OpenIddict.Scopes; | ||
|
||
public class AttachScopes : IOpenIddictServerHandler<OpenIddictServerEvents.HandleConfigurationRequestContext> | ||
{ | ||
public static OpenIddictServerHandlerDescriptor Descriptor { get; } | ||
= OpenIddictServerHandlerDescriptor.CreateBuilder<OpenIddictServerEvents.HandleConfigurationRequestContext>() | ||
.UseSingletonHandler<AttachScopes>() | ||
.SetOrder(OpenIddictServerHandlers.Discovery.AttachScopes.Descriptor.Order + 1) | ||
.SetType(OpenIddictServerHandlerType.Custom) | ||
.Build(); | ||
|
||
private readonly IOpenIddictScopeRepository _scopeRepository; | ||
|
||
public AttachScopes(IOpenIddictScopeRepository scopeRepository) | ||
{ | ||
_scopeRepository = scopeRepository; | ||
} | ||
|
||
public async ValueTask HandleAsync(OpenIddictServerEvents.HandleConfigurationRequestContext context) | ||
{ | ||
if (context is null) | ||
{ | ||
throw new ArgumentNullException(nameof(context)); | ||
} | ||
|
||
var scopes = await _scopeRepository.GetListAsync(); | ||
context.Scopes.UnionWith(scopes.Select(x => x.Name)); | ||
} | ||
} |