exp:expgraphqlpublickey
Make the public read key of a front end in one command: a role, a user group and a user that only read, then the key (shown once); list or revoke the public keys; a dry run unless --apply.
Script bin/php/expgraphqlpublickey.php, code in kernel/private/classes/commands/expgraphqlpublickey.php. Run it from the installation root, as the user the web server runs as:
./console exp:expgraphqlpublickey --help
./console exp:graphql:public-key --help
php bin/php/expgraphqlpublickey.php --helpHelp text
The public read key of a front end
A public read key (only graphql:read, only the siteaccesses of --siteaccess) needs an owner that
only reads. This command makes that owner once: the role "GraphQL public reader" (content/read as
the anonymous user of the siteaccesses reads, and apikey/create with the Scope graphql:read; no
user/login, so the owner cannot sign in), the hidden user group "GraphQL public readers" below the
user root node with the role, and the user graphql-public in it (a random password nobody is shown).
Then it makes the key and shows the token once. Run again, it reuses the role, the group and the
user, and makes no second key for the same siteaccesses unless --new. Making and revoking keys are
recorded in the audit (access.apikey.create, .revoke), the role in access.role.create.
Nothing is written without --apply.
./console exp:graphql:public-key --siteaccess=site what would be made
./console exp:graphql:public-key --siteaccess=site,site_de --name='Shop front end' --apply
./console exp:graphql:public-key --siteaccess=site --new --days=30 --apply
./console exp:graphql:public-key --list
./console exp:graphql:public-key --revoke=expk_4f2a9c1d7e3b --apply
Exit code: 0 done (or shown, or the key exists already); 1 the owner or the key could not be made,
or the key not revoked; 2 wrong options (no or an unknown siteaccess, an anonymous user that reads
nothing, a lifetime that is not offered, an unknown key, a user graphql-public of someone else).Options
| Option | Value | Help |
|---|---|---|
--siteaccess | required | the siteaccesses the key works in, comma separated (required to make a key) |
--name | required | the name of the key (default: GraphQL public key) |
--days | required | the lifetime of the key in days (rest.ini [ApiKeySettings] ExpiryChoices[]; default DefaultExpiryDays, as on the key page) |
--new | make another key although an active public key for these siteaccesses exists | |
--list | list the public read keys: prefix, status, siteaccesses, expiry, owner | |
--revoke | required | revoke the public read key of this prefix (expk_...) |
--apply | write; without it nothing is changed |
Read from the option definitions in the code (startup(), getOptions(), options() or ezcConsoleOption). Every script also takes the standard options of the script framework (--help, --siteaccess, --debug, --quiet, --allow-root-user ...).
Related
Generated by ./console exp:help:examples from bin/php/expgraphqlpublickey.php, kernel/private/classes/commands/expgraphqlpublickey.php. Do not edit this page: change the source and generate again (how). Free documentation: GFDL 1.3 or later.