重要 |
我在 happn 工作期间参与了这个项目。 我已经不在 happn 工作了! |
所有请求(除了身份验证请求)都必须包含以下标头
Authorization: Bearer <token>
所有响应都按如下格式格式化
{ "error": ErrorObject or null "data": CallTypeDependentObject or null } If error is null, data won’t be null and vice-versa.
TaggedID
对象
This is a string with the following format: service_id + ":" + id_of_object_for_given_service Obviously the service_id cannot contain a colon. The id of the object might though.
Error
对象
{ "code": Int "domain": String "message": String }
User
对象
{ "id": TaggedID "linked_ids": [ TaggedID, TaggedID, ... ] "first_name": String or null "last_name": String or null "ssh_key": String or null }
PasswordReset
对象
{ "user_id": TaggedID "is_executing": Bool (true if any service password reset is executing) "services": { ServicePasswordResetObject, ServicePasswordResetObject, ... } }
ServicePasswordReset
对象
{ "service_id": String "user_id": AnyObject (The type of the id of the service) "is_executing": Bool "error": Error or null }
POST /auth/login
Description: Retrieve a new access token. Parameters: username: String (Must be a valid *LDAP DN*) password: String Returns an object with the following properties: expiration_date: String (Always a valid ISO 8601 Date) token: String is_admin: Bool
POST /auth/logout
Description: Revoke an access token. Returns: The string "ok". Note: Currently the logout does not do anything. It might in the future actually disable the token.
GET /api/users/[:officectl_user_id]
Description: List all users in the LDAP, or fetch a specific user. Only an admin is allowed to list the users. Normal users are only allowed to fetch themselves. Returns a User, or a collection of User.
GET /api/password-resets/[:officectl_user_id]
Description: List all password resets in progress. Only an admin is allowed to list the resets. Normal users are only allowed to fetch the reset concerning their own account. Returns a PasswordReset, or a collection of PasswordReset.
PUT /api/password-resets/:officectl_user_id
Description: Create a new password reset. Only admins are allowed to reset the password of somebody else than themselves and without specifying the current password. If a password reset was already in progress for the given user, the call will fail. Parameters: old_password: String or null new_password: String Returns a PasswordReset.
DELETE /api/password-resets/:officectl_user_id
Description: Delete a password reset. Returns: The string "ok".
对于 macOS
swift build [-c release]
直接构建仓库。 如果您想避免大量的 LDAP 相关警告,可以运行一次 ./Scripts/configure.sh
。 有关更多信息,请参阅 Package.swift
文件。
对于 Linux
docker build .
这是一个标准的 SPM
项目,因此源代码位于 Sources
文件夹中,然后每个源文件位于以其所属目标命名的文件夹中。 测试位于 Tests
文件夹中。
包含构建 officectl
命令行工具所用的库。
模型的“OfficeKit”部分用于表示 OfficeKit 直接使用的对象。
LDAP 模型包含通用的 LDAPObject
结构和一些实用程序。 它还包含一些类,这些类匹配 LDAP 模式 RFC1274 (cosine) + RFC2798 (inetOrgPerson) 以及 OpenLDAP 中的“core”模式。
其他模型通常都很简单,直接用于存储来自不同 API 的结果。
这些是负责连接或验证不同服务的类。
连接器负责“创建到给定服务的连接”。 例如,对于 LDAP 服务,连接器将创建套接字以连接到 LDAP 服务器。 对于 REST 连接器(例如 GitHub),连接器将生成用于验证向此服务发出的请求的令牌。
身份验证器负责“验证请求”。 例如,GitHub 身份验证器将在 URLRequest 中添加必需的 HTTP 标头。
一个对象可以同时是连接器和身份验证器。 例如,GitHubJWTConnector
就是两者兼具。
它们是标准的 Foundation 的 Operation
。 有关更多信息,请参见下文,否则您可以跳过此节。
一个操作代表一个单独的工作单元,同步或异步。 该工作只能执行一次。 配置可以在初始化时完成,也可以在初始化之后,但在操作开始之前完成。 如何检索操作结果没有规则; 通常,操作会存储结果,并在操作结束后检索它。
通常,您会希望在 OperationQueue 中启动一个 Operation,这允许操作具有优先级和依赖关系。 队列将根据这些属性以正确的顺序启动操作。 在队列中启动 Operation 对于同步操作尤为重要:您可能不希望阻塞当前线程直到操作完成!
这是 officectl 可执行文件。 它具有一个命令行,可用于启动 officectl 服务器。
这些包含直接从命令行调用的函数。 要搜索运行 officectl backup mails
时调用的函数,您需要转到 root/backup/mails.swift
文件。
可用命令行动作和参数的配置在 guaka_config.swift
文件中完成。