Skip to content

Commit 40468b9

Browse files
committed
Cover default credentials and OpenAPI generation
The page claimed a generated spec ships; only the attribute sources do. Adds the credentials the fixtures seed as the first go-live step. Signed-off-by: arhimede <julian@dotkernel.com>
1 parent e780c20 commit 40468b9

1 file changed

Lines changed: 67 additions & 10 deletions

File tree

docs/book/v7/reference/production-readiness.md

Lines changed: 67 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22

33
## Summary
44

5-
Dotkernel API ships a complete application: a PSR-15 middleware pipeline, OAuth2 authentication, RBAC, input filtering, problem-details error responses and a generated OpenAPI specification.
5+
Dotkernel API ships a complete application: a PSR-15 middleware pipeline, OAuth2 authentication, RBAC, input filtering, problem-details error responses and the OpenAPI attribute sources you [generate the specification from](../openapi/generate-documentation.md).
66
What it does not ship is the operational layer a public API needs around it — rate limiting, API gateway integration, federated identity, log shipping and error tracking, health checks, metrics and response caching.
77
This page names each gap, says whether it belongs in the application or in the platform in front of it, and gives the concrete thing to configure until Dotkernel provides one.
8+
It also covers the one thing that does ship and has to go before launch: the demo credentials the Doctrine fixtures seed.
89

910
## Details
1011

