From 204084700d91af6155afb8ae607d543b4ff288d0 Mon Sep 17 00:00:00 2001
From: chuntaojun <liaochuntao@live.com>
Date: Mon, 4 Mar 2024 23:34:34 +0800
Subject: [PATCH] feat:add plugin register and get func

---
 access_control/auth/api.go | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/access_control/auth/api.go b/access_control/auth/api.go
index 9e72447..eaa1dca 100644
--- a/access_control/auth/api.go
+++ b/access_control/auth/api.go
@@ -193,3 +193,30 @@ type StrategyConfig struct {
 	// Option StrategyOperator的option
 	Option map[string]interface{} `yaml:"option"`
 }
+
+// OperatorInfo 根据 token 解析出来的具体额外信息
+type OperatorInfo struct {
+	// Origin 原始 token 字符串
+	Origin string
+	// OperatorID 当前 token 绑定的 用户/用户组 ID
+	OperatorID string
+	// OwnerID 当前用户/用户组对应的 owner
+	OwnerID string
+	// Role 如果当前是 user token 的话,该值才能有信息
+	Role string
+	// IsUserToken 当前 token 是否是 user 的 token
+	IsUserToken bool
+	// Disable 标识用户 token 是否被禁用
+	Disable bool
+	// 是否属于匿名操作者
+	Anonymous bool
+}
+
+func NewAnonymous() OperatorInfo {
+	return OperatorInfo{
+		Origin:     "",
+		OwnerID:    "",
+		OperatorID: "__anonymous__",
+		Anonymous:  true,
+	}
+}