[Question] Is there any way to force reload authorization provider during runtime?
See original GitHub issueAssume the following authorization provider:
namespace Languages.Authorization
{
public class LanguagesAuthorizationProvider : AuthorizationProvider
{
public override void SetPermissions(IPermissionDefinitionContext context)
{
using (var scope = IocManager.Instance.CreateScope())
{
var _permissionProvider = IocManager.Instance.Resolve<IPermissionManager>();
var _langManager = IocManager.Instance.Resolve<ILanguageManager>();
var administration = context.CreatePermission(PermissionNames.Administration);
var languages = administration.CreateChildPermission(PermissionNames.Administration_Languages);
languages.CreateChildPermission(PermissionNames.Administration_Languages_Create);
languages.CreateChildPermission(PermissionNames.Administration_Languages_Read);
languages.CreateChildPermission(PermissionNames.Administration_Languages_Update);
languages.CreateChildPermission(PermissionNames.Administration_Languages_Delete);
languages.CreateChildPermission(PermissionNames.Administration_Languages_List);
var languageTexts = languages.CreateChildPermission(PermissionNames.Administration_Languages_Texts);
languageTexts.CreateChildPermission(PermissionNames.Administration_Languages_Texts_List);
var languageTextsUpdate = languageTexts.CreateChildPermission(PermissionNames.Administration_Languages_Texts_Update);
var LanguageTextsRead = languageTexts.CreateChildPermission(PermissionNames.Administration_Languages_Texts_Read);
foreach (var lang in _langManager.GetLanguages())
{
languageTextsUpdate.CreateChildPermission($"{PermissionNames.Administration_Languages_Texts_Update}.{lang.Name}");
}
foreach (var lang in _langManager.GetLanguages())
{
LanguageTextsRead.CreateChildPermission($"{PermissionNames.Administration_Languages_Texts_Read}.{lang.Name}");
}
}
}
Now a new language is added but permissions provider is not aware of newly added language. Is there a way to force Authorization to reload permissions? It is somehow related to #3538 but the difference here is that permissions usage is predicted during design time: see for example part of LocalizationTextsAppService:
public async Task AddEditTranslation(LanguageTextsInput input)
{
await PermissionChecker.AuthorizeAsync(PermissionNames.Administration_Languages_Texts_Update + "." + input.Language);
if (input.Value == null) input.Value = "";
await _langTextsManager.UpdateStringAsync(null, input.Source, new System.Globalization.CultureInfo(input.Language), input.Key, input.Value);
}
For development i can easily restart app pool, but this is not an option to a highly traffic web app due to app pool warm up
Issue Analytics
- State:
- Created 5 years ago
- Comments:10 (2 by maintainers)
Top Results From Across the Web
How to reload authorities on user update with Spring Security
If a session exist, I can invalidate his session using : expireNow() (from SessionInformation ) to force re-authentication. But I don't ...
Read more >Auto Refresh Settings Changes in ASP.NET Core Runtime
Is there a way to refresh and apply it automatically after you modify the settings? Background. Let's take a look at a website...
Read more >Reload Java Classes at Runtime With JRebel
Read this post to learn how to reload Java classes at runtime, classloaders, and how JRebel bypasses reloads.
Read more >Three(+1) ways to refresh the claims of a logged-in user
In this article I describe three approaches: 1. Update user claims via cookie event: This is a relatively easy way to update the...
Read more >Live Reloading Server And Client Side ASP.NET Core Apps ...
Open a command Window in your Web project's folder · Type dotnet watch run · Open your browser and navigate to an API...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@raphaeldiasrj today i was facing this issue and just made this solution up you can try it i’m still in the middle of project building and it’s working fine with me
I copied this files and pasted them in my project (PermissionDefinitionContextBase , PermissionDictionary,PermissionManager).
In my Core Module in
PreInitialize()
And The PermissionManagerHandler
In Custom Permission Manager i Modified the Initialize Function by adding
Permissions.Clear();
then every time i add a new Permission i call the initialize function so i can republish every thingin Core Module PostInitilize Method add
IocManager.Resolve<PermissionManager>().Initialize();
Try to change the Namespace of the copied files to yours instead of Abp.Authorization
and be sure that the copied PermissionManager implements ISingletonDependency