Beispiel #1
0
        private HashSet <string> GetSessionPermissions()
        {
            var session = _sessionCache.GetSession(_user.Value.Login);
            var set     = new HashSet <string>();

            set.UnionWith(session.Permissions);
            _logger.LogDebug("Permission set for {0} setup with {1} permissions.".ToFormat(_user.Value.Login, set.Count));
            return(set);
        }
Beispiel #2
0
        public IPrincipal CreatePrincipal(IIdentity identity)
        {
            var username = identity.Name;

            //if agent get session and use its permissions
            var session = _sessionCache.GetSession(username);

            _logger.LogDebug("Creating principal for user {0} with {1} permissions.", username, session.Permissions.Length);

            return(new DovetailPrincipal(identity, session.Permissions));
        }
Beispiel #3
0
        public IPrincipal CreatePrincipal(string username)
        {
            var validator = _principalValidatorFactory.Create();

            try
            {
                var validatedUsername = validator.UserValidator(username);

                var session = _sessionCache.GetSession(validatedUsername);
                _logger.LogDebug("Creating principal for user {0} with {1} roles sourced from permissions.", validatedUsername, session.Permissions.Length);

                return(new GenericPrincipal(new GenericIdentity(validatedUsername, "bootstrap"), session.Permissions));
            }
            catch (Exception e)
            {
                validator.FailureHandler(e);
                return(null);
            }
        }