protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { AuthenticateClient.CheckUserTicket(); var userInfo = AuthenticateClient.CurrentUser; } }
public override void Respond(IHttpContext context) { if (context.Request.Headers["Accept"] != TokenContentType) { context.Response.StatusCode = (int)HttpStatusCode.BadRequest; context.WriteJson(new { error = "invalid_request", error_description = "Accept should be: " + TokenContentType }); return; } if (context.Request.Headers["grant_type"] != TokenGrantType) { context.Response.StatusCode = (int)HttpStatusCode.BadRequest; context.WriteJson(new { error = "unsupported_grant_type", error_description = "Only supported grant_type is: " + TokenGrantType }); return; } var identity = GetUserAndPassword(context); if (identity == null) { context.Response.StatusCode = (int)HttpStatusCode.Unauthorized; context.Response.AddHeader("WWW-Authenticate", "Basic realm=\"Raven DB\""); context.WriteJson(new { error = "invalid_client", error_description = "No client authentication was provided" }); return; } List <DatabaseAccess> authorizedDatabases; if (!AuthenticateClient.Authenticate(Database, identity.Item1, identity.Item2, out authorizedDatabases)) { if ((Database == SystemDatabase || !AuthenticateClient.Authenticate(SystemDatabase, identity.Item1, identity.Item2, out authorizedDatabases))) { context.Response.StatusCode = (int)HttpStatusCode.Unauthorized; context.Response.AddHeader("WWW-Authenticate", "Basic realm=\"Raven DB\""); context.WriteJson(new { error = "unauthorized_client", error_description = "Invalid client credentials" }); return; } } Interlocked.Increment(ref numberOfTokensIssued); var userId = identity.Item1; var token = AccessToken.Create(Settings.OAuthTokenKey, new AccessTokenBody { UserId = userId, AuthorizedDatabases = authorizedDatabases }); context.Write(token.Serialize()); }
public bool Authenticate(string username, string password, string domain) { LDAPAuth.AuthenticateClient authService = new AuthenticateClient(); string ldapUrl = System.Configuration.ConfigurationManager.AppSettings["ldapUrl"]; authService.InnerChannel.OperationTimeout = System.TimeSpan.MaxValue; bool retData = authService.Authenticate(username, domain, password, ldapUrl); return(retData); }
public string FetchUserDetails() { LDAPAuth.AuthenticateClient authService = new AuthenticateClient(); authService.InnerChannel.OperationTimeout = System.TimeSpan.MaxValue; var searchResult = authService.FetchUserDetails(Username); string result = ""; foreach (Dictionary <string, string> d in searchResult) { result += String.Join("\r\n", d.Select(x => x.Key + ": " + x.Value).ToArray()) + "\r\n"; } return(result); }
public GetTokenByRefreshTokenGrantTypeAction( IEventPublisher eventPublisher, ITokenStore tokenStore, IJwksStore jwksRepository, IResourceOwnerRepository resourceOwnerRepository, IClientStore clientStore) { _eventPublisher = eventPublisher; _tokenStore = tokenStore; _jwksRepository = jwksRepository; _resourceOwnerRepository = resourceOwnerRepository; _clientStore = clientStore; _authenticateClient = new AuthenticateClient(clientStore, jwksRepository); }
public GetTokenByAuthorizationCodeGrantTypeAction( IAuthorizationCodeStore authorizationCodeStore, RuntimeSettings configurationService, IClientStore clientStore, IEventPublisher eventPublisher, ITokenStore tokenStore, IJwksStore jwksStore) { _authorizationCodeStore = authorizationCodeStore; _configurationService = configurationService; _authenticateClient = new AuthenticateClient(clientStore, jwksStore); _eventPublisher = eventPublisher; _tokenStore = tokenStore; _jwksStore = jwksStore; }
public GetTokenByResourceOwnerCredentialsGrantTypeAction( IClientStore clientStore, IScopeStore scopeRepository, ITokenStore tokenStore, IJwksStore jwksStore, IEnumerable <IAuthenticateResourceOwnerService> resourceOwnerServices, IEventPublisher eventPublisher, ILogger logger) { _authenticateClient = new AuthenticateClient(clientStore, jwksStore); _jwtGenerator = new JwtGenerator(clientStore, scopeRepository, jwksStore, logger); _tokenStore = tokenStore; _jwksStore = jwksStore; _resourceOwnerServices = resourceOwnerServices.ToArray(); _eventPublisher = eventPublisher; }
public TokenActions( RuntimeSettings simpleAuthOptions, IAuthorizationCodeStore authorizationCodeStore, IClientStore clientStore, IScopeStore scopeRepository, IJwksStore jwksStore, IResourceOwnerRepository resourceOwnerRepository, IEnumerable <IAuthenticateResourceOwnerService> resourceOwnerServices, IEventPublisher eventPublisher, ITokenStore tokenStore, IDeviceAuthorizationStore deviceAuthorizationStore, ILogger logger) { _getTokenByDeviceAuthorizationTypeAction = new GetTokenByDeviceAuthorizationTypeAction( deviceAuthorizationStore, tokenStore, jwksStore, clientStore, eventPublisher, logger); _getTokenByResourceOwnerCredentialsGrantType = new GetTokenByResourceOwnerCredentialsGrantTypeAction( clientStore, scopeRepository, tokenStore, jwksStore, resourceOwnerServices, eventPublisher, logger); _getTokenByAuthorizationCodeGrantTypeAction = new GetTokenByAuthorizationCodeGrantTypeAction( authorizationCodeStore, simpleAuthOptions, clientStore, eventPublisher, tokenStore, jwksStore); _getTokenByRefreshTokenGrantTypeAction = new GetTokenByRefreshTokenGrantTypeAction( eventPublisher, tokenStore, jwksStore, resourceOwnerRepository, clientStore); _authenticateClient = new AuthenticateClient(clientStore, jwksStore); _revokeTokenAction = new RevokeTokenAction(clientStore, tokenStore, jwksStore, logger); _jwksStore = jwksStore; _eventPublisher = eventPublisher; _tokenStore = tokenStore; }
/// <summary> /// Create a new instance of the GroupShare API v1 client using the specified connection. /// </summary> /// <param name="connection">The underlying <seealso cref="IConnection"/> used to make requests</param> public GroupShareClient(IConnection connection) { Ensure.ArgumentNotNull(connection, "connection"); Connection = connection; var apiConnection = new ApiConnection(connection); Project = new ProjectClient(apiConnection); User = new UserClient(apiConnection); Organization = new OrganizationClient(apiConnection); Authenticate = new AuthenticateClient(apiConnection); Role = new RoleClient(apiConnection); Permission = new PermissionClient(apiConnection); ModuleClient = new ModuleClient(apiConnection); License = new LicenseClient(apiConnection); TranslationMemories = new TranslationMemoriesClient(apiConnection); Terminology = new TerminologyClient(apiConnection); }
private void btnLogIn_Click(object sender, RoutedEventArgs e) { lblError.Content = ""; byte[] cipheredKeyContainer = new byte[64]; IAuthenticate proxy = new AuthenticateClient(); LavaResult result = proxy.Authenticate(tbUserName.Text, pbPassword.Password); if (result.Result == LAVA_ERROR_CODE.NO_MASTER_KEY) { MasterKeyWindow msKeyWnd = new MasterKeyWindow(); msKeyWnd.ShowDialog(); byte[] masterKey = CryptoLibrary.generateRandom(32); byte[] keyContainer = TLVUtil.StoreTag(0x25, masterKey); cipheredKeyContainer = CryptoLibrary.encrypt28147cfb( CryptoLibrary.computeHash3411(Utility.StringToByteArray(MasterKeyWindow.Password)), keyContainer); result = proxy.StoreKeyContainer(tbUserName.Text, cipheredKeyContainer); if (result.Result != LAVA_ERROR_CODE.OK) { lblError.Content = "Error while putting container: " + result.Result.ToString(); return; } } if (result.Result == LAVA_ERROR_CODE.OK) { EnterMasterKey enterKey = new EnterMasterKey(tbUserName.Text, (AuthenticateClient)proxy); enterKey.ShowDialog(); byte[] key = EnterMasterKey.key; this.Close(); LavaUser user = new LavaUser(tbUserName.Text, pbPassword.Password); user.MasterKey = key; wnd.Show(user); } else lblError.Content = "wrong name or pword"; }
public UmaTokenActions( ITicketStore ticketStore, RuntimeSettings configurationService, IClientStore clientStore, IScopeStore scopeRepository, ITokenStore tokenStore, IResourceSetRepository resourceSetRepository, IJwksStore jwksStore, IEventPublisher eventPublisher, ILogger logger) { _ticketStore = ticketStore; _configurationService = configurationService; _authorizationPolicyValidator = new AuthorizationPolicyValidator( jwksStore, resourceSetRepository, eventPublisher); _authenticateClient = new AuthenticateClient(clientStore, jwksStore); _jwtGenerator = new JwtGenerator(clientStore, scopeRepository, jwksStore, logger); _tokenStore = tokenStore; _eventPublisher = eventPublisher; _logger = logger; }
public ActionResult Index( //bind form values to the class preceeding square brackets [Bind(Include = "ClientEmail, ClientPassword")] AuthenticateClient authClient) { Message argMessage = new Message(); CommunityAssist2017Entities db = new CommunityAssist2017Entities(); /*Logging In *For the login validation we will use the built in stored procedure *usp_login which takes a username (email) and a password.*/ int verifyAuthentication = db.usp_Login( authClient.ClientEmail, authClient.ClientPassword ); /*If the validation fails (the stored procedure returns a -1 if it *fails), the Result page should say something like Validation *failed, please try again or register if you have not done so yet.*/ if ( verifyAuthentication != -1 ) { var personKey = ( from r in db.People where r.PersonEmail.Equals ( authClient.ClientEmail ) select r.PersonKey ).FirstOrDefault(); int clientKey = (int)personKey; Session["sessClientKey"] = clientKey; argMessage.MessageText = "Thank you for verifying creditials " + "of e-mail account: " + authClient.ClientEmail + "."; return RedirectToAction("Result", argMessage); } argMessage.MessageText = "Invaild authentication credentials " + "please try again or register if you have not done so yet."; return View("Result", argMessage); }
public AuthenticateClientFixture() { _clientRepositoryStub = new Mock <IClientStore>(); _authenticateClient = new AuthenticateClient(_clientRepositoryStub.Object, new InMemoryJwksRepository()); }
public ExtensionAuthenticationApi(string baseUrl, HttpClient httpClient) { _client = new AuthenticateClient(baseUrl, httpClient); }
public RevokeTokenAction(IClientStore clientStore, ITokenStore tokenStore, IJwksStore jwksStore, ILogger logger) { _authenticateClient = new AuthenticateClient(clientStore, jwksStore); _tokenStore = tokenStore; _logger = logger; }
public EnterMasterKey(string UserName, AuthenticateClient proxy) : this() { this.proxy = proxy; this.name = UserName; }