AS AgentScopeAPI 手册 / API Reference

UserStore

public interface UserStore
源码Source 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说明Description
public PasswordEncoder passwordEncoder()
返回 `passwordEncoder` 结果。
Returns the password encoder used for hashing and verification.
public Optional<UserRecord> findById(String userId)
查找通过标识。
Finds a user by stable identifier.
public Optional<UserRecord> findByUsername(String username)
查找 `findByUsername`。
Finds a user by username (case-insensitive).
public List<UserRecord> listAll()
返回每个已注册用户。
Returns every registered user.
public UserRecord createUser(String userId, String username, String password, List<String> roles)
创建新的用户。
Creates a new user.
public boolean verifyPassword(UserRecord user, String rawPassword)
执行 `verifyPassword` 方法。
Verifies a plain-text password against a stored `UserRecord`'s hash.
public Optional<UserRecord> updatePassword(String userId, String newPassword)
更新密码。
Updates the password of an existing user.
public Optional<UserRecord> updateRoles(String userId, List<String> newRoles)
更新 `updateRoles`。
Updates the roles of an existing user.
public boolean deleteUser(String userId)
删除用户。
Deletes a user by userId.

方法详情Method Detail

passwordEncoder

public PasswordEncoder passwordEncoder()

返回 passwordEncoder 结果。

Returns the password encoder used for hashing and verification.

返回Returns PasswordEncoder
返回PasswordEncoder。Returns password encoder.
源码Source io/agentscope/builder/web/auth/UserStore.java:39

findById

public Optional<UserRecord> findById(String userId)

查找通过标识。

Finds a user by stable identifier.

参数Parameters
名称Name类型Type说明Description
userIdString用户标识(类型 `String`)。The user id.
返回Returns Optional<UserRecord>
返回可选。Returns optional.
源码Source io/agentscope/builder/web/auth/UserStore.java:42

findByUsername

public Optional<UserRecord> findByUsername(String username)

查找 findByUsername。

Finds a user by username (case-insensitive).

参数Parameters
名称Name类型Type说明Description
usernameStringusername(类型 `String`)。The username.
返回Returns Optional<UserRecord>
返回可选。Returns optional.
源码Source io/agentscope/builder/web/auth/UserStore.java:45

listAll

public List<UserRecord> listAll()

返回每个已注册用户。

Returns every registered user.

返回Returns List<UserRecord>
返回列出。Returns list.
源码Source io/agentscope/builder/web/auth/UserStore.java:48

createUser

public UserRecord createUser(String userId, String username, String password, List<String> roles)

创建新的用户。

Creates a new user.

参数Parameters
名称Name类型Type说明Description
userIdString用户标识(类型 `String`)。The user id.
usernameStringusername(类型 `String`)。The username.
passwordString密码(类型 `String`)。The password.
rolesList<String>roles(类型 `List`)。The roles.
返回Returns UserRecord
返回UserRecord。Returns user record.
源码Source io/agentscope/builder/web/auth/UserStore.java:54

verifyPassword

public boolean verifyPassword(UserRecord user, String rawPassword)

执行 verifyPassword 方法。

Verifies a plain-text password against a stored UserRecord's hash.

参数Parameters
名称Name类型Type说明Description
userUserRecord用户(类型 `UserRecord`)。The user.
rawPasswordString原始密码(类型 `String`)。The raw password.
返回Returns boolean
返回布尔值,表示判断结果。Returns a boolean result.
源码Source io/agentscope/builder/web/auth/UserStore.java:57

updatePassword

public Optional<UserRecord> updatePassword(String userId, String newPassword)

更新密码。

Updates the password of an existing user.

参数Parameters
名称Name类型Type说明Description
userIdString用户标识(类型 `String`)。The user id.
newPasswordString新建密码(类型 `String`)。The new password.
返回Returns Optional<UserRecord>
返回可选。Returns optional.
源码Source io/agentscope/builder/web/auth/UserStore.java:60

updateRoles

public Optional<UserRecord> updateRoles(String userId, List<String> newRoles)

更新 updateRoles。

Updates the roles of an existing user.

参数Parameters
名称Name类型Type说明Description
userIdString用户标识(类型 `String`)。The user id.
newRolesList<String>新建 Roles(类型 `List`)。The new roles.
返回Returns Optional<UserRecord>
返回可选。Returns optional.
源码Source io/agentscope/builder/web/auth/UserStore.java:63

deleteUser

public boolean deleteUser(String userId)

删除用户。

Deletes a user by userId.

参数Parameters
名称Name类型Type说明Description
userIdString用户标识(类型 `String`)。The user id.
返回Returns boolean
返回布尔值,表示判断结果。Returns a boolean result.
源码Source io/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.

基于官方固定版本源码静态生成Generated from pinned official sources · Python 2.0.11 · Java 2.0.4
签名与文档为静态抽取;如有疑问请以源码为准。Signatures and docs are extracted statically; verify against the source when in doubt.