JWT protected route

Learn how a route that takes AuthUser as an argument only runs for requests with a valid token, and what an unauthenticated request receives

A protected route is a route that only runs for a caller the server knows. The protection is not a check inside the handler, and it is not a layer wrapped around the route. It is the handler's argument list. A handler that takes AuthUser as an argument can only run after the extractor has built one, and the extractor only builds one from a valid token. A request without a valid token never reaches the handler body, and it receives a 401 with the shared error body. One argument is the whole protection.

Where This Fits

The login step mints a token, the verification step checks one, the extractor turns a checked token into a typed user, and the header scheme says how the token travels. This page puts those pieces together into a route that uses them. The route is the thing a client actually calls, and the argument is the thing that decides whether the call gets through. Everything before this page was a piece, and this page is the assembled door.

Think of a members-only reading room. The room has one door, and the doorkeeper stands in it. A member shows a card, the doorkeeper checks it, and the member walks in. A visitor with no card is stopped at the door, and never sees the room. The route is the room, the extractor is the doorkeeper, and the token is the card. The room itself never checks anyone, because the door already did.

The Smallest Working Version

Create a project with the same files as the login page. It has two routes: POST /login, which mints the token, and GET /profile, which takes AuthUser and is protected by it.

Cargo.toml
[package]
name = "axum-project"
version = "0.1.0"
edition = "2021"

[dependencies]
axum = "0.8"
tokio = { version = "1", features = ["full"] }
serde = { version = "1", features = ["derive"] }
serde_json = "1"
sqlx = { version = "0.9", features = ["runtime-tokio", "postgres", "macros", "derive"] }
jsonwebtoken = { version = "12", features = ["rust_crypto"] }
argon2 = "0.6"
thiserror = "2.0"

[dev-dependencies]
tower = { version = "0.5", features = ["util"] }
src/auth.rs
use std::time::{SystemTime, UNIX_EPOCH};

use argon2::{
    Argon2,
    password_hash::{PasswordVerifier, phc::PasswordHash},
};
use axum::{
    extract::FromRequestParts,
    http::{HeaderMap, header, request::Parts},
};
use jsonwebtoken::{DecodingKey, EncodingKey, Header, Validation, decode, encode};
use serde::{Deserialize, Serialize};
use sqlx::PgPool;

use crate::errors::AppError;

#[derive(Debug, Serialize, Deserialize)]
pub struct Claims {
    pub sub: i32,
    pub role: String,
    pub exp: usize,
}

#[derive(Debug, Clone)]
pub struct AuthUser {
    pub user_id: i32,
    pub role: String,
}

#[derive(Debug, Deserialize)]
pub struct LoginInput {
    pub email: String,
    pub password: String,
}

#[derive(Debug, Serialize)]
pub struct LoginResponse {
    pub token: String,
}

pub fn password_matches(password: &str, stored_hash: &str) -> bool {
    let Ok(parsed_hash) = PasswordHash::new(stored_hash) else {
        return false;
    };
    Argon2::default()
        .verify_password(password.as_bytes(), &parsed_hash)
        .is_ok()
}

fn expiry_in_one_hour() -> usize {
    let now = SystemTime::now()
        .duration_since(UNIX_EPOCH)
        .expect("system time is before the Unix epoch")
        .as_secs() as usize;
    now + 3600
}

pub fn create_token(user_id: i32, role: &str, secret: &str) -> Result<String, AppError> {
    let claims = Claims {
        sub: user_id,
        role: role.to_string(),
        exp: expiry_in_one_hour(),
    };
    let key = EncodingKey::from_secret(secret.as_bytes()).map_err(|error| {
        eprintln!("encoding key error: {error}");
        AppError::InternalError
    })?;
    encode(&Header::default(), &claims, &key).map_err(|error| {
        eprintln!("token encode error: {error}");
        AppError::InternalError
    })
}

pub fn verify_token(token: &str, secret: &str) -> Result<Claims, AppError> {
    let key = DecodingKey::from_secret(secret.as_bytes()).map_err(|error| {
        eprintln!("decoding key error: {error}");
        AppError::Unauthorized
    })?;
    let data = decode::<Claims>(token, &key, &Validation::default()).map_err(|error| {
        eprintln!("token decode error: {error}");
        AppError::Unauthorized
    })?;
    Ok(data.claims)
}

