Beispiel #1
0
        public virtual Task <string> GenerateAccessToken(
            string audience,
            IEnumerable <Claim> claims,
            TimeSpan lifetime,
            AccessTokenAlgorithm algorithm)
        {
            var token = AuthUtility.GenerateAccessToken(this, audience, claims, lifetime, algorithm);

            return(Task.FromResult(token));
        }
Beispiel #2
0
        public string GenerateClientAccessToken(string hubName, IEnumerable <Claim> claims = null, TimeSpan?lifetime = null)
        {
            if (string.IsNullOrEmpty(hubName))
            {
                throw new ArgumentNullException(nameof(hubName));
            }

            var audience = _generator.GetClientAudience(hubName, _appName);

            return(AuthUtility.GenerateAccessToken(_accessKey, audience, claims, lifetime ?? _accessTokenLifetime, _algorithm));
        }
Beispiel #3
0
        public string GenerateServerAccessToken(string hubName, string userId, TimeSpan?lifetime = null)
        {
            if (string.IsNullOrEmpty(hubName))
            {
                throw new ArgumentNullException(nameof(hubName));
            }

            var audience = _generator.GetServerAudience(hubName, _appName);
            var claims   = userId != null ? new[] { new Claim(ClaimTypes.NameIdentifier, userId) } : null;

            return(AuthUtility.GenerateAccessToken(_accessKey, audience, claims, lifetime ?? _accessTokenLifetime, _algorithm));
        }