Example #1
0
        /**
         * 返回AuthRequest对象
         *
         * @return {@link AuthRequest}
         */
        public IAuthRequest getRequest(string authSource)
        {
            // 获取 CollectiveOAuth 中已存在的
            IAuthRequest authRequest = getDefaultRequest(authSource);

            return(authRequest);
        }
Example #2
0
 private void setupPermissions(IAuthRequest request)
 {
     request.Uri         = _uri;
     request.AccountCode = _accountCode;
     request.UserName    = _userName;
     request.Password    = _password;
 }
        public void AeriaMakePayment(IAuthRequest req, AuthEndResponseDelegate callbackHandler, Control ctrl)
        {
            this.FormsControl   = ctrl;
            this.CallbackMethod = callbackHandler;
            this.mRequest       = (XmlRpcAuthRequest)req;
            AuthProxy proxy = XmlRpcProxyGen.Create <AuthProxy>();

            proxy.Url = this.EndpointUri;
            proxy.BeginAeriaMakePayment(this.mRequest.Request, new AsyncCallback(this.AeriaMakePaymentResponse), null);
        }
Example #4
0
        public Result Validate(IAuthRequest request)
        {
            Result result = new Result(true);

            if (!_regex.IsMatch(request.Email))
            {
                result.AddError(ErrorCodes.AUTH_EMAIL_INVALID);
            }
            return(result);
        }
Example #5
0
        private T PostRequest <T>(string requestQuery, IAuthRequest requestData)
        {
            var request = new RestRequest(requestQuery)
                          .AddJsonBody(requestData);

            var result = _client.Post <T>(request);

            CheckRequestResult(result);

            return(result.Data); // TODO: Add try-catch with logs
        }
Example #6
0
        public Result Validate(IAuthRequest request)
        {
            Result result = new Result(true);

            if (!request.Password.Equals(request.Confirmation))
            {
                result.AddError(ErrorCodes.AUTH_PASSWORD_CONFIRMATION_NOT_EQ);
            }
            if (request.Password.Length < _config.PasswordLength)
            {
                result.AddError(ErrorCodes.AUTH_PASSWORD_LENGTH);
            }
            return(result);
        }
Example #7
0
 public SamlController(ILoggerFactory logger, IOptions <AuthConfiguration> spidConfiguration,
                       RequestOptionFactory requestOptionFactory, IAuthRequest authRequest, IAuthResponse authResponse, ILogoutResponse logoutResponse,
                       ITokenService tokenService, IdpHelper idpHelper, IDataProtectionService dataProtectionService)
 {
     _logger                = logger.CreateLogger(LogCategories.AUTHENGINE);
     _traceLogger           = logger.CreateLogger(LogCategories.SAMLTRACE);
     _sessionAuthLogger     = logger.CreateLogger(LogCategories.AUTHSESSION);
     _spidConfiguration     = spidConfiguration?.Value;
     _requestOptionFactory  = requestOptionFactory;
     _authRequest           = authRequest;
     _authResponse          = authResponse;
     _logoutResponse        = logoutResponse;
     _tokenService          = tokenService;
     _idpHelper             = idpHelper;
     _dataProtectionService = dataProtectionService;
 }
 public BankIDController(
     IBankIDService bankIdService,
     IAuthRequest authRequest,
     ISignRequest signRequest,
     ICancelRequest cancelRequest,
     ICollectRequest collectRequest,
     IStatusHandler statusHandler,
     IHttpContextAccessor httpContextAccessor)
 {
     _bankIdService       = bankIdService;
     _authRequest         = authRequest;
     _signRequest         = signRequest;
     _cancelRequest       = cancelRequest;
     _collectRequest      = collectRequest;
     _statusHandler       = statusHandler;
     _httpContextAccessor = httpContextAccessor;
 }
 public XmlRpcAuthResponse AeriaMakePayment(IAuthRequest req, AuthEndResponseDelegate callbackHandler, Control ctrl, int timeout)
 {
     try
     {
         this.FormsControl   = ctrl;
         this.CallbackMethod = callbackHandler;
         this.mRequest       = (XmlRpcAuthRequest)req;
         AuthProxy proxy = XmlRpcProxyGen.Create <AuthProxy>();
         proxy.Url     = this.EndpointUri;
         proxy.Timeout = timeout;
         XmlRpcRespStruct struct2 = proxy.AeriaMakePayment(this.mRequest.Request);
         this.mResponse = new XmlRpcAuthResponse(struct2.mMessage, struct2.mSuccessCode, struct2.mUserGUID, struct2.mUsername, struct2.mEmailAddress, struct2.mPassword, struct2.mSessionID, struct2.mIPAddress, struct2.mPlatform, struct2.mRawCards, struct2.mCrowns, struct2.mCardpoints, struct2.mPremiumCards, struct2.mRawOffers, struct2.mRawPacks, struct2.mRawSharers, struct2.mRawTokens, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, struct2.mRawProducts, null);
     }
     catch (Exception)
     {
         this.mResponse = new XmlRpcAuthResponse("Login Server Unavailable, please try again later", 0, this.mRequest.UserGUID, this.mRequest.Username, this.mRequest.EmailAddress, this.mRequest.Password, this.mRequest.SessionID, this.mRequest.IPAddress, this.mRequest.Platform, null, 0, 0, 0, null, null, null, null);
     }
     return(this.mResponse);
 }
 public XmlRpcAuthResponse RenameParish(IAuthRequest req, AuthEndResponseDelegate callbackHandler, Control ctrl, int timeout)
 {
     try
     {
         this.FormsControl   = ctrl;
         this.CallbackMethod = callbackHandler;
         this.mRequest       = (XmlRpcAuthRequest)req;
         AuthProxy proxy = XmlRpcProxyGen.Create <AuthProxy>();
         proxy.Url     = this.EndpointUri;
         proxy.Timeout = timeout;
         XmlRpcRespStruct struct2 = proxy.RenameParish(this.mRequest.Request);
         this.mResponse = new XmlRpcAuthResponse(struct2.mMessage, struct2.mSuccessCode);
     }
     catch (Exception)
     {
         this.mResponse = new XmlRpcAuthResponse("Login Server Unavailable, please try again later", 0, this.mRequest.UserGUID, this.mRequest.Username, this.mRequest.EmailAddress, this.mRequest.Password, this.mRequest.SessionID, this.mRequest.IPAddress, this.mRequest.Platform, null, 0, 0, 0, null, null, null, null);
     }
     return(this.mResponse);
 }
