Beispiel #1
0
        public async Task ReceiveAsync(AuthenticationTokenReceiveContext context)
        {
            string clientId = context.OwinContext.Get <string>("as:client_id");
            string ticket   = refreshTokenService.GetAuthenticationTicket(new Guid(context.Token), clientId);

            if (!string.IsNullOrEmpty(ticket) && !string.IsNullOrWhiteSpace(ticket))
            {
                context.SetTicket(serializer.Deserialize(System.Text.Encoding.Default.GetBytes(ticket)));

                var command = new ReduceRefreshTokenTTL()
                {
                    ClientId             = clientId,
                    RefreshToken         = Guid.Parse(context.Token),
                    AuthenticationTicket = ticket,
                    TTL = ttlChange
                };

                this.commandBus.Send(command);
            }
        }
Beispiel #2
0
        public void Handle(ReduceRefreshTokenTTL command)
        {
            var key = string.Format("{0}:{1}:{2}", this.RefreshTokenPrefixNamespace, command.ClientId, command.RefreshToken);

            this.redisWriteClient.Set(key, command.AuthenticationTicket, TimeSpan.FromMinutes(command.TTL));
        }