예제 #1
0
        /// <summary>
        /// Retrieve ticket
        /// </summary>
        /// <param name="key">Session key</param>
        /// <returns>Return authentication ticket</returns>
        public async Task <AuthenticationTicket> RetrieveAsync(string key)
        {
            var session = await CookieMemoryCacheSessionStore.GetSessionAsync(key).ConfigureAwait(false);

            if (session == null)
            {
                return(null);
            }
            return(session.ConvertToTicket());
        }
예제 #2
0
        /// <summary>
        /// Renew ticket
        /// </summary>
        /// <param name="key">Session key</param>
        /// <param name="ticket">Ticket</param>
        /// <returns></returns>
        public async Task RenewAsync(string key, AuthenticationTicket ticket)
        {
            var session = AuthSession.FromAuthenticationTicket(ticket);

            if (session == null)
            {
                await Task.CompletedTask.ConfigureAwait(false);
            }
            session.SessionId = key;
            await CookieMemoryCacheSessionStore.StoreSessionAsync(session).ConfigureAwait(false);
        }
예제 #3
0
 /// <summary>
 /// Verify ticket
 /// </summary>
 /// <param name="subject">Subject</param>
 /// <param name="sessionToken">Session token</param>
 /// <param name="renew">Whether renew ticket</param>
 /// <returns>Return whether verify successful</returns>
 public async Task <bool> VerifyTicketAsync(string subject, string sessionToken, bool renew = true)
 {
     return(await CookieMemoryCacheSessionStore.VerifySessionAsync(subject, sessionToken, renew).ConfigureAwait(false));
 }
예제 #4
0
 /// <summary>
 /// Remove ticket
 /// </summary>
 /// <param name="key">Ticket key</param>
 /// <returns></returns>
 public async Task RemoveAsync(string key)
 {
     await CookieMemoryCacheSessionStore.DeleteSessionAsync(key).ConfigureAwait(false);
 }
예제 #5
0
        /// <summary>
        /// Get session token
        /// </summary>
        /// <param name="subject">Subject</param>
        /// <returns>Return session token</returns>
        public async Task <string> GetSessionTokenAsync(string subject)
        {
            var session = await CookieMemoryCacheSessionStore.GetSessionBySubjectAsync(subject).ConfigureAwait(false);

            return(session?.SessionToken ?? string.Empty);
        }