本文整理汇总了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;
}
}
示例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);
}
}
}
示例3: Receive
public override void Receive(AuthenticationTokenReceiveContext context)
{
string value;
if (_codes.TryRemove(context.Token, out value))
{
context.DeserializeTicket(value);
}
}
示例4: ReceiveAuthenticationCode
private void ReceiveAuthenticationCode(AuthenticationTokenReceiveContext context)
{
string value;
if (_authCodes.TryRemove(context.Token, out value))
{
context.DeserializeTicket(value);
}
}
示例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);
}
}
示例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);
});
}
示例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);
}
示例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;
}*/
}
示例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);
}
示例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 });
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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
}
}
示例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);
}
}