Assurance
Assurance-based shell tiers#
Not every federated identity is equally trustworthy. A user who logged in with a second factor at a well-run Home-IdP is a different proposition from one who self-registered with an email address. Assurance-based shell tiers let you accept both, but give them different login shells.
motley-cue evaluates each user’s assurance and MFA claims against a set of
boolean expressions, arriving at one of three tiers – full, limited or
restricted. The tier is handed to feudalAdapter, which maps it to a shell in
feudal_adapter.conf.
Assurance does not reject anyone
Every user who passes authorisation is deployed. The tier only decides which shell they get. This is deliberate: a user with weak assurance receives an account and an explanatory message rather than an opaque login failure.
This moved out of feudal_adapter.conf
Earlier versions configured a single global [assurance] require
expression in feudal_adapter.conf, which rejected users who did not
match. That mechanism is gone. Assurance is now configured per OP in
motley_cue.conf, because only motley-cue has the per-OP context and sees
the full token. If you have a require = line in your
feudal_adapter.conf, port it to assurance_based_shell_tier_full as
shown below.
Configuration#
The options live in the [authorisation.*] sections of
/etc/motley_cue/motley_cue.conf, with [DEFAULT] supplying the values an OP
does not override. So you can set a policy once globally and adjust it for
individual providers – which is the whole point, since OPs differ widely in
what assurance they can actually assert.
-
assurance_prefix- prefix prepended to relative claim values
default:assurance_prefix = https://refeds.org/assurance/ -
assurance_claims- token claims whose values are collected into the assurance set
default:assurance_claims = [assurance, eduperson_assurance, acr] -
assurance_based_shell_tier_full- expression for thefulltier
default: empty (never matches) -
assurance_based_shell_tier_limited- expression for thelimitedtier
default: empty (never matches) -
assurance_based_shell_tier_restricted- expression for therestrictedtier
default: empty (never matches) -
assurance_based_shell_default_tier- tier used when no expression matches. Left unset it is decided per OP:fullfor an OP with no tier expressions at all, the least privileged tier (restricted) for an OP that does have a policy. Set it explicitly to override in either direction.
default: empty, i.e. decided automatically -
assurance_based_shell_max_tier- caps the resulting tier; it can only ever lower a tier, never raise one. Most useful per OP.
default: empty, i.e. no cap
The feature is opt-in, and enabling it is per OP
With the defaults above, all three tier expressions are empty, so nothing
matches and every user resolves to full. feudalAdapter then uses its
normal shell. In other words: if you configure nothing, behaviour is
exactly as it was before shell tiers existed. You enable the feature by
writing expressions.
Enabling follows ordinary [DEFAULT] inheritance. A policy in [DEFAULT]
applies to every OP, including one that has no section of its own. A
policy in a single [authorisation.<op>] section applies to that OP
only and leaves the others exactly as they were.
Once an OP has a policy, unmatched users fail closed
For an OP that does have a policy, a user matching none of its
expressions gets the least privileged tier, not full. This matters
because the most likely mistake – an expression that can never match, such
as the MFA prefix trap below – would otherwise
silently grant everyone a full shell. Set
assurance_based_shell_default_tier explicitly if you want something else.
The expression grammar#
E -> E "&" E | E "|" E | "(" E ")" | string
& (AND) binds more strongly than | (OR); use parentheses to override.
This is the same grammar as the old feudal assurance.require, so existing
expressions carry over unchanged.
A bare string matches if the user’s assurance set contains it verbatim,
or contains it prefixed with assurance_prefix. That dual match is what
makes both worlds reachable from one option:
profile/cappuccinomatches the REFEDS URLhttps://refeds.org/assurance/profile/cappuccino1matches anacrclaim whose literal value is1mfamatches anamrvalue ofmfa
A string starting with http:// or https:// is matched verbatim only and
never prefixed – so https://refeds.org/profile/mfa works even though it does
not live under the assurance prefix.
REFEDS MFA is not under the assurance prefix
The REFEDS MFA profile is https://refeds.org/profile/mfa, while the
REFEDS Assurance Framework lives under
https://refeds.org/assurance/. They are different namespaces.
Writing the relative token profile/mfa therefore expands to
https://refeds.org/assurance/profile/mfa, which no provider ever
asserts – the expression silently never matches, and the user falls
through to assurance_based_shell_default_tier (which defaults to
full). Always write MFA as the absolute URL:
# correct
assurance_based_shell_tier_full = https://refeds.org/profile/mfa & profile/cappuccino
# WRONG -- can never match, everyone falls through to the default tier
assurance_based_shell_tier_full = profile/mfa & profile/cappuccino
Alternatively widen assurance_prefix to https://refeds.org/ and write
profile/mfa and assurance/profile/cappuccino.
See Multi-Factor Authentication for how often users actually have to produce a second factor, and for the caveat that an OP may not carry the MFA signal into tokens derived from a refresh token.
Two special tokens:
+matches if the user has any assurance claim at all*always matches
An empty expression never matches.
Which claims are inspected#
Each claim named in assurance_claims is looked up in all three token
sources and the results are combined:
- the userinfo endpoint
- the access token body, when it is a JWT
- token introspection
The union of everything found is what the expressions are evaluated
against. This matters: a provider may put the assurance profile in
eduperson_assurance at the userinfo endpoint while the MFA signal rides in
acr inside the access token. An expression requiring both is only satisfiable
if the two sources are merged, which is why motley-cue does not simply take the
first source that carries a claim.
A claim’s value may be a list, a single string, or a space-separated list of
values (as acr often is) – all are handled.
How the tier is chosen#
- The assurance set is collected as described above.
- The tier expressions are tested in order of decreasing privilege:
full, thenlimited, thenrestricted. The first match wins. - If none matches,
assurance_based_shell_default_tieris used – which, left unset, is the least privileged tier for an OP that has a policy, andfullfor one that does not. - Finally
assurance_based_shell_max_tieris applied, if set. It can only lower the result.
Expressions are parsed once at startup, so a syntax error surfaces immediately
as a configuration error naming the OP and the offending option, rather than
failing later on a user’s login. The same applies to
assurance_based_shell_default_tier and assurance_based_shell_max_tier: an
unrecognised tier name is rejected at startup rather than ignored, because
ignoring it would hand the user more privilege than intended.
Still configure a catch-all
Setting assurance_based_shell_tier_restricted = * is recommended even
though unmatched users now fail closed by themselves: it makes the intent
explicit in the config rather than relying on the fallback.
Mapping tiers to shells#
The tier names mean nothing by themselves; feudal_adapter.conf turns them
into actual shells:
[backend.local_unix]
# the "full" tier / default shell
shell = /bin/bash
# the lower tiers
shell_limited = /etc/motley_cue/shells/mc-rbash
shell_restricted = /etc/motley_cue/shells/mc-message
Two shells ship with motley-cue for this purpose:
mc-rbash– a restricted bash permitting only a safe whitelist of commands (ls,id,whoami, …)mc-message– prints an explanatory message and exits
shell_limited and shell_restricted both default to /sbin/nologin, i.e.
they fail closed until you configure them.
LDAP backends
With the ldap backends the login shell is written into the directory, so
the tier shells must exist, be executable, and usually be listed in
/etc/shells on every target system the user logs in to – not just on
the host running motley-cue. Note also that /etc is mounted noexec on
some hosts; install the shells elsewhere in that case, for example under
/usr/lib/motley-cue/shells/, and adjust the paths.
Examples#
A three-tier policy#
Full shell only with MFA and a REFEDS cappuccino profile; a restricted shell for cappuccino without MFA; a message-and-exit shell for everyone else.
[DEFAULT]
assurance_based_shell_tier_full = https://refeds.org/profile/mfa & profile/cappuccino
assurance_based_shell_tier_limited = profile/cappuccino
assurance_based_shell_tier_restricted = *
Capping a weak provider#
Google asserts no REFEDS assurance at all, so its users would be classified by
whatever [DEFAULT] says. Cap the OP so none of them can ever reach the full
shell, without touching the global policy:
[authorisation.google]
op_url = https://accounts.google.com/
scopes = ["openid", "profile"]
assurance_based_shell_max_tier = restricted
An OP that signals MFA in acr#
Some providers express the authentication context as a bare acr value rather
than a REFEDS URL. Match it directly:
[authorisation.example]
op_url = https://op.example.org/
assurance_claims = [acr, amr, eduperson_assurance]
assurance_based_shell_tier_full = 2 | mfa
assurance_based_shell_tier_restricted = *
Migrating from the old assurance.require#
The old feudal_adapter.conf stanza:
[assurance]
prefix = https://refeds.org/assurance/
require = profile/espresso | profile/cappuccino
becomes, in motley_cue.conf:
[DEFAULT]
assurance_prefix = https://refeds.org/assurance/
assurance_based_shell_tier_full = profile/espresso | profile/cappuccino
assurance_based_shell_tier_restricted = *
The expression is unchanged. The difference is the outcome: users who do not
match are no longer rejected, they get the restricted shell. To keep them out
entirely, point shell_restricted at /sbin/nologin.
Unknown providers#
A token from an OP that has no [authorisation.*] section of its own is not
authorised anyway, but should it ever be evaluated, the [DEFAULT] policy
applies. A configured assurance_based_shell_tier_restricted = * catch-all
therefore also covers unknown providers, rather than granting them full.
Troubleshooting#
Set log_level = DEBUG in the [mapper] section of motley_cue.conf. The
evaluation then logs, for every request, each configured claim and the values
found for it per source, followed by the tier that was selected and any cap
that was applied. That tells you directly whether a claim you expected is
missing, or is simply arriving under a name or in a source you have not
configured.
If a user’s claims look right but the shell does not change, check that the OP
is actually being asked for the relevant scopes (scopes in the same
[authorisation.*] section – eduperson_assurance in particular), and that
feudalAdapter is recent enough (see below).
Version requirements
Assurance-based shell tiers need feudalAdapter >= 2.0.0 on the
receiving side; the ldap backends gained tier support in 2.0.1. An
older feudalAdapter silently ignores the tier and gives every user the
default shell.