Skip to main content

Module feishu_auth

Module feishu_auth 

Source
Expand description

Feishu / Lark authentication plugin (feishu-auth).

Validates a Feishu authorization code by exchanging it, through Feishu’s OAuth v2 token endpoint, for a user access token, then calls Feishu’s userinfo endpoint to resolve the calling user’s identity and attaches it to the request. A code that cannot be resolved is rejected with a 401.

§Ported subset / deviations from APISIX

APISIX’s feishu-auth is a session plugin: it caches the exchanged access token and resolved userinfo in an encrypted feishu_session cookie so later requests skip the callouts, and it 302-redirects to redirect_uri when no code/session is present. featherbit is stateless with no session store, so this port implements the token-validation subset: every request must carry a code, which is exchanged and validated on each request. The session / cookie / redirect machinery is dropped, along with the keys that only served it (secret, secret_fallbacks, redirect_uri, cookie_expires_in). auth_redirect_uri is retained because it is part of the authorization_code token-exchange body, not the interactive redirect.

Structs§

FeishuAuthPlugin
Authenticates requests by exchanging a Feishu authorization code for a user access token, then resolving that token to a Feishu user.

Enums§

FeishuError 🔒
Outcome of resolving a Feishu code. Every failure maps to a 401 (FEISHU_AUTH_FAILED); variants exist to keep the reason legible.

Constants§

DEFAULT_TOKEN_URL 🔒
DEFAULT_USERINFO_URL 🔒

Functions§

attach_identity 🔒
Copies the resolved identity into context.message and optionally the X-Userinfo request header.
parse_access_token 🔒
Parses the user access token from Feishu’s v2 token response.
parse_userinfo 🔒
Parses Feishu’s userinfo response, returning data.data on code == 0.
require_string 🔒