Skip to main content

Aisphere IAM

Aisphere IAM 是基于 github.com/aisphereio/kernel身份认证、目录查询和权限关系服务。它封装 Casdoor(认证)和 SpiceDB(授权),为 Hub、Gateway、Runtime 等业务组件提供统一 IAM API。

架构

提供的服务

IAMAuthService

方法说明
BuildLoginURL构建 Casdoor 登录 URL
ExchangeCode用 code 交换 token
RefreshToken刷新令牌
VerifyToken验证令牌
RevokeToken撤销令牌
GetMe获取当前用户信息
UpdateMe更新当前用户信息
GetUserPreferences获取用户偏好
UpdateUserPreferences更新用户偏好

IAMDirectoryService

方法说明
GetUser获取用户
ListUsers列出用户
GetOrganization获取组织
ListGroups列出组

IAMPermissionService

方法说明
CheckPermission检查权限
WriteRelationship写入关系
DeleteRelationship删除关系
LookupResources查找资源
LookupSubjects查找主体

本地运行

go run ./cmd/aisphere-iam -conf ./configs/config.local.yaml

默认端口:

  • HTTP: 0.0.0.0:18080
  • gRPC: 0.0.0.0:19080
  • Metrics: 127.0.0.1:19180

验证

# 健康检查
curl http://127.0.0.1:18080/healthz

# 获取登录 URL
curl "http://127.0.0.1:18080/v1/iam/login-url?redirect_uri=http://localhost:3001/auth/callback&state=/"

# 列出本地用户
curl http://127.0.0.1:18080/v1/users

# 创建本地用户
curl -X POST http://127.0.0.1:18080/v1/users \
-H "Content-Type: application/json" \
-d '{"username":"test","displayName":"Test User","email":"test@example.com","password":"test123"}'

依赖

  • github.com/aisphereio/kernel — 核心框架
  • Casdoor — 身份认证
  • SpiceDB — 关系授权
  • etcd — route registry 存储(可选)