Example #11
0
        public async Task <Result <IAuthResponse> > SignIn(IAuthRequest request, ClaimsPrincipal principal)
        {
            try
            {
                Result <User> userResult = await _usersRepo.Get(
                    u => request.Email.Equals(u.Email, StringComparison.OrdinalIgnoreCase));

                User user = userResult.Data;
                if (user == null)
                {
                    userResult.AddError(ErrorCodes.AUTH_EMAIL_NOT_FOUND);
                    return(Result <IAuthResponse> .Error(userResult.ErrorCodes));
                }
                if (!user.Password.SequenceEqual(GetHash(request.Password)))
                {
                    userResult.AddError(ErrorCodes.AUTH_EMAIL_OR_PASSWORD_INCORRECT);
                    return(Result <IAuthResponse> .Error(userResult.ErrorCodes));
                }
                var claims = new Claim[]
                {
                    new Claim(ClaimTypes.Sid, user.Id.ToString())
                };
                var identity = new ClaimsIdentity(claims);
                principal.AddIdentity(identity);

                var now = DateTime.UtcNow;
                JwtSecurityToken token = new JwtSecurityToken(
                    issuer: _config.Issuer,
                    audience: _config.Audience,
                    claims: identity.Claims,
                    notBefore: now,
                    expires: now.Add(TimeSpan.FromHours(_config.Lifetime)),
                    signingCredentials: new SigningCredentials(_key, SecurityAlgorithms.HmacSha256));
                _logger.LogInformation($"User {user} signed in.");
                return(Result <IAuthResponse> .Success(
                           new AuthResponse(new JwtSecurityTokenHandler().WriteToken(token))));
            }
            catch (Exception ex)
            {
                _logger.LogError(ex.Message);
            }
            return(Result <IAuthResponse> .Error(ErrorCodes.UNEXPECTED));
        }
