Skip to main content

Crate openlark_security

Crate openlark_security 

Source
Expand description

OpenLark 安全服务模块

提供飞书开放平台的完整安全服务,包括访问控制(ACS)和安全合规管理。

§架构设计

采用 Project-Version-Resource (PVR) 三层架构,使用 canonical openlark_core::config::Config(#444–#447):

openlark-security/src/
├── acs/              # 访问控制系统 (Project)
│   └── v1/          # API版本v1 (Version)
└── security_and_compliance/  # 安全合规管理 (Project)
    ├── v1/          # API版本v1 (Version) - 审计日志
    └── v2/          # API版本v2 (Version) - 设备记录管理

§快速开始

use openlark_security::prelude::*;
use openlark_core::config::Config;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    // 使用 canonical core Config(v0.18 推荐唯一路径,完整保留 token provider / headers / timeout 等)
    let config = Config::builder()
        .app_id("app_id")
        .app_secret("app_secret")
        .build();
    let security = SecurityClient::new(config);

    // 获取门禁用户列表(响应 data 透传为 ListUsersResponse)
    let users = security.acs.v1().users().list()
        .page_size(20)
        .execute()
        .await?;

    println!("是否有更多: {}", users.has_more);
    Ok(())
}

§API覆盖

§acs (v1) - 访问控制系统

所有端点走 openlark_core::Transport,token 类型按飞书文档 Authorization 标注 (用户/设备/记录类 tenant_access_token,权限组/访客类 user_access_token),返回响应 data 字段内容。 各 Service 是门面,方法返回 *Request 构建器(.execute() 发请求)。

§用户管理 (users)
  • users.get(user_id) / users.list() / users.create() / users.patch(user_id) / users.delete(user_id)
§用户人脸 (user_faces,/users/{user_id}/face)
  • user_faces.get(user_id) - 下载用户人脸
  • user_faces.update(user_id) - 上传用户人脸
§人脸资源 (face,独立资源 /faces)
  • face().get(face_id) / face().create() / face().delete(face_id)
§设备管理 (devices)
  • devices.get/list/create/update/delete/approve/query
  • client_device(device_id) - 客户端设备认证(便捷方法)
§权限规则 (rule_external)
  • rule_external.create(rule_id) - 创建或更新权限组(body {"rule":...}
  • rule_external.get(device_id) - 获取权限组
  • rule_external.delete(rule_id) - 删除权限组(无 body)
  • rule_external.device_bind() - 设备绑定({device_id, rule_ids[]}
§访客管理 (visitors)
  • visitors.create() / visitors.delete(visitor_id)
§访问记录 (access_records)
  • access_records.list() / access_records.get_access_photo(access_record_id)

§security_and_compliance (v2/v1) - 安全合规管理

§设备记录管理 (device_record - v2)
  • device_records.mine() - 获取客户端设备认证信息
  • device_records.create() - 新增设备
  • device_records.list() - 查询设备信息
  • device_records.get() - 获取设备信息
  • device_records.update() - 更新设备
  • device_records.delete() - 删除设备
§设备申报审批 (device_apply_record - v2)
  • device_apply_records.approve() - 审批设备申报
§审计日志管理 (openapi_log - v1)
  • openapi_logs.list_data() - 获取OpenAPI审计日志数据

Re-exports§

pub use security::security_and_compliance::SecurityAndComplianceV1Service;
pub use security::security_and_compliance::SecurityAndComplianceV2Service;
pub use crate::error::SecurityError;

Modules§

acs
Project: acs - 访问控制系统 路径结构 acs/acs/v1/ 对齐 validate_apis.py 的 bizTag/project 路径推断
error
安全服务错误处理模块
prelude
预导出模块
security
Security 模块

Structs§

Config
零拷贝配置共享实现
SecurityClient
安全服务客户端(唯一公开入口,single-entry)。

Type Aliases§

SecurityResult
结果类型别名