public string Protect(TicketInfo ticket) { ticket.CheckNotNull(nameof(ticket)); var json = ticket.ToJsonString(); return(DesHelper.Encrypt(json, _desKey) + DesHelper.Encrypt(_salt, _desKey)); }
public async Task <string> StoreAsync(TicketInfo ticket) { var key = new Guid().ToString(); var token = _ticketInfoProtector.Protect(ticket); await _cacheManager.GetCache(SsoCacheKey).SetAsync(key, token); return(key); }
public async Task <string> GenerateToken(ClaimsIdentity identity) { var tiketInfo = new TicketInfo(identity); if (SessionStore != null) { return(await SessionStore.StoreAsync(tiketInfo)); } return(TicketInfoProtector.Protect(tiketInfo)); }
private bool CheckAllowHost(TicketInfo ticketInfo) { var claim = ticketInfo.Claims.FirstOrDefault(p => p.Name == SsoClaimTypes.AllowHosts); if (claim == null) { return(false); } var allowHosts = claim.Value.Split(",", StringSplitOptions.RemoveEmptyEntries); return(allowHosts.Contains(Request.Host.ToString())); }
public async Task RenewAsync(string key, TicketInfo ticket) { var token = _ticketInfoProtector.Protect(ticket); await _cacheManager.GetCache(SsoCacheKey).SetAsync(key, token); }