当前位置: 首页>>代码示例>>C#>>正文


C# AuthenticationTokenReceiveContext.DeserializeTicket方法代码示例

本文整理汇总了C#中Microsoft.Owin.Security.Infrastructure.AuthenticationTokenReceiveContext.DeserializeTicket方法的典型用法代码示例。如果您正苦于以下问题:C# AuthenticationTokenReceiveContext.DeserializeTicket方法的具体用法?C# AuthenticationTokenReceiveContext.DeserializeTicket怎么用?C# AuthenticationTokenReceiveContext.DeserializeTicket使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.Owin.Security.Infrastructure.AuthenticationTokenReceiveContext的用法示例。


在下文中一共展示了AuthenticationTokenReceiveContext.DeserializeTicket方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ReceiveAsync

        public async Task ReceiveAsync(AuthenticationTokenReceiveContext context)
        {
            try
            {
                var allowedOrigin = context.OwinContext.Get<string>("as:clientAllowedOrigin") ?? "*";
                context.OwinContext.Response.Headers.Add("Access-Control-Allow-Origin", new[] { allowedOrigin });

                var hashedTokenId = Utilities.GetHash(context.Token);
                using (IApplicationRepository rep = new ApplicationRepository())
                {
                    var refreshToken = await rep.RefreshTokens.FindAsync(hashedTokenId);

                    if (refreshToken != null)
                    {
                        //Get protectedTicket from refreshToken class
                        context.DeserializeTicket(refreshToken.ProtectedTicket);
                        var result = await rep.RefreshTokens.RemoveAsync(hashedTokenId);
                    }
                }

            }
            catch (Exception e)
            {

                throw e;
            }
        }
开发者ID:Fanuer,项目名称:EventCorp,代码行数:27,代码来源:CustomRefreshTokenProvider.cs

示例2: ReceiveAsync

        public async Task ReceiveAsync(AuthenticationTokenReceiveContext context)
        {
            var allowedOrigin = context.OwinContext.Get<string>("as:clientAllowedOrigin");

            if (context.OwinContext.Response.Headers.Keys.Contains("Access-Control-Allow-Origin"))
            {
                context.OwinContext.Response.Headers["Access-Control-Allow-Origin"] = allowedOrigin;
            }
            else
            {
                context.OwinContext.Response.Headers.Add("Access-Control-Allow-Origin", new[] {allowedOrigin});
            }

            var hashedTokenId = TokenHelper.GetHash(context.Token);

            using (var _repo = new AuthRepository())
            {
                var refreshToken = await _repo.FindRefreshToken(hashedTokenId);

                if (refreshToken != null)
                {
                    //Get protectedTicket from refreshToken class
                    context.DeserializeTicket(refreshToken.ProtectedTicket);
                    var result = await _repo.RemoveRefreshToken(hashedTokenId);
                }
            }
        }
开发者ID:chivandikwa,项目名称:Angular-Starter,代码行数:27,代码来源:SimpleRefreshTokenProvider.cs

示例3: Receive

 public override void Receive(AuthenticationTokenReceiveContext context)
 {
     string value;
     if (_codes.TryRemove(context.Token, out value))
     {
         context.DeserializeTicket(value);
     }
 }
开发者ID:BiaoLiu,项目名称:osharp,代码行数:8,代码来源:OsharpAuthorizationCodeProvider.cs

示例4: ReceiveAuthenticationCode

 private void ReceiveAuthenticationCode(AuthenticationTokenReceiveContext context)
 {
     string value;
     if (_authCodes.TryRemove(context.Token, out value))
     {
         context.DeserializeTicket(value);
     }
 }
开发者ID:austinejei,项目名称:sidekick,代码行数:8,代码来源:SideKickOAuthImplementation.cs

示例5: Receive

 /// <summary>
 /// 
 /// </summary>
 /// <param name="context"></param>
 public override void Receive(AuthenticationTokenReceiveContext context)
 {
     string token;
     if (_refreshTokens.TryRemove(context.Token, out token))
     {
         context.DeserializeTicket(token);
     }
 }
开发者ID:xianrui,项目名称:osharp,代码行数:12,代码来源:OsharpRefreshTokenProvider.cs

示例6: ReceiveAsync

        public async Task ReceiveAsync(AuthenticationTokenReceiveContext context)
        {
            context.OwinContext.Response.Headers.Add("Access-Control-Allow-Origin", new[] { "*" });
            await Task.Run(() =>
            {
                context.DeserializeTicket(context.Token);
            });

            
        }
开发者ID:akapolonn,项目名称:AngularJSAuthentication,代码行数:10,代码来源:MyRefreshTokenProvider.cs

示例7: ReceiveAsync

 /// <summary>
 /// 移除RefreshToken,在客户端使用RefreshToken请求新的AccessToken的时候自动调用
 /// </summary>
 /// <param name="context"></param>
 public async override Task ReceiveAsync(AuthenticationTokenReceiveContext context)
 {
     RefreshTokenInfo token = await _clientRefreshTokenStore.GetTokenInfo(context.Token);
     if (token == null)
     {
         return;
     }
     context.DeserializeTicket(token.ProtectedTicket);
     await _clientRefreshTokenStore.Remove(context.Token);
 }
开发者ID:i66soft,项目名称:osharp,代码行数:14,代码来源:OsharpRefreshTokenProvider.cs

示例8: Receive

        public void Receive(AuthenticationTokenReceiveContext context)
        {
            context.DeserializeTicket(context.Token);
            //var isUpdated = _usersRepository.IsRegisteredUserUpdated(context.Ticket.Identity.Claims.First(i => i.Type == ClaimTypes.NameIdentifier));

            /*f (isUpdated)
            {
                context.Response.StatusCode = (int)HttpStatusCode.Forbidden;
                context.Response.ReasonPhrase = Exceptions.UserDataChanged;
            }*/
        }
