@nakedev/go-scaffold 0.5.1 → 0.5.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commands/auth.js +11 -2
- package/dist/index.js +1 -1
- package/dist/templates/auth-manifest.js +4 -0
- package/dist/utils/rbac-patcher.js +12 -4
- package/package.json +1 -1
- package/templates/add/auth/docs/schemas.yaml.hbs +54 -0
- package/templates/add/auth/docs/users-me-identities.yaml.hbs +13 -0
- package/templates/add/auth/docs/users-me-identity-link-exchange.yaml.hbs +26 -0
- package/templates/add/auth/docs/users-me-identity-link.yaml.hbs +25 -0
- package/templates/add/auth/docs/users-me-identity.yaml.hbs +15 -0
- package/templates/add/auth/docs/users-me-session.yaml.hbs +14 -0
- package/templates/add/auth/docs/users-me-sessions.yaml.hbs +13 -0
- package/templates/add/auth/internal/app/user/adapters/inbound/http/dto.go.hbs +62 -0
- package/templates/add/auth/internal/app/user/adapters/inbound/http/handler.go.hbs +7 -1
- package/templates/add/auth/internal/app/user/adapters/inbound/http/handler_identity.go.hbs +80 -0
- package/templates/add/auth/internal/app/user/adapters/inbound/http/handler_local.go.hbs +6 -2
- package/templates/add/auth/internal/app/user/adapters/inbound/http/handler_mfa.go.hbs +9 -0
- package/templates/add/auth/internal/app/user/adapters/inbound/http/handler_oauth.go.hbs +3 -1
- package/templates/add/auth/internal/app/user/adapters/inbound/http/handler_test.go.hbs +34 -0
- package/templates/add/auth/internal/app/user/adapters/inbound/http/handler_user.go.hbs +30 -0
- package/templates/add/auth/internal/app/user/adapters/outbound/postgres/mfa_store.go.hbs +3 -3
- package/templates/add/auth/internal/app/user/adapters/outbound/postgres/model.go.hbs +6 -1
- package/templates/add/auth/internal/app/user/adapters/outbound/postgres/repository.go.hbs +43 -0
- package/templates/add/auth/internal/app/user/adapters/outbound/postgres/tokenstore_pg.go.hbs +46 -7
- package/templates/add/auth/internal/app/user/adapters/outbound/postgres/tokenstore_pg_test.go.hbs +36 -0
- package/templates/add/auth/internal/app/user/adapters/outbound/redis/tokenstore.go.hbs +75 -0
- package/templates/add/auth/internal/app/user/adapters/outbound/redis/tokenstore_test.go.hbs +36 -0
- package/templates/add/auth/internal/app/user/application/dto.go.hbs +32 -0
- package/templates/add/auth/internal/app/user/application/errors.go.hbs +16 -0
- package/templates/add/auth/internal/app/user/application/external_login.go.hbs +42 -13
- package/templates/add/auth/internal/app/user/application/identities.go.hbs +97 -0
- package/templates/add/auth/internal/app/user/application/identities_test.go.hbs +69 -0
- package/templates/add/auth/internal/app/user/application/jwt.go.hbs +5 -2
- package/templates/add/auth/internal/app/user/application/local_auth.go.hbs +2 -2
- package/templates/add/auth/internal/app/user/application/mfa_service.go.hbs +13 -4
- package/templates/add/auth/internal/app/user/application/service.go.hbs +6 -0
- package/templates/add/auth/internal/app/user/application/service_test.go.hbs +107 -5
- package/templates/add/auth/internal/app/user/application/sessions.go.hbs +62 -8
- package/templates/add/auth/internal/app/user/application/tokenstore_ports.go.hbs +1 -0
- package/templates/add/auth/internal/app/user/domain/errors.go.hbs +3 -1
- package/templates/add/auth/internal/app/user/ports/repository.go.hbs +19 -0
- package/templates/add/auth/internal/shared/middleware/auth.go.hbs +9 -3
- package/templates/add/auth/internal/shared/middleware/auth_test.go.hbs +48 -0
- package/templates/add/auth/migrations/create_auth_tokens.up.sql.hbs +5 -1
- package/templates/add/auth/migrations/create_mfa.up.sql.hbs +2 -0
- package/templates/create/base/.claude/skills/go-scaffold/SKILL.md.hbs +9 -0
- package/templates/create/base/AGENTS.md.hbs +14 -0
- package/templates/create/base/README.md.hbs +9 -0
- package/templates/create/features/docs/architecture.md.hbs +5 -5
- package/templates/create/features/docs/techstack.md.hbs +1 -1
|
@@ -180,6 +180,20 @@ approval before changing their contract.
|
|
|
180
180
|
tombstone. Its inactivity expiry may move on rotation, but its persisted
|
|
181
181
|
absolute expiry never moves. Never replace it with a read-then-delete
|
|
182
182
|
sequence.
|
|
183
|
+
- Authenticated users can inspect active refresh sessions through
|
|
184
|
+
`GET /users/me/sessions` and revoke one with
|
|
185
|
+
`DELETE /users/me/sessions/:id`. Session IDs remain stable through refresh
|
|
186
|
+
rotation; responses expose only User-Agent and lifecycle timestamps, never
|
|
187
|
+
refresh tokens or token hashes. The current access token carries the session
|
|
188
|
+
ID as `sid` so the adapter can mark the current device.
|
|
189
|
+
- Authenticated users can manage login identities through
|
|
190
|
+
`GET /users/me/identities`, `POST /users/me/identities/:provider/link`,
|
|
191
|
+
`POST /users/me/identities/:provider/link/exchange`, and
|
|
192
|
+
`DELETE /users/me/identities/:provider`. The link transaction is bound to
|
|
193
|
+
the current user as well as provider/state/PKCE/nonce; it can never create a
|
|
194
|
+
session or silently move a provider account between users. Return only safe
|
|
195
|
+
provider metadata, allow at most one identity per provider per user, and
|
|
196
|
+
refuse to unlink the last remaining login method.
|
|
183
197
|
- Password reset and email verification consume a one-time token in the same
|
|
184
198
|
retry-safe transaction as the user/identity update. A failed post-commit
|
|
185
199
|
session revocation must not make a successful reset impossible to retry.
|
|
@@ -194,6 +194,15 @@ nonce; the frontend still owns the callback route and sends the code to the
|
|
|
194
194
|
exchange endpoint. The provider redirect URI is separate from
|
|
195
195
|
`CORS_ALLOWED_ORIGINS`; the latter remains an exact-origin credentialed API
|
|
196
196
|
policy. Token responses use `Cache-Control: no-store` and `Pragma: no-cache`.
|
|
197
|
+
Authenticated users can list active device sessions with
|
|
198
|
+
`GET /users/me/sessions` and revoke an individual session with
|
|
199
|
+
`DELETE /users/me/sessions/:id`; only User-Agent and session lifecycle
|
|
200
|
+
timestamps are returned.
|
|
201
|
+
They can also list safe login-provider metadata with
|
|
202
|
+
`GET /users/me/identities`, link a provider through the authenticated
|
|
203
|
+
`/users/me/identities/:provider/link` start/exchange flow, and unlink a
|
|
204
|
+
provider with `DELETE /users/me/identities/:provider`; the last login method
|
|
205
|
+
cannot be removed.
|
|
197
206
|
For `cross-site`, configure HTTPS origins, `COOKIE_SAMESITE=none`,
|
|
198
207
|
`COOKIE_SECURE=true`, and an exact allowed Origin; the API applies an Origin
|
|
199
208
|
guard independently of CORS.
|
|
@@ -60,7 +60,7 @@ internal/
|
|
|
60
60
|
```
|
|
61
61
|
|
|
62
62
|
Installed process and platform additions:
|
|
63
|
-
{{#if auth}}- `cmd/seed` and `platform/authprovider/google/` for user bootstrap
|
|
63
|
+
{{#if auth}}- `cmd/seed` and `platform/authprovider/google/` for user bootstrap, Google OAuth/OIDC login, and authenticated identity linking
|
|
64
64
|
{{/if}}{{#if worker}}- `cmd/worker` and `platform/{mail,queue}/` for queue/SMTP jobs{{#if (eq queue "asynq")}}, plus `platform/cache/` for Redis{{/if}}
|
|
65
65
|
{{/if}}{{#if observability}}- `platform/telemetry/` for the OTLP exporter
|
|
66
66
|
{{/if}}{{#if rbac}}- `shared/middleware/authz.go` and `app/role/` for RBAC policy
|
|
@@ -73,10 +73,10 @@ a real external system.
|
|
|
73
73
|
add a `shared/utils` or similarly generic package — name it after what it
|
|
74
74
|
actually does.
|
|
75
75
|
|
|
76
|
-
Optional feature boundaries are explicit: auth owns user authentication
|
|
77
|
-
provider ports; RBAC owns role policy and authorization;
|
|
78
|
-
mail adapters; observability owns metrics/tracing setup.
|
|
79
|
-
second domain architecture.
|
|
76
|
+
Optional feature boundaries are explicit: auth owns user authentication,
|
|
77
|
+
identity linking, and provider ports; RBAC owns role policy and authorization;
|
|
78
|
+
worker owns queue and mail adapters; observability owns metrics/tracing setup.
|
|
79
|
+
They do not create a second domain architecture.
|
|
80
80
|
|
|
81
81
|
## 3. API Style
|
|
82
82
|
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
| Logging | `log/slog`, JSON handler |
|
|
16
16
|
| Migrations | [golang-migrate](https://github.com/golang-migrate/migrate) |
|
|
17
17
|
| Testing | stdlib `testing`, real Postgres for integration tests |
|
|
18
|
-
| Authentication | {{#if auth}}JWT access/refresh sessions, password recovery, email verification, provider login, and MFA{{else}}optional via `go-scaffold add auth`{{/if}} |
|
|
18
|
+
| Authentication | {{#if auth}}JWT access/refresh sessions, password recovery, email verification, provider login/linking, and MFA{{else}}optional via `go-scaffold add auth`{{/if}} |
|
|
19
19
|
| Authorization | {{#if rbac}}RBAC role/permission middleware{{else}}optional RBAC via `go-scaffold add rbac`{{/if}} |
|
|
20
20
|
| Background jobs | {{#if worker}}{{queue}} queue backend with SMTP mail and `cmd/worker`{{else}}optional via `go-scaffold add worker`{{/if}} |
|
|
21
21
|
|