pub fn bearer_token(headers: &HeaderMap) -> Option<&str> {
    headers
        .get(header::AUTHORIZATION)
        .and_then(|value| value.to_str().ok())
        .and_then(|value| value.strip_prefix("Bearer "))
}

impl FromRequestParts<PgPool> for AuthUser {
    type Rejection = AppError;

    async fn from_request_parts(
        parts: &mut Parts,
        _state: &PgPool,
    ) -> Result<Self, Self::Rejection> {
        let Some(token) = bearer_token(&parts.headers) else {
            return Err(AppError::Unauthorized);
        };
        let secret = std::env::var("JWT_SECRET").map_err(|_| AppError::Unauthorized)?;
        let claims = verify_token(token, &secret)?;
        Ok(AuthUser {
            user_id: claims.sub,
            role: claims.role,
        })
    }
}

This file holds every auth piece in one place: the claims, the typed user, the login types, the password check, the minting helper, the verification helper, the header helper, and the extractor. A project of this size keeps them together, because they all describe the same idea, and splitting them across files would only make the idea harder to follow.

src/handlers.rs
use axum::{Json, extract::State};
use serde_json::json;
use sqlx::{FromRow, PgPool};

use crate::{
    auth::{AuthUser, LoginInput, LoginResponse, create_token, password_matches},
    errors::{AppError, HandlerResult},
};

#[derive(Debug, FromRow)]
pub struct LoginRow {
    pub id: i32,
    pub password_hash: Option<String>,
}

pub async fn login(
    State(pool): State<PgPool>,
    Json(input): Json<LoginInput>,
) -> HandlerResult<Json<LoginResponse>> {
    let row = sqlx::query_as!(
        LoginRow,
        "SELECT id, password_hash FROM users WHERE email = $1",
        input.email
    )
    .fetch_optional(&pool)
    .await?;
    let Some(row) = row else {
        return Err(AppError::Unauthorized);
    };
    let Some(stored_hash) = row.password_hash else {
        return Err(AppError::Unauthorized);
    };
    if !password_matches(&input.password, &stored_hash) {
        return Err(AppError::Unauthorized);
    }
    let secret = std::env::var("JWT_SECRET").map_err(|_| AppError::InternalError)?;
    let token = create_token(row.id, "user", &secret)?;
    Ok(Json(LoginResponse { token }))
}

pub async fn profile(user: AuthUser) -> HandlerResult<Json<serde_json::Value>> {
    Ok(Json(json!({ "user_id": user.user_id, "role": user.role })))
}

pub async fn home() -> &'static str {
    "Welcome! This page is open to everyone."
}

Three handlers sit side by side, and the difference between them is the argument list. login takes the pool and the JSON body, and it is open to everyone, because a login route that required a token could never be used. profile takes AuthUser, and it is protected, because the argument cannot be built without a valid token. home takes nothing, and it is open to everyone, because it serves public data. The router table shows at a glance which routes are protected, because the protection is visible in the handler signature.

src/lib.rs
pub mod auth;
pub mod db;
pub mod errors;
pub mod handlers;

use axum::{Router, routing::{get, post}};
use handlers::{home, login, profile};
use sqlx::PgPool;

pub fn app(pool: PgPool) -> Router {
    Router::new()
        .route("/", get(home))
        .route("/login", post(login))
        .route("/profile", get(profile))
        .with_state(pool)
}
src/main.rs
use axum_project::{app, db::create_pool};

#[tokio::main]
async fn main() {
    let database_url = std::env::var("DATABASE_URL").expect("DATABASE_URL must be set");
    let pool = create_pool(&database_url)
        .await
        .expect("failed to connect to the database");
    let router = app(pool);
    let listener = tokio::net::TcpListener::bind("127.0.0.1:3000")
        .await
        .unwrap();
    println!("Server running at http://127.0.0.1:3000");
    axum::serve(listener, router).await.unwrap();
}

Start the server with the database URL and the signing secret, using the seeded user from the login page:

DATABASE_URL="postgres://axumdocs:axumdocs@127.0.0.1:5432/ch13_jwt" JWT_SECRET="test-secret-only-for-local-development" cargo run

The public route answers without any token:

