public ClsApplication IsAuthenticated(string clientId) { ClsGetApplication getApplication = new ClsGetApplication() { appId = clientId }; ClsApplication application = repository.GetApplication(getApplication); return(application); }
public override Task ValidateClientAuthentication(OAuthValidateClientAuthenticationContext context) { string clientId = string.Empty; string clientSecret = string.Empty; ClsApplication client = null; if (!context.TryGetBasicCredentials(out clientId, out clientSecret)) { context.TryGetFormCredentials(out clientId, out clientSecret); } if (clientId == null) { clientId = "NULL"; } iICLabsService.AddLog(clientId, "Authentication", "RemoteIP:" + context.Request.RemoteIpAddress + ";ClientId:" + clientId); if (context.ClientId == null) { context.SetError("invalid_clientId", "ClientId should be sent."); return(Task.FromResult <object>(null)); } if (string.IsNullOrWhiteSpace(clientSecret)) { context.SetError("invalid_clientId", "Client secret should be sent."); return(Task.FromResult <object>(null)); } else { client = iICLabsService.IsAuthenticated(clientId); if (client == null) { context.SetError("invalid_clientId", string.Format("Client '{0}' is not registered in the system. ", context.ClientId)); return(Task.FromResult <object>(null)); } if (client.clientSecret != clientSecret) { context.SetError("invalid_clientId", "Client secret is invalid."); return(Task.FromResult <object>(null)); } } context.OwinContext.Set <string>("as:orgID", client.orgId); //context.OwinContext.Set<string>("as:clientRefreshTokenLifeTime", client.RefreshTokenLifeTime.ToString()); context.Validated(); return(Task.FromResult <object>(null)); }