servicestack - 我将如何创建自己的 IUserAuthRepository 实现?

标签 servicestack authentication

我正在使用开箱即用的身份验证和服务堆栈,并且效果很好。所以,现在,我正在使用以下来自 ServiceStack 示例的代码行模拟用户:

            var userRep = new InMemoryAuthRepository();
            container.Register<IUserAuthRepository>(userRep);
            string hash;
            string salt;
            new SaltedHash().GetHashAndSaltString("test", out hash, out salt);
            userRep.CreateUserAuth(new UserAuth
            {
                Id = 1,
                DisplayName = "DisplayName",
                Email = "as@if.com",
                UserName = "john",
                FirstName = "FirstName",
                LastName = "LastName",
                PasswordHash = hash,
                Salt = salt,
            }, "test");

有什么办法可以定义 userRep 中的字段吗?例如,假设我想要字段 portalid 以及 UserAuth 对象的一部分?我该怎么做呢?我可以只修改 InMemoryAuthRepository 类吗?

最佳答案

您不能更改 ServiceStack's built-in UserAuth 的架构DTO,但它确实提供了一些扩展点,即 explained in detail in this answer您可以在哪里使用 RefIdRefIdStr通过将元数据添加到 Dictionary<string,string> Meta 来引用您自己的自定义表或在 UserAuth 行中添加元数据的字段收藏。

关于servicestack - 我将如何创建自己的 IUserAuthRepository 实现?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14611471/

相关文章:

ServiceStack BSD 版本 3.9.71 和 protobuf-net 版本

php - token 在尝试刷新后被解除认证

linux - 登录和 shell 提示之间有 10 秒的延迟。

authentication - Keycloak:使用自定义 JWT 对用户进行身份验证

java - 基于用户代理的 REST API 未经身份验证的请求异常

c# - SQLite 在 where 子句中使用整数主键选择查询返回空结果

redis - 如何使用 ServiceStack Redis 客户端获取多个 HashSet

c# - 如何在 https (ssl) channel 上通过服务堆栈运行 RESTful web 服务

使用 ServiceStack ORMLite 的 MySql.Data.MySqlClient.MySqlException

java - 如何查看个人域用户登录情况