iam-api

module
v0.0.0-...-63bcae8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 23, 2022 License: MIT

README

iam-api

IAM (Identity and Access Management) API、错误码、接口文档。

IAM系统由多个微服务构成(详见系统架构),为了方便查阅,所有微服务的API、错误码、接口文档在本项目统一管理。

系统架构

功能说明
  1. iam-apiserver: 用户、密钥、授权策略的资源管理
  • 对外)用户、密钥、授权策略的增删改查
  • 当密钥、授权策略有变更时,通知iam-authz更新数据
  • 密钥、授权策略批量查询
  1. iam-authz:授权服务
  • 对外)提供授权服务
  • 将授权审计日志转存至消息队列
  • 订阅密钥、授权策略变更通知
  • 收到事件通知后,通过gRPC接口从iam-apiserver拉取密钥、授权策略,并缓存至内存
  1. iam-pump:审计日志转存服务
  • 从消息队列消费审计日志,转存至prometheus

因为运维侧的监控日志都是prometheus技术栈,所以审计日志的持久化后端也采用prometheus。

接口文档

接口文档

开发规范

IAM系统各服务应遵循统一的架构风格,可以认为是简化版的DDD,如下图所示。

  1. Model 模型层
  • 对内:不区分DTO、DO、PO,Models对其他所有层可见。
  • 对外:作为微服务之间交互的数据结构,统一在iam-api/api中定义,方便各微服务查询。
  1. Service 服务层
  • 实现了对外提供的所有服务
  • 参数的解析与校验、权限检查、协同Domain之间的交互
  • 不应处理复杂的业务逻辑
  1. Domain 领域层
  • 核心业务逻辑
  • 基于依赖倒置的原则,在这里定义Data层需要实现的接口
  • 测试时通过Mock模拟Data层
  1. Data 数据层
  • 实现了Domain定义的接口
  • 不同于DAO,Data是对业务数据的封装,业务数据包括数据库缓存外部服务

推荐目录结构:

.
├── # 无model层,model层通过`import github.com/che-kwas/iam-api/api`引入
├── cmd         # 服务启动的入口
├── configs     # yaml配置文件
└── internal    # 核心逻辑,使用internal避免错误引用
    ├── options # server的配置项
    ├── server  # 根据options构建server
    ├── service # 服务层
    ├── domain  # 领域层
    ├── data    # 数据层
    └── pkg     # 业务无关的pkg

项目说明

本项目是对极客时间训练营的实战总结,主要参考资料:

Directories

Path Synopsis
api
Package errcode defines the error codes with corresponding HTTP status and message.
Package errcode defines the error codes with corresponding HTTP status and message.
coder
Package coder implements `github.com/marmotedu/errors` Coder interface.
Package coder implements `github.com/marmotedu/errors` Coder interface.
tools
codegen
Package codegen is a tool to automate the creation of code init function and generate document.
Package codegen is a tool to automate the creation of code init function and generate document.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL