Title here
Summary here
Pionia Shop needs a simple login: Ada enters email and password, gets a token, and later calls order.place with that token. You do not want to invent a custom auth class for that everyday path.
customer.login returns a tokenAuthorization: Bearer …make:auth is worth it insteadcustomer.login checks the password and calls jwt_encode(…).Authorization: Bearer ….JwtAuthentication verifies the signature and fills $this->auth().#[Authenticated] decide whether this action may run.flowchart LR Login["customer.login"] --> Encode["jwt_encode"] Encode --> Client[Bearer token] Client --> Jwt[JwtAuthentication] Jwt --> Auth["$this->auth()"] Auth --> Attr["#[Authenticated]"]
.envJWT_SECRET=paste-a-long-random-value
JWT_TTL=3600
JWT_ALG=HS256php pionia shell
# secure_random_hex(32);Never commit real secrets. Optional INI section: [jwt] with SECRET, TTL, ALG.
[app_authentications]
jwt = "Pionia\Auth\JwtAuthentication"$token = jwt_encode([
'sub' => $customer->id,
'email' => $customer->email,
'permissions' => ['order.place', 'wallet.topup'],
]);
return response(0, 'Logged in', ['token' => $token]);| Helper | Role |
|---|---|
jwt_encode($claims) | Create the token |
jwt_decode($token) | Read claims (verifies by default) |
jwt_verify($token) | Soft true/false check |
jwt_refresh_token() | Opaque refresh string — not a new JWT |
sub / id become the user id; permissions / perms feed #[Can].
curl -s -X POST http://127.0.0.1:8000/api/v1/ \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_TOKEN" \
-d '{"service":"order","action":"place","product_id":1,"quantity":2}'Use php pionia make:auth ApiKey for partner keys or sessions. Prefer JwtAuthentication for normal Bearer JWT.
login itself — leave it public[app_authentications]Require login or permissions on checkout.
End-to-end in Pionia Shop.