UserStore
public interface UserStore
io/agentscope/builder/web/auth/UserStore.java:36–85定义用户存储契约的接口。位于 io.agentscope.builder.web.auth 包。核心成员包括 passwordEncoder、findById、findByUsername、listAll、createUser、verifyPassword。
Abstraction over the user registry.
The only bundled implementation is
io.agentscope.builder.web.persistence.jpa.JpaUserStore, which persists via Spring Data
JPA. Out of the box the default DataSource is embedded H2 in file mode at
${user.home}/.agentscope-builder/db; activate the jdbc Spring profile (or
set BUILDER_DB_URL) to switch to MySQL or PostgreSQL. The MySQL and PostgreSQL JDBC
drivers ship at runtime scope.
Implementations are expected to be thread-safe and seed a default admin user on
first start when the store is empty.
嵌套类摘要Nested Class Summary
| 类Class | 类型Kind | 说明Description |
|---|---|---|
UserRecord | 记录record | 可 JSON 序列化的用户。 JSON-serializable user record. |
方法摘要Method Summary
方法详情Method Detail
passwordEncoder
public PasswordEncoder passwordEncoder()
返回 passwordEncoder 结果。
Returns the password encoder used for hashing and verification.
PasswordEncoderio/agentscope/builder/web/auth/UserStore.java:39findById
public Optional<UserRecord> findById(String userId)
查找通过标识。
Finds a user by stable identifier.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
userId | String | 用户标识(类型 `String`)。The user id. |
Optional<UserRecord>io/agentscope/builder/web/auth/UserStore.java:42findByUsername
public Optional<UserRecord> findByUsername(String username)
查找 findByUsername。
Finds a user by username (case-insensitive).
| 名称Name | 类型Type | 说明Description |
|---|---|---|
username | String | username(类型 `String`)。The username. |
Optional<UserRecord>io/agentscope/builder/web/auth/UserStore.java:45listAll
public List<UserRecord> listAll()
返回每个已注册用户。
Returns every registered user.
List<UserRecord>io/agentscope/builder/web/auth/UserStore.java:48createUser
public UserRecord createUser(String userId, String username, String password, List<String> roles)
创建新的用户。
Creates a new user.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
userId | String | 用户标识(类型 `String`)。The user id. |
username | String | username(类型 `String`)。The username. |
password | String | 密码(类型 `String`)。The password. |
roles | List<String> | roles(类型 `List`)。The roles. |
UserRecordio/agentscope/builder/web/auth/UserStore.java:54verifyPassword
public boolean verifyPassword(UserRecord user, String rawPassword)
执行 verifyPassword 方法。
Verifies a plain-text password against a stored UserRecord's hash.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
user | UserRecord | 用户(类型 `UserRecord`)。The user. |
rawPassword | String | 原始密码(类型 `String`)。The raw password. |
booleanio/agentscope/builder/web/auth/UserStore.java:57updatePassword
public Optional<UserRecord> updatePassword(String userId, String newPassword)
更新密码。
Updates the password of an existing user.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
userId | String | 用户标识(类型 `String`)。The user id. |
newPassword | String | 新建密码(类型 `String`)。The new password. |
Optional<UserRecord>io/agentscope/builder/web/auth/UserStore.java:60updateRoles
public Optional<UserRecord> updateRoles(String userId, List<String> newRoles)
更新 updateRoles。
Updates the roles of an existing user.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
userId | String | 用户标识(类型 `String`)。The user id. |
newRoles | List<String> | 新建 Roles(类型 `List`)。The new roles. |
Optional<UserRecord>io/agentscope/builder/web/auth/UserStore.java:63deleteUser
public boolean deleteUser(String userId)
删除用户。
Deletes a user by userId.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
userId | String | 用户标识(类型 `String`)。The user id. |
booleanio/agentscope/builder/web/auth/UserStore.java:69嵌套类详情Nested Class Detail
UserRecord
@JsonIgnoreProperties(ignoreUnknown = true) record UserRecord(String userId, String username, String passwordHash, List<String> roles)可 JSON 序列化的用户。位于 io.agentscope.builder.web.auth 包。核心成员包括 userId、username、passwordHash、roles、hasRole。
JSON-serializable user record.