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

            return(authRequest);
        }
コード例 #2
0
 private void setupPermissions(IAuthRequest request)
 {
     request.Uri         = _uri;
     request.AccountCode = _accountCode;
     request.UserName    = _userName;
     request.Password    = _password;
 }
コード例 #3
0
        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);
        }
コード例 #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);
        }
コード例 #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
        }
コード例 #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);
        }
コード例 #7
0
ファイル: SamlController.cs プロジェクト: maurbone/DocSuitePA
 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;
 }
コード例 #8
0
 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;
 }
コード例 #9
0
 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);
 }
コード例 #10
0
 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);
 }
コード例 #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));
        }
コード例 #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();
            }
        }
コード例 #13
0
 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);
     }
 }
コード例 #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));
        }
コード例 #15
0
 public void Foo(IAuthRequest r)
 {
     Called++;
 }
コード例 #16
0
 public void Auth(IAuthRequest r)
 {
 }
コード例 #17
0
 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;
 }
コード例 #18
0
 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);
 }
コード例 #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;
 }
コード例 #20
0
 public void Bar(IAuthRequest r)
 {
 }
コード例 #21
0
 public void AuthenticateUser(IAuthRequest req, AuthEndResponseDelegate callbackHandler)
 {
 }
コード例 #22
0
 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);
 }
コード例 #23
0
 public void AuthenticateUser(IAuthRequest req, AuthEndResponseDelegate callbackHandler)
 {
 }
コード例 #24
0
 public void LogoutUser(IAuthRequest req, AuthEndResponseDelegate callbackHandler)
 {
 }
コード例 #25
0
 public void Foo‿Bar(IAuthRequest r)
 {
 }
コード例 #26
0
 public void LogoutUser(IAuthRequest req, AuthEndResponseDelegate callbackHandler)
 {
 }
コード例 #27
0
 public void Foo(IAuthRequest r)
 {
 }
コード例 #28
0
 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;
 }
コード例 #29
0
 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;
     }
 }
コード例 #30
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="request"></param>
 /// <returns></returns>
 public async Task <IAuthResponse> Auth(IAuthRequest request)
 {
     return(await _bankIdHttpClientService.RequestClient <AuthResponse, IAuthRequest>(request, "auth"));
 }