开发者ID:ReaderOfDream,项目名称:GuessThePicture,代码行数:11,代码来源:ApplicationOAuthProvider.cs

示例9: Receive

 public override void Receive(AuthenticationTokenReceiveContext context)
 {
     var container = context.OwinContext.GetAutofacLifetimeScope();
     var membershipService = container.Resolve<IAuthorizationService>();
     var hashedTokenId = VaBank.Common.Security.Hash.Compute(context.Token);
     var token = membershipService.RevokeToken(new IdentityQuery<string>(hashedTokenId));
     if (token != null)
     {
         context.DeserializeTicket(token.Value);
     }
     base.Receive(context);
 }
开发者ID:al-main,项目名称:vabank,代码行数:12,代码来源:VabankRefreshTokenProvider.cs

示例10: ReceiveAsync

    public async Task ReceiveAsync(AuthenticationTokenReceiveContext context) {
      var allowedOrigin = context.OwinContext.Get<string>("as:clientAllowedOrigin");
      context.OwinContext.Response.Headers.Add("Access-Control-Allow-Origin", new[] { allowedOrigin });
      string hashedToken = PasswordHelper.HashToken(context.Token);

      var authenticationClient = new AuthenticationClient();
      var response = await authenticationClient.GetRefreshToken(new GetRefreshTokenRequest { HashedToken = hashedToken });
      if (response.RefreshToken != null) {
        context.DeserializeTicket(response.RefreshToken.ProtectedTicket);
        await authenticationClient.DeleteRefreshToken(new DeleteRefreshTokenRequest { HashedToken = hashedToken });
      }
    }
开发者ID:kdewal,项目名称:kym,代码行数:12,代码来源:SimpleRefreshTokenProvider.cs

示例11: ReceiveAsync

        public async Task ReceiveAsync(AuthenticationTokenReceiveContext context)
        {
            var allowedOrigin = context.OwinContext.Get<string>("as:clientAllowedOrigin");
            context.OwinContext.Response.Headers.Add("Access-Control-Allow-Origin", new[] { allowedOrigin });
            var hashedTokenId = AuthorizationHelpers.GetHash(context.Token);

            var refreshToken = await _userRepository.FindRefreshTokenAsync(hashedTokenId);
            if (refreshToken != null)
            {
                context.DeserializeTicket(refreshToken.ProtectedTicket);
                await _userRepository.TryRemoveRefreshTokenAsync(hashedTokenId);
            }
        }
开发者ID:huoxudong125,项目名称:Moviepicker,代码行数:13,代码来源:SimpleRefreshTokenProvider.cs

示例12: Receive

        public void Receive(AuthenticationTokenReceiveContext context)
        {
            var hashedTokenId = Helper.GetHash(context.Token);
            var appTokenService = mobSocialEngine.ActiveEngine.Resolve<IAppTokenService>();

            var appToken = appTokenService.FirstOrDefault(x => x.Guid == hashedTokenId);
            if (appToken != null)
            {
                //Get protectedTicket from refreshToken class
                context.DeserializeTicket(appToken.ProtectedTicket);
                appTokenService.Delete(appToken);
            }
        }
开发者ID:Console-Byte,项目名称:mobsocial,代码行数:13,代码来源:ApplicationAuthorizationCodeProvider.cs

示例13: ReceiveAsync

        public async Task ReceiveAsync(AuthenticationTokenReceiveContext context)
        {
            string hashedTokenId = CommonMethod.GetHash(context.Token);

            var token = RedisHelp.GetObj<RefreshToken>(hashedTokenId);
            var user = RedisHelp.GetLoginUserCacheNotNull(int.Parse(token.ClientId));

            if (user != null)
            {
                //Get protectedTicket from refreshToken class
                context.DeserializeTicket(token.ProtectedTicket);
                bool flag = RedisHelp.ItemRemove(hashedTokenId);
            }
        }
开发者ID:a526757124,项目名称:YouTravelProject,代码行数:14,代码来源:ApplicationRefreshTokenProvider.cs

示例14: ReceiveAsync

        public async Task ReceiveAsync(AuthenticationTokenReceiveContext context)
        {
            var authClient = context.OwinContext.Get<AuthClient>("authClient");

            context.OwinContext.Response.Headers.Add("Access-Control-Allow-Origin", new[] { authClient.AllowedOrigin });

            //TODO: get the refresh token
            var token = new RefreshToken(); 

            if (token != null)
            {
                context.DeserializeTicket(token.ProtectedTicket);

                //TODO: remove token when used
            }
        }
开发者ID:eddievagabond,项目名称:angular-oauth-base,代码行数:16,代码来源:CustomOAuthRefreshProvider.cs

示例15: ReceiveAsync

        public async Task ReceiveAsync(AuthenticationTokenReceiveContext context)
        {

            var allowedOrigin = context.OwinContext.Get<string>("as:clientAllowedOrigin");
            context.OwinContext.Response.Headers.Add("Access-Control-Allow-Origin", new[] { allowedOrigin });

            string hashedTokenId = Helper.GetHash(context.Token);
            var refreshToken = await _authService.FindRefreshToken(hashedTokenId);

            if (refreshToken != null)
            {
                //Get protectedTicket from refreshToken class
                context.DeserializeTicket(refreshToken.ProtectedTicket);
                await _authService.RemoveRefreshToken(hashedTokenId);
            }
        }
开发者ID:Gangrena,项目名称:WebBellwether,代码行数:16,代码来源:SimpleRefreshTokenProvider.cs


注:本文中的Microsoft.Owin.Security.Infrastructure.AuthenticationTokenReceiveContext.DeserializeTicket方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。