@@ -21,6 +22,7 @@ Everything on this page was checked against the [dotkernel/api](https://github.c
2122

2223
| Concern | Ships with the API | Where it belongs | Tracked upstream |
2324
| --- | --- | --- | --- |
25+
| Default demo credentials | Yes — seeded by the Doctrine fixtures | Removed before launch ||
2426
| Rate limiting and throttling | No | Proxy, gateway, or a PSR-15 middleware | [#529](https://github.com/dotkernel/api/issues/529) |
2527
| API gateway integration | No | Platform ||
2628
| External OAuth2 / OIDC provider | No — the API is its own authorization server | Application ||
@@ -32,6 +34,32 @@ Everything on this page was checked against the [dotkernel/api](https://github.c
3234
| Background jobs and async work | No — mail is sent in-request | Separate service ||
3335
| Secrets management | No — cleartext PHP config | Platform ||
3436
| Scheduled dependency re-audit | No — Composer audits at resolution time, not on a schedule | Server | [#525](https://github.com/dotkernel/api/issues/525) |
37+
| OpenAPI specification file | No — attribute sources only, generated on demand | Build step ||
38+
39+
## Default credentials
40+
41+
Every other entry on this page is something missing.
42+
This one is something present: the Doctrine fixtures seed four sets of credentials, and all four are published in the repository.
43+
44+
| Seeded by | Identity | Secret |
45+
| --- | --- | --- |
46+
| `AdminLoader` | `admin` | `dotadmin` |
47+
| `UserLoader` | `test@dotkernel.com` | `dotkernel` |
48+
| `OAuthClientLoader` | `admin` | `admin` |
49+
| `OAuthClientLoader` | `frontend` | `frontend` |
50+
51+
The password grant needs both halves, a client and an account, and the fixtures supply a matching pair of each.
52+
Running `php ./bin/doctrine fixtures:execute` against a production database therefore leaves `/security/generate-token` answering to the `admin` client with secret `admin` and the `admin` account with password `dotadmin`, which between them reach every administrator endpoint in the API.
53+
54+
Change them before you seed, by editing the loaders in `src/Core/src/App/src/Fixture/`:
55+
56+
- `AdminLoader.php` and `UserLoader.php``setIdentity()` for the identity, `usePassword()` for the password, and optionally `setFirstName()` and `setLastName()`.
57+
- `OAuthClientLoader.php``setName()` and `setSecret()`.
58+
59+
If a database has already been seeded, treat all four as public.
60+
Create a replacement administrator with `php ./bin/cli.php admin:create`, then remove the `admin` and `test@dotkernel.com` accounts and re-secret both OAuth clients.
61+
62+
[Basic Security](../security/basic-security.md) covers the demo accounts and [OAuth2 Security](../security/oauth2-security.md) the clients.
3563

3664
## Rate limiting
3765

@@ -243,19 +271,43 @@ Until there is, either accept in-request sending or dispatch to a worker you wir
243271
A server installed once and left alone has never been re-examined against advisories published since, so run `composer audit` there on a schedule rather than only at install time.
244272
Issue #525 proposes pinning the policy explicitly in `composer.json` rather than inheriting the defaults.
245273

274+
## OpenAPI specification
275+
276+
The attributes ship; the specification file does not.
277+
Every path, schema and security scheme is declared across four files — `src/App/src/OpenAPI.php`, `src/Admin/src/OpenAPI.php`, `src/Security/src/OpenAPI.php` and `src/User/src/OpenAPI.php` — and `public/` contains no `openapi.yaml` or `openapi.json`.
278+
Producing one is a step you add to your own build or deploy:
279+
280+
```shell
281+
./vendor/bin/openapi ./src --output public/openapi.yaml
282+
```
283+
284+
`zircote/swagger-php` is a `require` rather than a `require-dev` dependency, so `vendor/bin/openapi` is present on a production install as well.
285+
286+
Two things to get right.
287+
288+
**The server URL defaults to localhost.**
289+
`src/App/src/OpenAPI.php` declares `#[OA\Server(url: 'http://api.dotkernel.localhost')]`, so a specification generated without editing that line tells every client to call your development host.
290+
291+
**The file is a snapshot.**
292+
No Composer script wraps the command and nothing regenerates the file when the attributes change, so a specification generated once drifts from the API it describes.
293+
Regenerate it in the same step that deploys the code.
294+
295+
See [Generate documentation](../openapi/generate-documentation.md) for the version and format options, and [Render documentation](../openapi/render-documentation.md) for serving the result.
296+
246297
## A minimum before you go live
247298

248299
Ordered by what bites first:
249300

250-
1. Rate-limit `/security/generate-token` and `/error-report` at the proxy.
251-
2. Disable the OAuth2 grants you do not use, starting with the implicit grant.
252-
3. Point `dot-errorhandler` at a logger that reaches somebody — Sentry, or at least a shipped `stderr` stream.
253-
4. Add `logrotate` for `log/`, or repoint the writer at standard output.
254-
5. Add a readiness endpoint that checks the database, and point your load balancer at it rather than `/`.
255-
6. Fix `X-Forwarded-For` handling at the proxy, since the application trusts the header as sent.
256-
7. Set a default `Cache-Control` for the whole API instead of leaving it unset.
257-
8. Schedule `composer audit` on each server — the install that generated its lock was audited, but nothing re-checks that lock afterwards.
258-
9. Work through [Basic Security](../security/basic-security.md) and [OAuth2 Security](../security/oauth2-security.md), which cover the application-level hardening this page does not repeat.
301+
1. Change every seeded credential — both demo accounts and both OAuth clients — or delete them once a real administrator exists.
302+
2. Rate-limit `/security/generate-token` and `/error-report` at the proxy.
303+
3. Disable the OAuth2 grants you do not use, starting with the implicit grant.
304+
4. Point `dot-errorhandler` at a logger that reaches somebody — Sentry, or at least a shipped `stderr` stream.
305+
5. Add `logrotate` for `log/`, or repoint the writer at standard output.
306+
6. Add a readiness endpoint that checks the database, and point your load balancer at it rather than `/`.
307+
7. Fix `X-Forwarded-For` handling at the proxy, since the application trusts the header as sent.
308+
8. Set a default `Cache-Control` for the whole API instead of leaving it unset.
309+
9. Schedule `composer audit` on each server — the install that generated its lock was audited, but nothing re-checks that lock afterwards.
310+
10. Work through [Basic Security](../security/basic-security.md) and [OAuth2 Security](../security/oauth2-security.md), which cover the application-level hardening this page does not repeat.
259311

260312
## FAQ
261313

@@ -265,6 +317,11 @@ A: No.
265317
The application is complete and tested; what is missing is the operational layer around it, most of which is conventionally the platform's job.
266318
The gap is documentation, not code — nothing tells you which half you still have to build.
267319

320+
**Q: What are the default credentials, and where do I change them?**
321+
322+
A: `admin` / `dotadmin` and `test@dotkernel.com` / `dotkernel` for the accounts, and OAuth clients `admin` / `admin` and `frontend` / `frontend`.
323+
All four come from the fixture loaders in `src/Core/src/App/src/Fixture/`, so edit those before running `php ./bin/doctrine fixtures:execute`, or replace the records afterwards.
324+
268325
**Q: Which of these should I solve in the application rather than the platform?**
269326

270327
A: External identity provider integration, error tracking, the health endpoint, caching headers and asynchronous mail.

0 commit comments

Comments
 (0)