ToolypetMCP
advanced6 minutescross hub

Microservice Security Scaffold

Secure a microservice: generate service-to-service JWT, set up mTLS certificates, configure API gateway headers.

microserviceservice-meshmtlsjwtapi-gateway

Quando usar esta receita

Secure microservice architectures with defense in depth: JWT for identity, mTLS for transport, HMAC for request integrity, and CORS at the gateway.

Etapas

1

Per-service secrets

Prompt:Generate unique secrets for each microservice: auth-service, user-service, payment-service
2

Service JWT tokens

Prompt:Generate a service-to-service JWT with claims {iss: 'auth-service', aud: 'user-service', scopes: ['read:users']}
3

Generate mTLS keys

Prompt:Generate RSA key pairs for each service for mTLS (mutual TLS) authentication
4

API gateway CORS

Prompt:Generate CORS for API gateway: allow only known frontend origins, restrict methods per service
5

Request signing between services

Prompt:Generate HMAC signatures for inter-service request verification as a secondary auth layer

Perguntas frequentes

JWT vs mTLS for service-to-service auth?

Use both. mTLS verifies the service identity at the transport layer (which server is calling). JWT carries authorization claims (what the service is allowed to do). Defense in depth.

Do microservices need CORS?

Not between backend services (they communicate directly). CORS is needed at the API gateway/BFF layer where browser clients connect. Internal services should reject all browser requests.

Receitas relacionadas