예제 #1
0
        private Session GetClientSession(SSOClient client, User user, ServerSession session)
        {
            var userRoles = repoUserRole.Query(o => o.UserId == user.UserId);
            var roles = userRoles.Select(o => o.RoleId).ToArray();
            var rolePermissions = repoRolePermission.Query(o => userRoles.Any(ur => ur.RoleId == o.RoleId)).ToArray();

            var appUris = GetAppProtectedUris();

            var sps = appProtectedUris.Select(o => new SimplePermission()
            {
                ClientId = o.Item1,
                PermissionType = o.Item2,
                ProtectedUris = o.Item3.Select(p => p.Uri).ToArray(),
                AllowedUris = o.Item3.Where(u => rolePermissions.HasPermitted(u)).Select(u => u.Uri).ToArray()
            }).ToArray();

            return new Session()
            {
                ClientId = client.ClientId,
                ClientName = client.ClientName,
                ClientBaseUrl = client.BaseUrl,
                SessionId = session.SessionId,
                AccessToken = session.AccessToken,
                User = user.ToUserSession(),
                Roles = roles,

                DeviceId = session.DeviceId,
                DeviceInfo = session.DeviceInfo,

                Theme = string.IsNullOrEmpty(user.Theme) ? "Default" : user.Theme,
                Skin = string.IsNullOrEmpty(user.Skin) ? "Default" : user.Skin,
                Locale = string.IsNullOrEmpty(user.Locale) ? System.Threading.Thread.CurrentThread.CurrentCulture.Name : user.Locale,
                TimeZone = user.TimeZone,

                Permissions = sps
            };
        }
예제 #2
0
 public IEncryptionProvider GetClientEncryptor(SSOClient client)
 {
     return new AESEncryptionProvider(client.EncryptKey, client.EncryptScrect);
 }