curl http://127.0.0.1:3000/
Welcome! This page is open to everyone.

The protected route refuses the same anonymous request:

curl -i http://127.0.0.1:3000/profile
HTTP/1.1 401 Unauthorized
content-type: application/json
content-length: 24

{"error":"unauthorized"}

Log in to get a token, then call the protected route with it:

curl -X POST http://127.0.0.1:3000/login \
  -H "Content-Type: application/json" \
  -d '{"email": "ada@example.com", "password": "ada-secret-password"}'
{"token":"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOjEsInJvbGUiOiJ1c2VyIiwiZXhwIjoxNzk0NjQ4MTU0fQ.Yytn5--kvv7H5_OXXodlwtqRzwdK_UcbdF5Wt9WbmYc"}
curl -H "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOjEsInJvbGUiOiJ1c2VyIiwiZXhwIjoxNzk0NjQ4MTU0fQ.Yytn5--kvv7H5_OXXodlwtqRzwdK_UcbdF5Wt9WbmYc" http://127.0.0.1:3000/profile
{"role":"user","user_id":1}

The same server serves a public route, an open login route, and a protected route, and the difference between them is one argument. The public route and the login route take no AuthUser, and the protected route takes one. That is the whole mechanism, and the rest of this page is about what it guarantees and where it breaks.

Working Setup:

If the public route answers without a token, the protected route answers 401 without a token, and the protected route answers 200 with the user data when the token is sent, the route is protected correctly. The three outcomes come from one argument.

How the Argument Protects the Route

The protection works because of the order Axum runs things in. When a request arrives for /profile, Axum looks at the handler signature and runs each extractor in argument order, before the handler body. AuthUser is the only argument, so its from_request_parts runs first. That method reads the header, reads the secret, and verifies the token, and it returns either a typed user or the unauthorized error. On success, Axum calls the handler body with the user. On failure, Axum turns the error into the response, and the handler body never runs.

That order is a guarantee, not a convention. A handler cannot forget to check the token, because the handler never receives control until the check has passed. A handler cannot check the token after doing its work, because the check runs before the body. And a handler cannot receive an unverified user, because the only way to build the value is through the verification. The compiler and the framework together enforce what a code review would otherwise have to catch on every handler.

The guarantee also covers the data the handler uses. The user_id in the handler body came from a verified token, so a handler that loads a row by that id loads the row of the user who logged in, and not of anyone else. The handler does not need to re-check the id against anything, because the id was proved by the signature. The trust flows from the secret, through the signature, into the claims, into the struct, and into the handler, and each step preserves it.

Protection Is Per Handler, Not Per Router:

The router does not know which routes are protected. Each handler declares its own need by taking AuthUser or leaving it out, and the router only maps paths to handlers. A new route is protected by taking the argument, and it is open by leaving it out. There is no central list to update, and no route can accidentally inherit protection it was never given, or lose protection it was meant to have, except by changing its own signature.

What an Unauthenticated Request Receives

An unauthenticated request is a request the server cannot tie to any user, and it receives status 401 with the body {"error": "unauthorized"}. The status means the server does not know who is asking, and the body is the same generic word the login step uses for its failures. The response is identical whether the header was missing, the token was malformed, the signature was wrong, or the token had expired, because the server must not say which part failed.

The 401 is an invitation to try again with credentials. A client that receives it can ask the user to log in, fetch a fresh token, and repeat the request, and the retry may succeed, because the problem was missing proof, not a rule the user broke. That is the test that separates 401 from 403. A 403 answer means the server knows who is asking and refuses anyway, and logging in again changes nothing. A 401 answer means the server does not know who is asking, and logging in again may fix it.

Do Not Send the User to Login on a 403:

A client that treats every refusal as a login problem will show a login screen for a 403, and the user will log in, retry, and be refused again, because the refusal was about permission, not identity. Read the status before deciding what to do: 401 means log in and retry, 403 means stop and show a message about permission. Mixing the two up turns a permission refusal into a login loop.

The response carries no detail about the failure, and it carries no hint about whether the route exists. A request to a protected route that does not exist gets a 404 from the router before any extractor runs, because the router matches the path first. A request to a protected route that does exist gets the 401, which confirms the route exists and the caller is unknown. That confirmation is acceptable, because the route name is not a secret, and the 401 says nothing about what the route would return to a known user.

