服务间身份认证与授权设计
结合现有服务架构设计身份认证、最小权限和用户上下文传递方案,提供分阶段迁移与回滚计划。
完整提示词
<context>
Many systems trust any call that arrives from inside the network, so one compromised or misconfigured service, or one server-side request forgery bug, can call every other service with full power. The fix has two parts that are often mixed up. Service identity answers "which workload is calling": mutual TLS with short-lived certificates issued automatically (a service mesh or SPIFFE-style workload identity), or short-lived signed tokens obtained from a platform identity (cloud workload identity, Kubernetes service account tokens with an audience) rather than long-lived shared secrets. Authorisation answers "may this workload call this operation": an explicit allowlist per caller and operation, enforced at the callee or in the mesh. End-user context is a third concern: forwarding the user's original token everywhere widens its exposure, so mature designs either exchange it for a downscoped internal token or pass a signed internal assertion, and the callee still checks that the user may access the specific object.
</context>
<task>
<services>
{{services}}
</services>
{{#current_state}}
<current_state>
{{current_state}}
</current_state>
{{/current_state}}
{{#requirements}}
<requirements>
{{requirements}}
</requirements>
{{/requirements}}
1. If a repository is available, read the service clients, ingress and mesh configuration, and how secrets reach services, and say what you read.
2. Recommend the identity mechanism (mesh mTLS, workload identity tokens, or a combination) for this platform, considering every runtime involved, including async consumers and jobs.
3. Specify service identity: naming scheme for workloads, issuance, certificate or token lifetime, automatic rotation, and how non-mesh workloads such as serverless functions or external jobs get identities.
4. Specify authorisation between services: a default-deny policy, allowed caller and operation pairs, where it is enforced, how policies are reviewed and changed, and audit logging of denied calls.
5. Specify end-user context propagation: what is forwarded (exchanged downscoped token or signed internal assertion), audience and lifetime, and the rule that callees check object-level access for the user, not just the calling service.
6. Specify secrets and rotation: removal of long-lived shared tokens, where any remaining secrets live, and the rotation process.
7. Plan the migration in phases: inventory current calls, issue identities, run policies in audit mode, then enforce, with rollback for each phase.
</task>
<constraints>
- Do not treat network location (inside the VPC or cluster) as authentication.
- Do not recommend long-lived shared secrets as the target state.
- Do not forward full-privilege user tokens to every downstream service without discussing exposure and audience.
- Policy enforcement must be rolled out with an audit-only phase to avoid outages.
{{> output/uncertainty}}
</constraints>
<output_format>
## Recommendation
In at most 6 lines.
## Service identity
## Authorisation between services
Table: caller, callee, allowed operations.
## End-user context
## Secrets and rotation
## Migration
Numbered phases, each with verification and rollback.
## Open questions
Numbered.
</output_format>可替换内容
- {{services}}
- {{#current_state}}
- {{current_state}}
- {{/current_state}}
- {{#requirements}}
- {{requirements}}
- {{/requirements}}
- {{> output/uncertainty}}
分类与标签
编程开发、微服务认证、权限控制、凭证轮换、安全迁移