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); }
public User Authenticate(SysAuthToken token, AuthenticationRequestContext ctx = null) { var credentials = authTokenToCred(token); return(Authenticate(credentials, ctx)); }
public Task AuthenticateAsync(User user, AuthenticationRequestContext ctx = null) { Authenticate(user, ctx); return(Task.CompletedTask); }
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)); }
public Task <User> AuthenticateAsync(SysAuthToken token, AuthenticationRequestContext ctx = null) => Task.FromResult(Authenticate(token, ctx));
public Task <User> AuthenticateAsync(Credentials credentials, AuthenticationRequestContext ctx = null) => Task.FromResult(Authenticate(credentials, ctx));
public Task AuthenticateAsync(User user, AuthenticationRequestContext ctx = null) => Task.CompletedTask;
public void Authenticate(User user, AuthenticationRequestContext ctx = null) { }
public User Authenticate(SysAuthToken token, AuthenticationRequestContext ctx = null) => User.Fake;
public User Authenticate(Credentials credentials, AuthenticationRequestContext ctx = null) => User.Fake;