Exemple #1
0
        public void Authenticate(User user, AuthenticationRequestContext ctx = null)
        {
            if (user == null)
            {
                return;
            }
            var token  = user.AuthToken;
            var reuser = Authenticate(token, ctx);

            user.___update_status(reuser.Status, reuser.Name, reuser.Description, reuser.Rights, App.TimeSource.UTCNow);
        }
Exemple #2
0
        public User Authenticate(SysAuthToken token, AuthenticationRequestContext ctx = null)
        {
            var credentials = authTokenToCred(token);

            return(Authenticate(credentials, ctx));
        }
Exemple #3
0
 public Task AuthenticateAsync(User user, AuthenticationRequestContext ctx = null)
 {
     Authenticate(user, ctx); return(Task.CompletedTask);
 }
Exemple #4
0
        public User Authenticate(Credentials credentials, AuthenticationRequestContext ctx = null)
        {
            if (credentials is BearerCredentials bearer)
            {
                var oauth = App.ModuleRoot.TryGet <Services.IOAuthModule>();
                if (oauth == null)
                {
                    return(MakeBadUser(credentials));
                }

                var accessToken = oauth.TokenRing.GetAsync <Tokens.AccessToken>(bearer.Token).GetAwaiter().GetResult(); //since this manager is sync-only
                if (accessToken != null)                                                                                //if token is valid
                {
                    if (SysAuthToken.TryParse(accessToken.SubjectSysAuthToken, out var sysToken))
                    {
                        return(Authenticate(sysToken, ctx));
                    }
                }
            }

            var sect = m_Config ?? App.ConfigRoot[CommonApplicationLogic.CONFIG_SECURITY_SECTION];

            if (sect.Exists)
            {
                IConfigSectionNode usern = sect.Configuration.EmptySection;

                if (credentials is IDPasswordCredentials idpass)
                {
                    usern = findUserNode(sect, idpass);
                }
                if (credentials is EntityUriCredentials enturi)
                {
                    usern = findUserNode(sect, enturi);
                }

                if (usern.Exists)
                {
                    var name   = usern.AttrByName(CONFIG_NAME_ATTR).ValueAsString(string.Empty);
                    var descr  = usern.AttrByName(CONFIG_DESCRIPTION_ATTR).ValueAsString(string.Empty);
                    var status = usern.AttrByName(CONFIG_STATUS_ATTR).ValueAsEnum(UserStatus.Invalid);

                    var rights = Rights.None;

                    var rightsn = usern[CONFIG_RIGHTS_SECTION];

                    if (rightsn.Exists)
                    {
                        var data = new MemoryConfiguration();
                        data.CreateFromNode(rightsn);
                        rights = new Rights(data);
                    }

                    return(MakeUser(credentials,
                                    credToAuthToken(credentials),
                                    status,
                                    name,
                                    descr,
                                    rights));
                }
            }

            return(MakeBadUser(credentials));
        }
Exemple #5
0
 public Task <User> AuthenticateAsync(SysAuthToken token, AuthenticationRequestContext ctx = null) => Task.FromResult(Authenticate(token, ctx));
Exemple #6
0
 public Task <User> AuthenticateAsync(Credentials credentials, AuthenticationRequestContext ctx = null) => Task.FromResult(Authenticate(credentials, ctx));
Exemple #7
0
 public Task AuthenticateAsync(User user, AuthenticationRequestContext ctx = null) => Task.CompletedTask;
Exemple #8
0
 public void Authenticate(User user, AuthenticationRequestContext ctx = null)
 {
 }
Exemple #9
0
 public User Authenticate(SysAuthToken token, AuthenticationRequestContext ctx             = null) => User.Fake;
Exemple #10
0
 public User Authenticate(Credentials credentials, AuthenticationRequestContext ctx             = null) => User.Fake;