|
| 1 | +# Database Connections POC Example |
| 2 | + |
| 3 | +This is a manual harness for live-tenant testing of `signUp` and `changePassword` database connection operations with Auth0. |
| 4 | + |
| 5 | +## Prerequisites |
| 6 | + |
| 7 | +- An Auth0 tenant with a database connection enabled on the app |
| 8 | +- Signup enabled on the connection (or expect documented signup-disabled behavior) |
| 9 | +- The client configured as either a confidential app (with client secret) or public app as configured |
| 10 | +- Node.js and npm installed |
| 11 | + |
| 12 | +## Setup |
| 13 | + |
| 14 | +1. Copy `.env.example` to `.env` and fill in your Auth0 tenant credentials: |
| 15 | + ```bash |
| 16 | + cp .env.example .env |
| 17 | + ``` |
| 18 | + |
| 19 | +2. Install workspace dependencies at the repo root: |
| 20 | + ```bash |
| 21 | + npm install |
| 22 | + ``` |
| 23 | + |
| 24 | +3. Build the auth0-auth-js and auth0-server-js packages first to ensure the example resolves the new database connection surface from dist: |
| 25 | + ```bash |
| 26 | + npm run build --workspace=packages/auth0-auth-js |
| 27 | + npm run build --workspace=packages/auth0-server-js |
| 28 | + ``` |
| 29 | + |
| 30 | +4. Install the example dependencies: |
| 31 | + ```bash |
| 32 | + npm install --workspace=examples/database-conns |
| 33 | + ``` |
| 34 | + |
| 35 | +## Running |
| 36 | + |
| 37 | +```bash |
| 38 | +npm start --workspace=examples/database-conns |
| 39 | +``` |
| 40 | + |
| 41 | +The app will start on the port specified in your `.env` (default: `http://localhost:3000`). |
| 42 | + |
| 43 | +## Testing |
| 44 | + |
| 45 | +### Sign Up |
| 46 | + |
| 47 | +Test user registration: |
| 48 | + |
| 49 | +```bash |
| 50 | +curl -X POST localhost:3000/signup \ |
| 51 | + -H 'content-type: application/json' \ |
| 52 | + -d '{"email":"new@example.com","password":"Str0ng-pw!"}' |
| 53 | +``` |
| 54 | + |
| 55 | +Expected success response: |
| 56 | +```json |
| 57 | +{ |
| 58 | + "ok": true, |
| 59 | + "user": { |
| 60 | + "id": "...", |
| 61 | + "email": "new@example.com", |
| 62 | + "emailVerified": false |
| 63 | + } |
| 64 | +} |
| 65 | +``` |
| 66 | + |
| 67 | +Expected error when re-running with the same email: |
| 68 | +```json |
| 69 | +{ |
| 70 | + "ok": false, |
| 71 | + "code": "signup_error", |
| 72 | + "message": "...", |
| 73 | + "cause": { "error": "..." } |
| 74 | +} |
| 75 | +``` |
| 76 | + |
| 77 | +### Change Password |
| 78 | + |
| 79 | +Test password reset request: |
| 80 | + |
| 81 | +```bash |
| 82 | +curl -X POST localhost:3000/change-password \ |
| 83 | + -H 'content-type: application/json' \ |
| 84 | + -d '{"email":"new@example.com"}' |
| 85 | +``` |
| 86 | + |
| 87 | +Expected success response: |
| 88 | +```json |
| 89 | +{ |
| 90 | + "ok": true, |
| 91 | + "message": "We've just sent you an email to reset your password." |
| 92 | +} |
| 93 | +``` |
| 94 | + |
| 95 | +A password reset email will be sent to the specified email address from your Auth0 tenant. |
| 96 | + |
| 97 | +## Investigation Notes |
| 98 | + |
| 99 | +This POC is the live-tenant check that closes the signup success-rate investigation. When running the tests above, capture observed status codes and response codes for: |
| 100 | + |
| 101 | +- Existing user signup attempt (expect 4xx validation error) |
| 102 | +- Weak password signup attempt (expect 4xx validation error) |
| 103 | +- Signup with disabled connection (expect 4xx validation error) |
| 104 | + |
| 105 | +These should all be expected validation 4xx responses, not a defect. Any 5xx or unexpected behavior indicates a platform issue. |
| 106 | + |
| 107 | +## Implementation Details |
| 108 | + |
| 109 | +The example: |
| 110 | +- Uses a simple no-op state store for the `ServerClient` (database operations never read or write session state) |
| 111 | +- Catches `SignUpError` and `ChangePasswordError` and surfaces them with appropriate HTTP status codes |
| 112 | +- Reads plain text responses from the change-password endpoint |
| 113 | + |
| 114 | +See the source files for implementation details. |
0 commit comments