A Protected Route That Uses the User

The profile handler above only echoes the user back. A realistic handler uses the user id to load that user's data, and the protection is what makes the lookup safe. The handler below loads the user's row from the database by the id from the token, and returns the name and email of the user who is asking, and of nobody else.

src/handlers.rs
use axum::{Json, extract::State};
use serde::{Deserialize, Serialize};
use sqlx::{FromRow, PgPool};

use crate::{
    auth::AuthUser,
    errors::HandlerResult,
};

#[derive(Debug, Serialize, FromRow)]
pub struct User {
    pub id: i32,
    pub name: String,
    pub email: String,
}

pub async fn my_profile(
    State(pool): State<PgPool>,
    user: AuthUser,
) -> HandlerResult<Json<User>> {
    let found = sqlx::query_as!(
        User,
        "SELECT id, name, email FROM users WHERE id = $1",
        user.user_id
    )
    .fetch_one(&pool)
    .await?;
    Ok(Json(found))
}

The handler takes two extractor arguments, and their order matters. State(pool) runs first, and AuthUser runs second, because extractors run in argument order. The body then uses user.user_id as the $1 placeholder in the query, so the row it loads is the row of the user who logged in. A user who asks for their own profile gets their own row, and there is no id in the URL or the body for an attacker to change. The id comes from the token, and the token was verified, so the id cannot be forged.

An Id From the Caller Is an Id the Caller Controls:

A handler that reads the user id from the path, the query string, or the body lets any caller ask for any user's data, because the caller chooses the value. The only id a handler may trust for "whose data is this" is the one from AuthUser, which came from a verified token. If a route takes both an id and an AuthUser, the handler must check that the two agree, and refuse the request when they do not, because a mismatch means the caller is asking for someone else's data.

The route for it is registered the same way as the others:

src/lib.rs
pub fn app(pool: PgPool) -> Router {
    Router::new()
        .route("/", get(home))
        .route("/login", post(login))
        .route("/profile", get(profile))
        .route("/me", get(my_profile))
        .with_state(pool)
}

Calling /me with Ada's token returns Ada's row:

curl -H "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOjEsInJvbGUiOiJ1c2VyIiwiZXhwIjoxNzk0NjQ4MTU0fQ.Yytn5--kvv7H5_OXXodlwtqRzwdK_UcbdF5Wt9WbmYc" http://127.0.0.1:3000/me
{"id":1,"name":"Ada","email":"ada@example.com"}

Calling it without a token returns the 401, before any database query runs. The extractor refuses the request, so the handler body never runs, and the database is never touched. An unauthenticated request costs the server one header read and nothing else.

A Plain Text Diagram of the Flow

The request passes through the router, the extractor, and the handler, in that order, and the failure exits are all the same.

request arrives for GET /profile
        |
        v
router matches the path to the profile handler
        |
        v
AuthUser extractor runs
        |
        +-- no header --> 401 + {"error": "unauthorized"}
        +-- bad token --> 401 + {"error": "unauthorized"}
        +-- expired token --> 401 + {"error": "unauthorized"}
        |
        v
handler body runs with the typed user
        |
        v
200 + {"role": "user", "user_id": 1}

The diagram has three failure exits that look the same and one success exit. The router match comes first, because a request to a path that does not exist gets a 404 before any extractor runs. The extractor comes second, because the handler cannot run without its argument. The handler comes last, because it is the only part that does the work the route exists for.

Testing It

The tests below cover the three outcomes for the protected route: an anonymous request is refused, a request with a good token succeeds, and a request with a bad token is refused. They send requests through the router with oneshot, which sends one request directly through the router with no network involved.

tests/jwt_test.rs
use axum::{
    body::{Body, to_bytes},
    http::{Request, StatusCode},
};
use axum_project::{app, db::create_pool};
use tower::ServiceExt;

async fn call(uri: &str, token: Option<&str>) -> (StatusCode, String) {
    let database_url = std::env::var("DATABASE_URL").expect("DATABASE_URL must be set");
    let pool = create_pool(&database_url).await.unwrap();
    let mut builder = Request::builder().uri(uri);
    if let Some(token) = token {
        builder = builder.header("authorization", format!("Bearer {token}"));
    }
    let response = app(pool)
        .oneshot(builder.body(Body::empty()).unwrap())
        .await
        .unwrap();
    let status = response.status();
    let bytes = to_bytes(response.into_body(), usize::MAX).await.unwrap();
    (status, String::from_utf8(bytes.to_vec()).unwrap())
}

