This document covers the authentication and authorization system used by the bot, implemented via the auth controller and context.
Commands permissions are used by controllers to filter incoming commands. They use the form scope:name:noun:verb
,
with the controller's scope
and name
.
Message permissions are used by listeners and parsers to filter incoming messages and by listeners to filter outgoing
messages. They use the form scope:name:type
, with the listener or parser's kind
and name
and message's type
.
Permissions use the Shiro syntax, originally from Apache Shiro, as
implemented by shiro-trie. Sections are delimited by colons, lists are
delimited by commas, and *
is a wildcard.
For example:
office,factory:door:outside,office
allows all of:office:door:outside
office:door:office
factory:door:outside
factory:door:office
Each section can specify one or more values, or the *
(anything) wildcard.
To query permissions, replace one section with the ?
operator. The result of the query will be all allowed values for
that section.
For example:
- with the grants
office:door:*
andfactory:equipment:drill
- the query
office:door:?
will return*
- the query
office:?
will returndoor
- the query
factory:equipment
will returndrill
To create a new user and role with the reference config, please run:
!!args --noun role --verb create --name test_role --grants foo
!!join --name test_user --roles test_role
!!login --name test_user
!!args --noun token --verb list
!!args --noun token --verb create --grants test
To log in with the reference config, please run:
!!login --name test_user
Session is managed by the listeners and attached a uid
(unique user ID, meaningful to the listener) to a User
entity suitable for creating Context
. Not all listeners maintain sessions; HTTP uses Authentication
header tokens,
which extend session, and does not need to track them outside of the request scope. Listeners that work with logged in
users, like most chat applications, should support keeping the user logged in. This is a convenience and may be
disabled for security reasons.
Services that issue tokens need to be configured with a few secrets:
- the
audience
to which they are issuing tokens - a stable
issuer
used to identify this service (or bot) - the
secret
used to sign the tokens
The secret
can be a simple string or RSA key.