Athena::MercureBundle::Schema#
Represents the possible properties used to configure and customize the Mercure integration. See the Getting Started docs for more information on how the bundle system works in Athena.
A full example showing all properties is as follows:
ADI.configure({
mercure: {
hubs: {
default: {
url: "https://internal-hub/.well-known/mercure",
public_url: "https://hub.example.com/.well-known/mercure",
jwt: {
# Provide *secret* to generate JWTs dynamically via a token factory...
secret: "my-jwt-secret",
publish: ["*"],
subscribe: ["https://example.com/books/{id}"],
algorithm: :hs256,
passphrase: "",
# ...or provide *value* to use a static JWT token directly.
# value: "eyJhbGciOiJIUzI1NiJ9...",
},
},
},
default_hub: "default",
default_cookie_lifetime: 1.hour,
},
})
Configuration Properties
hubs#
Hash(K, V)
{__nil: nil}
Named Mercure hub definitions. Each hub requires a url and jwt configuration.
This property consists of a map of key/value pairs where each value has the following properties:
url#type:
StringRequiredThe internal URL used by the server to publish updates to this hub. Should be set via ENV var.
public_url#type:
String | ::Nildefault:
nilThe public URL exposed to clients via the
Linkheader for hub discovery. Falls back to url if not set. Useful when the internal hub URL differs from the one clients should connect to. Should be set via ENV var.
jwt#type:
JWTRequiredJWT configuration for authenticating with a Mercure hub. Provide either secret to generate tokens dynamically, or value to use a static token.
This property consists of an object with the following properties:
secret#type:
String | ::Nildefault:
nilThe secret key used to sign JWTs. Required when generating tokens dynamically via a
AMC::TokenFactory::JWT(i.e. when value is not set). Should be set via ENV var.
publish#type:
Array(String)default:
[] of StringTopic selectors that the generated JWT grants publish access to. Included in the JWT's
mercure.publishclaim.
subscribe#type:
Array(String)default:
[] of StringTopic selectors that the generated JWT grants subscribe access to. Included in the JWT's
mercure.subscribeclaim.
algorithm#type:
::JWT::Algorithmdefault:
hs256The signing algorithm used to encode the JWT.
passphrase#type:
StringRequiredPassphrase for the secret key, if the algorithm requires one (e.g. RSA).
value#type:
String | ::Nildefault:
nilA pre-built static JWT token string provided via
AMC::TokenProvider::Static. When set, the token is used as-is and secret, algorithm, and passphrase are ignored.
default_hub#
String | ::Nil
nil
The name of the hub to use when none is specified. Defaults to the first defined hub if not explicitly set.
default_cookie_lifetime#
Time::Span
1.hour
Default lifetime for authorization cookies set via ABM::Authorization.