跳到主内容

日志

记录是 Casdoor 审计日志中的一个条目。每当请求被处理后,Casdoor 会为每个 API 请求写入一条记录。每条记录都属于一个组织,因此组织的管理员只能看到与该组织相关的请求。

查看记录​

在 Casdoor 管理控制台中,转到 Auditing > Records。点击某条记录所在行的 View 以查看所有字段。

组织管理员只能看到他们自己组织的记录。全局管理员(即 built-in 组织的用户)可以看到所有组织的记录。

你也可以通过 GET /api/get-records 读取记录,权限范围相同。

记录字段​

FieldDescription
NameGenerated identifier of the record
IDSequential number of the record
TimestampWhen Casdoor handled the request
OrganizationThe organization that the record belongs to. See Organization and user of a record
UserThe user who made the request, or the application for a request with application credentials
MethodThe HTTP method, such as POST
Request URIThe path and query of the request. Casdoor removes secret query parameters, such as id_token_hint, password, and access_token
LanguageThe language of the request
Status codeCasdoor stores 200 for every API request, so use Response to see the outcome
ResponseThe status (ok or error) and the message of the response
ObjectThe request body. Casdoor masks secret values, such as passwords, client secrets, and tokens, as ***
ActionThe API action, for example login, update-user, or logout
Is triggeredWhether the record was sent to the matching webhooks without an error

对于登录失败的情况,记录的 detail 字段会包含原因,例如 wrong-password。请参阅 登录失败分类。

记录的组织和用户​

Casdoor 按以下顺序将每条记录归属于一个组织和用户:

  1. 已登录用户的请求属于该用户所在的组织。
  2. 使用应用的客户端 ID 和客户端密钥发出的请求属于该应用所在的组织。其用户为 app/<application-name>,控制台将其链接到该应用。
  3. 没有经过认证用户的请求属于请求中指定的组织。Casdoor 首先查看 body 或 query 中的 organization,然后查看 application 或 applicationId,最后查看 clientId。只有当组织或应用存在时,名称才有效。
  4. 其他任何请求都属于 built-in 组织。

Casdoor 记录哪些请求​

当配置文件中的 logPostOnly 为 true(默认值)时,Casdoor 不记录 GET 请求。例外情况是 logout 和 sso-logout,Casdoor 始终记录它们,因为 OpenID Connect (OIDC) 依赖方会通过 GET 调用它们以执行 RP-initiated logout。对于没有会话 cookie 的此类登出,记录从 id_token_hint 的主体获取其用户和组织。

Casdoor 还会将每条记录发送到其组织的 Audit providers,例如 Syslog,以及订阅其操作的 webhooks。

Casdoor 保留记录的时长​

默认情况下,Casdoor 永久保留记录。若要自动删除旧记录,请在组织的 Advanced 选项卡上设置 Record retention days。每日任务随后会删除超过此天数的组织记录。请参阅 令牌和记录的保留策略。

来自 Casdoor 旧版本的记录可能没有组织或所有者为 anonymous。它们遵循 built-in 组织的 Record retention days。

另请参阅​