private Permission[] LoadAllPermissions()
        {
            var manifestPermissions = new List <Permission>();

            var manifestsWithPermissions = _manifestProvider.GetModuleManifests().Values
                                           .Where(m => m.Permissions != null);

            foreach (var module in manifestsWithPermissions)
            {
                foreach (var group in module.Permissions)
                {
                    if (group.Permissions != null)
                    {
                        foreach (var modulePermission in group.Permissions)
                        {
                            var permission = modulePermission.ToCoreModel(module.Id, group.Name);
                            permission.AvailableScopes = _permissionScopeService.GetAvailablePermissionScopes(permission.Id).ToList();
                            manifestPermissions.Add(permission);
                        }
                    }
                }
            }

            var allPermissions = PredefinedPermissions.Permissions.Union(manifestPermissions).ToArray();

            return(allPermissions);
        }
Ejemplo n.º 2
0
        private ApplicationUserExtended GetUserExtended(UserEntity applicationUser, UserDetails detailsLevel)
        {
            ApplicationUserExtended result = null;

            if (applicationUser != null)
            {
                var cacheRegion = GetUserCacheRegion(applicationUser.Id.ToString());
                result = _cacheManager.Get(cacheRegion + ":" + detailsLevel, cacheRegion, () =>
                {
                    ApplicationUserExtended retVal;

                    var user = _baseUnitOfWork.BaseWorkArea.User.Query().First(x => x.UserName == applicationUser.UserName);
                    retVal   = applicationUser.ToCoreModel(user, _permissionScopeService);
                    //Populate available permission scopes
                    if (retVal.Roles != null)
                    {
                        foreach (var permission in retVal.Roles.SelectMany(x => x.Permissions).Where(x => x != null))
                        {
                            permission.AvailableScopes = _permissionScopeService.GetAvailablePermissionScopes(permission.Id).ToList();
                        }
                    }

                    if (detailsLevel != UserDetails.Export)
                    {
                        retVal.PasswordHash  = null;
                        retVal.SecurityStamp = null;
                    }
                    return(retVal);
                });
            }
            return(result);
        }
 public static Permission ToCoreModel(this dataModel.RolePermissionEntity source, IPermissionScopeService scopeService)
 {
     var result = new Permission();
     result.InjectFrom(source.Permission);
     result.AssignedScopes = source.Scopes.Select(x => new { source = x, target = scopeService.GetScopeByTypeName(x.Type) })
                                           .Where(x=> x.target != null)
                                           .Select(x=> x.source.ToCoreModel(x.target))
                                           .ToArray();
     result.AvailableScopes = scopeService.GetAvailablePermissionScopes(result.Id).ToArray();
     return result;
 }
        public static Permission ToCoreModel(this dataModel.RolePermissionEntity source, IPermissionScopeService scopeService)
        {
            var result = new Permission();

            result.InjectFrom(source.Permission);
            result.AssignedScopes = source.Scopes.Select(x => new { source = x, target = scopeService.GetScopeByTypeName(x.Type) })
                                    .Where(x => x.target != null)
                                    .Select(x => x.source.ToCoreModel(x.target))
                                    .ToArray();
            result.AvailableScopes = scopeService.GetAvailablePermissionScopes(result.Id).ToArray();
            return(result);
        }
Ejemplo n.º 5
0
        private Permission[] LoadAllPermissions()
        {
            var manifestPermissions = new List <Permission>();

            foreach (var module in _moduleCatalog.Modules.OfType <ManifestModuleInfo>())
            {
                foreach (var group in module.Permissions)
                {
                    if (group.Permissions != null)
                    {
                        foreach (var modulePermission in group.Permissions)
                        {
                            var permission = modulePermission.ToCoreModel(module.Id, group.Name);
                            permission.AvailableScopes = _permissionScopeService.GetAvailablePermissionScopes(permission.Id).ToList();
                            manifestPermissions.Add(permission);
                        }
                    }
                }
            }

            var allPermissions = PredefinedPermissions.Permissions.Union(manifestPermissions).ToArray();

            return(allPermissions);
        }
Ejemplo n.º 6
0
        public Role GetRole(string roleId)
        {
            Role result = null;

            using (var repository = _platformRepository())
            {
                var role = repository.GetRoleById(roleId);

                if (role != null)
                {
                    result = role.ToCoreModel(_permissionScopeService);
                    if (result.Permissions != null)
                    {
                        foreach (var permission in result.Permissions)
                        {
                            permission.AvailableScopes = _permissionScopeService.GetAvailablePermissionScopes(permission.Id).ToList();
                        }
                    }
                }
            }

            return(result);
        }