Take a high-value payment#
Level 3: a verified identity and a hardware passkey. Anything weaker is refused.
| Level | 3: A person verified at the highest level approves with a hardware passkey. |
| Class | irreversible: Cannot be undone. The app creates the approval for that exact request, and it works once. |
routes.append(route("POST", "/payees/{payee}/transfers", "transfers:send", cls="irreversible", level=3,
authn="hardware", resource="payee:{payee}", amount_field="/amount", summary="Send a bank transfer",
body={"amount": "a decimal string, e.g. 4000.00", "currency": "e.g. EUR"}))
templates["transfers:send"] = "Transfer {amount.max} {amount.currency} to {scope}"
@app.post("/payees/<payee>/transfers")
def transfer(payee):
# Level 3: an identity verified to eIDAS high, and a passkey that never leaves its device.
order = request.json
return {"sent": order["amount"], "currency": order["currency"], "to": payee, "level": g.allowedby.level}, 201routes.push(route("POST", "/payees/{payee}/transfers", "transfers:send", {
class: "irreversible", level: 3, authn: "hardware", resource: "payee:{payee}", amountField: "/amount",
summary: "Send a bank transfer", body: { amount: "a decimal string, e.g. 4000.00", currency: "e.g. EUR" },
}));
templates["transfers:send"] = "Transfer {amount.max} {amount.currency} to {scope}";
api.post("/payees/:payee/transfers", (req, res) => {
// Level 3: an identity verified to eIDAS high, and a passkey that never leaves its device.
const { amount, currency } = req.body;
res.status(201).json({ sent: amount, currency, to: req.params.payee, level: req.allowedby.level });
});routes = append(routes, allowedby.Route{Method: "POST", Path: "/payees/{payee}/transfers",
Capability: "transfers:send", Class: allowedby.Irreversible, Level: 3, Authn: "hardware",
Resource: "payee:{payee}", AmountField: "/amount", Summary: "Send a bank transfer",
Body: map[string]string{"amount": "a decimal string, e.g. 4000.00", "currency": "e.g. EUR"}})
templates["transfers:send"] = allowedby.Text("Transfer {amount.max} {amount.currency} to {scope}")
mux.HandleFunc("POST /payees/{payee}/transfers", func(w http.ResponseWriter, r *http.Request) {
// Level 3: an identity verified to eIDAS high, and a passkey that never leaves its device.
who, _ := allowedby.ContextFrom(r.Context())
var order struct{ Amount, Currency string }
if err := json.NewDecoder(r.Body).Decode(&order); err != nil {
writeJSON(w, http.StatusBadRequest, map[string]string{"error": "amount, currency: strings"})
return
}
writeJSON(w, http.StatusCreated, map[string]any{
"sent": order.Amount, "currency": order.Currency, "to": r.PathValue("payee"), "level": who.Level})
})@Bean
AllowedByCustomizer payHigh() {
return aby -> aby
.route(Route.post("/payees/{payee}/transfers").capability("transfers:send")
.actionClass(ActionClass.IRREVERSIBLE).level(3).authn("hardware").resource("payee:{payee}")
.amountField("/amount").summary("Send a bank transfer")
.body(Map.of("amount", "a decimal string, e.g. 4000.00", "currency", "e.g. EUR")))
.template("transfers:send", "Transfer {amount.max} {amount.currency} to {scope}");
}
@PostMapping("/payees/{payee}/transfers")
@ResponseStatus(HttpStatus.CREATED)
Map<String, Object> transfer(@AllowedByContext Context ctx, @PathVariable String payee,
@RequestBody Payment order) {
// Level 3: an identity verified to eIDAS high, and a passkey that never leaves its device.
return Map.of("sent", order.amount(), "currency", order.currency(), "to", payee, "level", ctx.getLevel());
}routes.Add(Route("POST", "/payees/{payee}/transfers", "transfers:send", cls: "irreversible", level: 3, authn: "hardware",
resource: "payee:{payee}", amountField: "/amount", summary: "Send a bank transfer",
body: new Dictionary<string, string> { ["amount"] = "a decimal string, e.g. 4000.00", ["currency"] = "e.g. EUR" }));
templates["transfers:send"] = "Transfer {amount.max} {amount.currency} to {scope}";
app.MapPost("/payees/{payee}/transfers", (string payee, Payment order, AllowedByContext ctx) =>
// Level 3: an identity verified to eIDAS high, and a passkey that never leaves its device.
Results.Json(new { sent = order.Amount, currency = order.Currency, to = payee, level = ctx.Level }, statusCode: 201));$routes[] = route('POST', '/payees/{payee}/transfers', 'transfers:send', class: 'irreversible', level: 3,
authn: 'hardware', resource: 'payee:{payee}', amountField: '/amount', summary: 'Send a bank transfer',
body: ['amount' => 'a decimal string, e.g. 4000.00', 'currency' => 'e.g. EUR']);
$templates['transfers:send'] = 'Transfer {amount.max} {amount.currency} to {scope}';
$app->post('/payees/{payee}/transfers', function (Request $request, Response $response, array $args) use ($json) {
// Level 3: an identity verified to eIDAS high, and a passkey that never leaves its device.
$level = $request->getAttribute('allowedby.context')->level;
$order = json_decode((string) $request->getBody(), true);
return $json($response, ['sent' => $order['amount'], 'currency' => $order['currency'], 'to' => $args['payee'],
'level' => $level], 201);
});ROUTES << AllowedBy.route(
"POST", "/payees/{payee}/transfers", "transfers:send",
class: "irreversible", level: 3, authn: "hardware", resource: "payee:{payee}", amount_field: "/amount",
summary: "Send a bank transfer", body: { amount: "a decimal string, e.g. 4000.00", currency: "e.g. EUR" }
)
TEMPLATES["transfers:send"] = "Transfer {amount.max} {amount.currency} to {scope}"
post "/payees/:payee/transfers" do
# Level 3: an identity verified to eIDAS high, and a passkey that never leaves its device.
order = JSON.parse(request.body.read)
level = env["allowedby.context"].level
[201, { sent: order["amount"], currency: order["currency"], to: params["payee"], level: level }.to_json]
endlet aby = aby
.route(
Route::post("/payees/{payee}/transfers")
.capability("transfers:send")
.class(Class::Irreversible)
.level(3)
.authn(Authn::Hardware)
.resource("payee:{payee}")
.amount_field("/amount")
.summary("Send a bank transfer")
.body_field("amount", "a decimal string, e.g. 4000.00")
.body_field("currency", "e.g. EUR"),
)
.template("transfers:send", "Transfer {amount.max} {amount.currency} to {scope}");
let app = app.route("/payees/{payee}/transfers", post(transfer));
async fn transfer(
ctx: AllowedByContext,
Path(payee): Path<String>,
Json(order): Json<Payment>,
) -> (StatusCode, Json<Value>) {
// Level 3: an identity verified to eIDAS high, and a passkey that never leaves its device.
let sent = json!({"sent": order.amount, "currency": order.currency, "to": payee, "level": ctx.level});
(StatusCode::CREATED, Json(sent))
}What the test proves#
- a passkey that is synced, or that no hardware vouches for, cannot reach level 3: refused
- with a hardware passkey and an identity verified to level 3, the person approves: 201
- the approval works once