Example #12
0
        /// <summary>
        /// Method called on an auth request.
        /// </summary>
        /// <param name="request">Auth request context.</param>
        private async Task handleAuth(IAuthRequest request)
        {
            if (authMethods != null)
            {
                if (authMethods.TryGetValue(request.Method, out Func <IAuthRequest, Task> handler))
                {
                    await handler(request);

                    return;
                }
            }
            if (authHandler != null)
            {
                await authHandler.Invoke(request);
            }
            else
            {
                request.MethodNotFound();
            }
        }
 public int AeriaGetBalance(IAuthRequest req, AuthEndResponseDelegate callbackHandler, Control ctrl, int timeout, ref XmlRpcAuthResponse response)
 {
     try
     {
         this.FormsControl   = ctrl;
         this.CallbackMethod = callbackHandler;
         this.mRequest       = (XmlRpcAuthRequest)req;
         AuthProxy proxy = XmlRpcProxyGen.Create <AuthProxy>();
         proxy.Url     = this.EndpointUri;
         proxy.Timeout = timeout;
         XmlRpcRespStruct struct2 = proxy.AeriaGetBalance(this.mRequest.Request);
         int num = 0;
         num                     = struct2.mPoints.Value;
         this.mResponse          = new XmlRpcAuthResponse();
         this.mResponse.Products = struct2.mRawProducts;
         response                = this.mResponse;
         return(num);
     }
     catch (Exception)
     {
         return(0);
     }
 }
Example #14
0
        public async Task <Result <IAuthResponse> > Register(IAuthRequest request, ClaimsPrincipal principal)
        {
            try
            {
                var user = new User()
                {
                    Email    = request.Email,
                    Password = GetHash(request.Password)
                };
                Result <User> userResult = await _usersRepo.Get(
                    u => u.Email.Equals(user.Email, StringComparison.OrdinalIgnoreCase));

                if (userResult.Data != null)
                {
                    userResult.AddError(ErrorCodes.AUTH_EMAIL_IN_USE);
                }
                foreach (var rule in _rules)
                {
                    var ruleResult = rule.Validate(request);
                    userResult.AddErrors(ruleResult.ErrorCodes);
                }
                if (!userResult.IsSuccess)
                {
                    return(Result <IAuthResponse> .Error(userResult.ErrorCodes));
                }
                await _usersRepo.Add(user);

                _dataService.SaveChanges();
                _logger.LogInformation($"User {user} registered.");
                return(await SignIn(request, principal));
            }
            catch (Exception ex)
            {
                _logger.LogError(ex.Message);
            }
            return(Result <IAuthResponse> .Error(ErrorCodes.UNEXPECTED));
        }
Example #15
0
 public void Foo(IAuthRequest r)
 {
     Called++;
 }
Example #16
0
 public void Auth(IAuthRequest r)
 {
 }
 public XmlRpcAuthResponse SteamPaymentInit(IAuthRequest req, AuthEndResponseDelegate callbackHandler, Control ctrl, int timeout)
 {
     this.FormsControl = ctrl;
     this.CallbackMethod = callbackHandler;
     this.mRequest = (XmlRpcAuthRequest) req;
     AuthProxy proxy = XmlRpcProxyGen.Create<AuthProxy>();
     proxy.Url = this.EndpointUri;
     proxy.Timeout = timeout;
     XmlRpcRespStruct struct2 = proxy.SteamPaymentInit(this.mRequest.Request);
     try
     {
         this.mResponse = new XmlRpcAuthResponse(struct2.mMessage, struct2.mSuccessCode, struct2.mUserGUID, struct2.mUsername, struct2.mEmailAddress, struct2.mPassword, struct2.mSessionID, struct2.mIPAddress, struct2.mPlatform, struct2.mRawCards, struct2.mCrowns, struct2.mCardpoints, struct2.mPremiumCards, struct2.mRawOffers, struct2.mRawPacks, struct2.mRawSharers, struct2.mRawTokens, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, struct2.mRawProducts, null);
     }
     catch (Exception)
     {
         this.mResponse = new XmlRpcAuthResponse("Login Server Unavailable, please try again later", 0, this.mRequest.UserGUID, this.mRequest.Username, this.mRequest.EmailAddress, this.mRequest.Password, this.mRequest.SessionID, this.mRequest.IPAddress, this.mRequest.Platform, null, 0, 0, 0, null, null, null, null);
     }
     return this.mResponse;
 }
 public void SetEmailOptIn(IAuthRequest req, AuthEndResponseDelegate callbackHandler, Control ctrl)
 {
     this.FormsControl = ctrl;
     this.CallbackMethod = callbackHandler;
     this.mRequest = (XmlRpcAuthRequest) req;
     AuthProxy proxy = XmlRpcProxyGen.Create<AuthProxy>();
     proxy.Url = this.EndpointUri;
     proxy.BeginsetEmailOptIn(this.mRequest.Request, new AsyncCallback(this.SetEmailOptInResponse), null);
 }
