Exemplo n.º 1
0
        //Creation
        public Token CreateToken(string tokenUnique, object data)
        {
            TokenLookup lookup = new TokenLookup()
            {
                AccessToken  = GenerateCryptoKey(),
                RefreshToken = GenerateCryptoKey(),
                Expires      = DateTime.Now.Add(TimeSpan.FromSeconds(Duration)),
                Data         = data,
                TokenUnique  = tokenUnique
            };

            lookupTable.AddOrUpdate(lookup.AccessToken, lookup, (key, val) => lookup);
            return(lookup.ToToken());
        }
Exemplo n.º 2
0
        public Token UseRefreshToken(string tokenUnique, string accessToken, string refreshToken)
        {
            accessToken  = accessToken.UrlDecode();
            refreshToken = refreshToken.UrlDecode();
            if (!lookupTable.ContainsKey(accessToken))
            {
                return(null);
            }
            TokenLookup lookup = lookupTable[accessToken];

            if (lookup.RefreshToken != refreshToken)
            {
                return(null);
            }

            lookupTable.TryRemove(accessToken, out lookup);

            lookup.AccessToken  = GenerateCryptoKey().UrlEncode();
            lookup.RefreshToken = GenerateCryptoKey().UrlEncode();
            lookupTable.AddOrUpdate(lookup.AccessToken, lookup, (key, val) => lookup);

            return(lookup.ToToken());
        }
Exemplo n.º 3
0
        //Publics
        public Token GetToken(string token)
        {
            TokenLookup lookup = lookupTable[token];

            return(lookup.ToToken());
        }