public InternalPermissionFinder(params AuthorizationProvider[] authorizationProviders)
            {
                foreach (var provider in authorizationProviders)
                {
                    provider.SetPermissions(this);
                }

                Permissions.AddAllPermissions();
            }
示例#2
0
        public void Initialize()
        {
            foreach (var providerType in _authorizationConfiguration.Providers)
            {
                CreateAuthorizationProvider(providerType).SetPermissions(this);
            }

            Permissions.AddAllPermissions();
        }
        public async Task <Abp.Authorization.Permission> CreatePermissionAsync(PermissionDefinition permission)
        {
            var newPermission = await _CreatePermissionAsync(permission);

            await _permissionDefinitionRepository.InsertOrUpdateAsync(permission);

            Permissions.AddAllPermissions();

            return(newPermission);
        }
示例#4
0
            public InternalPermissionFinder(params Type[] providerTypes)
            {
                foreach (var authorizationProviderType in providerTypes)
                {
                    var provider = (AuthorizationProvider)Activator.CreateInstance(authorizationProviderType);
                    provider.SetPermissions(this);
                }

                Permissions.AddAllPermissions();
            }
        public void Initialize()
        {
            foreach (var providerType in _authorizationConfiguration.Providers)
            {
                using (var provider = _iocManager.ResolveAsDisposable <AuthorizationProvider>(providerType))
                {
                    provider.Object.SetPermissions(this);
                }
            }

            Permissions.AddAllPermissions();
        }
示例#6
0
 public void Initialize()
 {
     foreach (var providerType in _authorizationConfiguration.Providers)
     {
         _iocManager.RegisterIfNot(providerType, DependencyLifeStyle.Transient); //TODO: Needed?
         using (var provider = _iocManager.ResolveAsDisposable <AuthorizationProvider>(providerType))
         {
             provider.Object.SetPermissions(this);
         }
     }
     Permissions.AddAllPermissions();
 }
        public async Task UpdateParentAsync(string name, string parentName)
        {
            var dbPermission = _permissionDefinitionRepository.GetAll().FirstOrDefault(x => x.Name == name);

            // ToDo: Add NotFound exception or something else
            if (dbPermission == null)
            {
                return;
            }

            InternalDeletePermission(dbPermission);

            dbPermission.Parent = parentName;
            await _CreatePermissionAsync(dbPermission);

            Permissions.AddAllPermissions();

            await _permissionDefinitionRepository.UpdateAsync(dbPermission);
        }
        public async Task <Abp.Authorization.Permission> EditPermissionAsync(string oldName, PermissionDefinition permission)
        {
            var dbPermission = _permissionDefinitionRepository.GetAll().FirstOrDefault(x => x.Name == oldName);

            // ToDo: Add NotFound exception or something else
            if (dbPermission == null)
            {
                return(null);
            }

            if (dbPermission.Name != permission.Name ||
                dbPermission.DisplayName != permission.DisplayName ||
                dbPermission.Description != permission.Description
                )
            {
                dbPermission.Name        = permission.Name;
                dbPermission.Description = permission.Description;
                dbPermission.DisplayName = permission.DisplayName;
                dbPermission.Parent      = permission.Parent;

                RemovePermission(oldName);
                var parent = !string.IsNullOrEmpty(permission.Parent)
                    ? GetPermissionOrNull(permission.Parent)
                    : null;

                parent?.RemoveChildPermission(oldName);

                var newPermission = await _CreatePermissionAsync(permission);

                await _permissionDefinitionRepository.InsertOrUpdateAsync(dbPermission);

                Permissions.AddAllPermissions();

                return(newPermission);
            }

            return(GetPermissionOrNull(oldName));
        }