Overview of authentication and authorization in Microservices.Ecommerce (portfolio / local demo).
| Endpoint | Auth |
|---|---|
POST /identity/auth/register |
Public |
POST /identity/auth/login |
Public |
GET /identity/auth/me |
JWT |
- Passwords with BCrypt (work factor 12); password is never logged.
- JWT issued with
sub,email,customer_id,role. - Configuration:
Jwt:Secret,Issuer,Audience,ExpirationMinutes(environment variables in Docker).
GatewayAuthorizationMiddleware after JWT validation:
| Route | Policy |
|---|---|
/identity/* (register/login) |
Public |
GET /catalog/products* |
Public |
POST/PUT /catalog/* |
JWT + Admin role |
/basket/*, /ordering/* |
JWT required |
/inventory/* |
Public (demo) |
- Basket and Ordering:
[Authorize]+ validate URLcustomerIdagainstcustomer_idclaim (403 if mismatch). - Ordering
POST /orders:customerIdcomes only from the token; body does not define the customer. - Basket → Ordering:
BearerTokenForwardingHandlerforwards JWT on checkout. - Catalog: anonymous read; write requires Admin.
| Profile | Password | Role | |
|---|---|---|---|
| Customer | demo@ecommerce.local |
Demo123! |
Customer |
| Admin | admin@ecommerce.local |
Admin123! |
Admin |
Use only in local environment. Do not reuse in production.
Jwt:Secretminimum 32 characters — viaappsettings,appsettings.Docker.json, orJwt__Secretin Compose (demo).- Do not commit
.envwith real secrets (see .gitignore).
- No refresh token, OAuth, or IdentityServer.
- Shared symmetric JWT (HMAC) across services.
- Inventory is public to simplify smoke tests.
Planned evolutions: ROADMAP.md.