#!/usr/bin/env bash # What a token is allowed to do, and why Keycloak's roles are invisible by default. # Pass the profile set the resource server is running with, for the transcript header. set -eu . "$(dirname "$0")/lib.sh" PROFILES="${1:-unknown}" head1 "resource server profiles: $PROFILES" head1 "1. alice - realm role USER, client role reports-reader" T=$(stub_token "sub=alice&roles=USER") claims "$T" call "GET /api/me (which authorities did the converter produce?)" "$RS/api/me" "$T" call "GET /api/reports (needs ROLE_reports-reader, from resource_access)" "$RS/api/reports" "$T" call "GET /api/admin/stats (needs ROLE_ADMIN, from realm_access)" "$RS/api/admin/stats" "$T" head1 "2. root - realm roles USER and ADMIN" T=$(stub_token "sub=root&roles=USER%20ADMIN") call "GET /api/me" "$RS/api/me" "$T" call "GET /api/admin/stats" "$RS/api/admin/stats" "$T"