Example #19
0
 /// <summary>
 /// 初始化用户服务
 /// </summary>
 /// <param name="unitOfWork">工作单元</param>
 /// <param name="userRepository">用户仓储</param>
 public UserService(IUniversalSysCenterUnitOfWork unitOfWork, IUserRepository userRepository, IAuthRequest authRequest)
     : base(unitOfWork, userRepository)
 {
     UserRepository = userRepository;
     _authRequest   = authRequest;
 }
Example #20
0
 public void Bar(IAuthRequest r)
 {
 }
 public void AuthenticateUser(IAuthRequest req, AuthEndResponseDelegate callbackHandler)
 {
 }
 public void AuthenticateSteamAccount(IAuthRequest req, AuthEndResponseDelegate callbackHandler, Control ctrl)
 {
     this.FormsControl = ctrl;
     this.CallbackMethod = callbackHandler;
     this.mRequest = (XmlRpcAuthRequest) req;
     AuthProxy proxy = XmlRpcProxyGen.Create<AuthProxy>();
     proxy.Url = this.EndpointUri;
     proxy.BeginAuthSteamAccount(this.mRequest.Request, new AsyncCallback(this.AuthenticateSteamAccountResponse), null);
 }
 public void AuthenticateUser(IAuthRequest req, AuthEndResponseDelegate callbackHandler)
 {
 }
 public void LogoutUser(IAuthRequest req, AuthEndResponseDelegate callbackHandler)
 {
 }
Example #25
0
 public void Foo‿Bar(IAuthRequest r)
 {
 }
 public void LogoutUser(IAuthRequest req, AuthEndResponseDelegate callbackHandler)
 {
 }
Example #27
0
 public void Foo(IAuthRequest r)
 {
 }
 public XmlRpcAuthResponse RenameParish(IAuthRequest req, AuthEndResponseDelegate callbackHandler, Control ctrl, int timeout)
 {
     try
     {
         this.FormsControl = ctrl;
         this.CallbackMethod = callbackHandler;
         this.mRequest = (XmlRpcAuthRequest) req;
         AuthProxy proxy = XmlRpcProxyGen.Create<AuthProxy>();
         proxy.Url = this.EndpointUri;
         proxy.Timeout = timeout;
         XmlRpcRespStruct struct2 = proxy.RenameParish(this.mRequest.Request);
         this.mResponse = new XmlRpcAuthResponse(struct2.mMessage, struct2.mSuccessCode);
     }
     catch (Exception)
     {
         this.mResponse = new XmlRpcAuthResponse("Login Server Unavailable, please try again later", 0, this.mRequest.UserGUID, this.mRequest.Username, this.mRequest.EmailAddress, this.mRequest.Password, this.mRequest.SessionID, this.mRequest.IPAddress, this.mRequest.Platform, null, 0, 0, 0, null, null, null, null);
     }
     return this.mResponse;
 }
 public int AeriaGetBalance(IAuthRequest req, AuthEndResponseDelegate callbackHandler, Control ctrl, int timeout, ref XmlRpcAuthResponse response)
 {
     try
     {
         this.FormsControl = ctrl;
         this.CallbackMethod = callbackHandler;
         this.mRequest = (XmlRpcAuthRequest) req;
         AuthProxy proxy = XmlRpcProxyGen.Create<AuthProxy>();
         proxy.Url = this.EndpointUri;
         proxy.Timeout = timeout;
         XmlRpcRespStruct struct2 = proxy.AeriaGetBalance(this.mRequest.Request);
         int num = 0;
         num = struct2.mPoints.Value;
         this.mResponse = new XmlRpcAuthResponse();
         this.mResponse.Products = struct2.mRawProducts;
         response = this.mResponse;
         return num;
     }
     catch (Exception)
     {
         return 0;
     }
 }
 /// <summary>
 ///
 /// </summary>
 /// <param name="request"></param>
 /// <returns></returns>
 public async Task <IAuthResponse> Auth(IAuthRequest request)
 {
     return(await _bankIdHttpClientService.RequestClient <AuthResponse, IAuthRequest>(request, "auth"));
 }