#[tokio::test]
async fn public_route_answers_without_a_token() {
    let (status, body) = call("/", None).await;
    assert_eq!(status, StatusCode::OK);
    assert_eq!(body, "Welcome! This page is open to everyone.");
}

#[tokio::test]
async fn protected_route_without_token_is_unauthorized() {
    let (status, body) = call("/profile", None).await;
    assert_eq!(status, StatusCode::UNAUTHORIZED);
    assert_eq!(body, r#"{"error":"unauthorized"}"#);
}

#[tokio::test]
async fn protected_route_with_bad_token_is_unauthorized() {
    let (status, body) = call("/profile", Some("not-a-token")).await;
    assert_eq!(status, StatusCode::UNAUTHORIZED);
    assert_eq!(body, r#"{"error":"unauthorized"}"#);
}

The shared call helper builds any request with an optional token, so each test stays short. The public-route test is the one that guards the design: it proves the protection is per handler, not global, because the same router serves an open route and a protected route, and only the protected one refuses anonymous requests. The bad-token test uses a plain string, not a well-formed token, which is the simplest malformed case, and it asserts the same 401 as the missing-header test. Run them with:

DATABASE_URL="postgres://axumdocs:axumdocs@127.0.0.1:5432/ch13_jwt" JWT_SECRET="test-secret-only-for-local-development" cargo test --test jwt_test -- --test-threads=1
test protected_route_with_bad_token_is_unauthorized ... ok
test protected_route_without_token_is_unauthorized ... ok
test public_route_answers_without_a_token ... ok

Common Beginner Mistakes

Checking the token inside the handler body

// Wrong - the check belongs in the extractor, and the handler body must never run unchecked
pub async fn profile(headers: HeaderMap) -> HandlerResult<Json<serde_json::Value>> {
    let data = load_profile_data().await?;
    let token = bearer_token(&headers).ok_or(AppError::Unauthorized)?;
    let secret = std::env::var("JWT_SECRET").map_err(|_| AppError::Unauthorized)?;
    let claims = verify_token(token, &secret)?;
    Ok(Json(json!({ "user_id": claims.sub, "role": claims.role })))
}

This handler loads the profile data before it checks the token, so an unauthenticated request still pays the cost of the load, and any side effect in the load happens for a request that should have been turned away at the door. The fix is the AuthUser argument, which moves the check before the body and guarantees the body never runs unchecked. The argument is the protection, and a check written by hand inside the body is a protection that can be forgotten, reordered, or skipped.

Protecting the login route

// Wrong - a login route that needs a token can never be used
pub fn app(pool: PgPool) -> Router {
    Router::new()
        .route("/login", post(login_with_auth))
        .route("/profile", get(profile))
        .with_state(pool)
}

A login route exists to mint the first token, so it cannot require one. A handler that takes AuthUser on the login route would refuse every login, because no caller has a token yet. The fix is to leave AuthUser off the login handler, as the working version does. The rule is simple: the route that hands out tokens is open, and the routes that accept tokens are protected.

Using 403 for an unauthenticated request

// Wrong - the server does not know who is asking yet, so the answer is 401
impl FromRequestParts<PgPool> for AuthUser {
    type Rejection = AppError;

    async fn from_request_parts(
        parts: &mut Parts,
        _state: &PgPool,
    ) -> Result<Self, Self::Rejection> {
        let Some(token) = bearer_token(&parts.headers) else {
            return Err(AppError::Forbidden);
        };
        let secret = std::env::var("JWT_SECRET").map_err(|_| AppError::Forbidden)?;
        let claims = verify_token(token, &secret)?;
        Ok(AuthUser {
            user_id: claims.sub,
            role: claims.role,
        })
    }
}

A missing token is not a permission problem. The server has no user to check permission against, so 403 is the wrong status. The fix is the unauthorized variant. The rule to remember is the retry test: if logging in could fix the request, the answer is 401. A 403 answer says logging in again changes nothing, and that is false for a request that arrived with no token at all.

Trusting a user id from the URL instead of the token

// Wrong - the id in the URL is chosen by the caller, and any caller can ask for any id
pub async fn profile(Path(id): Path<i32>) -> HandlerResult<Json<User>> {
    let found = sqlx::query_as!(User, "SELECT id, name, email FROM users WHERE id = $1", id)
        .fetch_one(&pool)
        .await?;
    Ok(Json(found))
}

A handler that reads the user id from the path lets any caller ask for any user's data, because the id is whatever the caller wrote in the URL. The fix is the id from AuthUser, which came from a verified token and cannot be chosen by the caller. The route stays /profile with no id in it, and the handler loads the row for the user the token names. An id the caller supplies is an id the caller controls, and an id the token supplies is an id the server proved.

Final Complete Example

Here is everything from this page put together: the three handlers, the router with its public and protected routes, and the entry point that starts the server.

src/handlers.rs
use axum::{Json, extract::State};
use serde_json::json;
use sqlx::{FromRow, PgPool};

use crate::{
    auth::{AuthUser, LoginInput, LoginResponse, create_token, password_matches},
    errors::{AppError, HandlerResult},
};

#[derive(Debug, FromRow)]
pub struct LoginRow {
    pub id: i32,
    pub password_hash: Option<String>,
}

pub async fn login(
    State(pool): State<PgPool>,
    Json(input): Json<LoginInput>,
) -> HandlerResult<Json<LoginResponse>> {
    let row = sqlx::query_as!(
        LoginRow,
        "SELECT id, password_hash FROM users WHERE email = $1",
        input.email
    )
    .fetch_optional(&pool)
    .await?;
    let Some(row) = row else {
        return Err(AppError::Unauthorized);
    };
    let Some(stored_hash) = row.password_hash else {
        return Err(AppError::Unauthorized);
    };
    if !password_matches(&input.password, &stored_hash) {
        return Err(AppError::Unauthorized);
    }
    let secret = std::env::var("JWT_SECRET").map_err(|_| AppError::InternalError)?;
    let token = create_token(row.id, "user", &secret)?;
    Ok(Json(LoginResponse { token }))
}

pub async fn profile(user: AuthUser) -> HandlerResult<Json<serde_json::Value>> {
    Ok(Json(json!({ "user_id": user.user_id, "role": user.role })))
}

pub async fn home() -> &'static str {
    "Welcome! This page is open to everyone."
}
src/lib.rs
pub mod auth;
pub mod db;
pub mod errors;
pub mod handlers;

use axum::{Router, routing::{get, post}};
use handlers::{home, login, profile};
use sqlx::PgPool;

pub fn app(pool: PgPool) -> Router {
    Router::new()
        .route("/", get(home))
        .route("/login", post(login))
        .route("/profile", get(profile))
        .with_state(pool)
}
src/main.rs
use axum_project::{app, db::create_pool};

#[tokio::main]
async fn main() {
    let database_url = std::env::var("DATABASE_URL").expect("DATABASE_URL must be set");
    let pool = create_pool(&database_url)
        .await
        .expect("failed to connect to the database");
    let router = app(pool);
    let listener = tokio::net::TcpListener::bind("127.0.0.1:3000")
        .await
        .unwrap();
    println!("Server running at http://127.0.0.1:3000");
    axum::serve(listener, router).await.unwrap();
}

Run the checks with these commands:

cargo check
cargo test --test jwt_test
cargo run

Summary

A protected route is a handler whose argument list does the protecting. The argument runs before the body, the body runs only for a verified user, and the route needs no check of its own, because the check is the argument. The public routes beside it stay open by leaving the argument out, and the login route stays open because it is the route that hands out the first token. The same router serves all three, and the signature of each handler says which kind it is.

The decision to carry forward is about where trust is established. A check inside a handler body can be forgotten, reordered, or skipped, and a check in an extractor runs before the body by construction. Whenever a route needs to know who is asking, the answer belongs in the argument list, where the compiler and the framework enforce it, and the handler body starts with a user it can trust. The token flow is now complete: login mints it, the header carries it, the extractor verifies it, and the route runs on it. What remains is the question of who may do what once they are known, and that question is answered by the role the token carries, not by the identity alone.