예제 #1
0
        public static User GetUserFromToken()
        {
            // Get User form Token
            string token  = AuthenticationModule.GetToken();
            User   result = new User();

            if (!string.IsNullOrEmpty(token))
            {
                IClaimsIdentity claim = AuthenticationModule.GetClaim(token);
                result.UserId   = Convert.ToInt16(claim.UserId);
                result.UserName = claim.UserName;
                result.RoleId   = Convert.ToInt16(claim.RoleId);
            }

            return(result);
        }
        public async void ItGetsToken()
        {
            var module       = new AuthenticationModule();
            var subscription = new Subscription
            {
                Endpoint = new Uri("https://requestb.in/19swc1r1"),
                Auth     = new Auth
                {
                    Endpoint     = new Uri("http://localhost:4050/connect/token"),
                    ClientId     = "testclient",
                    ClientSecret = "verysecret"
                }
            };

            var token = await module.GetToken(subscription, "0", CancellationToken.None);

            Assert.False(token.token.IsNullOrEmpty());
            Assert.Equal("Bearer", token.scheme);
        }
예제 #3
0
 public bool IsUserAuthenticated()
 {
     return(AuthenticationModule.TokenValidation(AuthenticationModule.GetToken()));
 }