servicestack用户身份验证无法授权

时间:2014-07-01 10:30:29

标签: xamarin.ios servicestack servicestack-auth

 Plugins.Add(new AuthFeature(
                    () => new AuthUserSession(),
                    new IAuthProvider[] { new BasicAuthProvider(new AppSettings()), }));

            Plugins.Add(new RegistrationFeature());

            container.Register<ICacheClient>(new MemoryCacheClient());
            var userRepository = new InMemoryAuthRepository();
            container.Register<IUserAuthRepository>(userRepository);

            string hash;
            string salt;

            new SaltedHash().GetHashAndSaltString("password", out hash, out salt);
            userRepository.CreateUserAuth(new UserAuth
            {
                Id = 1,
                DisplayName = "JoeUser",
                Email = "joe@user.com",
                UserName = "hal",
                FirstName = "Joe",
                LastName = "User",
                PasswordHash = hash,
                Salt = salt,
                Roles = new List<string> { RoleNames.Admin },
                //Permissions = new List<string>{"GetStatus"}
            }, "password");

这是全局的asax文件,我使用此代码进行身份验证

 [Route("/ClientList/", "POST")]
    [ Authenticate]

    public class ClientGet
    {
        public string username { get; set; }
        public string password { get; set; }

    }
当我尝试

时,在单音句阶段

client = new JsonServiceClient ("http://sampleurl.com/api/authenticate/Basic?format=json") {
                UserName = "hal",
                Password = "password"
            };

或   client = new JsonServiceClient(“http://sampleurl.com/api){Username =”Hal“,Password =”password“);

它让我请求超时问题

有更新吗?

感谢

0 个答案:

没有答案