Authentication and Authorisation
There are many ways to secure webservices. The most flexible one is to use an external reverse proxy.
Since this can be tricky to set up, FROST offers some simple auth* options.
Auth* has to happen in two places: in the HTTP package and in the MQTT package. To make things
flexible, authentication is handled by classes that implement an interface, just like the
persistence backends. The interface to be implemented is de.fraunhofer.iosb.ilt.sta.util.AuthProvider.
An example docker-compose file with basic auth set up can be found at:
More fine-grained authorisation rules can be configured using:
- plugins with
- PostgreSQL Row-level security (see
FROST-Server asks the AuthProvider if the user has the following roles:
Can the user read, both on HTTP and MQTT.
Can the user create new entities, both on HTTP and MQTT.
Can the user update entities. This is only possible over HTTP.
Can the user delete entities. This is only possible over HTTP.
Can the user call the DatabaseStatus script. This is only possible over HTTP.
Currently there are two auth packages included:
These are generic settings for authentication/authorisation.
The java class used to configure authentication/authorisation. Currently implemented are:
An authentication provider that user basic authentication for HTTP, and stores user information in a database.
An authentication provider that uses a keycloak server for authentication.
If true, anonymous users are allowed to read (GET) data.
Automatically apply database updates.
The role in the external authentication system that represents read (GET) access.
The role in the external authentication system that represents create (POST) access.
The role in the external authentication system that represents update (PUT/PATCH) access.
The role in the external authentication system that represents delete (DELETE) access.
The role in the external authentication system that represents admin (DatabaseStatus) access.
Settings for the auth provider class
The BasicAuthProvider needs a database to store its usernames, passwords and user roles.
This database can be the same as the database used by the persistence manager, but it can also be
a different database. The database has the same structure as described in the
DataSourceRealm documentation of Tomcat
except with the table and column names in upper case, like the rest of the database.
If you let this provider create its database tables (with auth.autoUpdateDatabase) it will
create three default users:
read, has only role
write, has roles
admin, has roles
You should change these default users!
The BasicAuthProvider has the following specific settings:
The name of the realm that the browser displays when asking for username and password.
If true (the default), passwords are stored in plain text.
Otherwise password can use any result of the PostgreSQL crypt function,
for example with Blowfish variant 2a (recommended):
INSERT INTO "USERS" VALUES ('my_user', crypt('my_password', gen_salt('bf', 12))).
JNDI data source name, used when running in Tomcat/Wildfly. When using JNDI only set this option. When not using JNDI all other options can be used.
The Database driver to use. For PostgreSQL this should be:
The database connection url. Example:
The username to use when connecting to the database.
The password to use when connecting to the database.
The maximum number of database connections to use.
The maximum number of idle database connections to keep open.
The minimum number of idle database connections to keep open.
Settings for the auth provider class
Keycloak requires a JSON config file. The contents of this file are provided by the Keycloak server.
There are three ways to pass this configuration to FROST:
- setting the content directly in the option
- saving the config in a file and passing the file path in the option
- or having FROST download it from the server, by setting the option
keycloakConfigUrl and optionally
When setting roles for a user, the roles need to be set explicitly for the FROST client.
Realm roles do not automatically apply to FROST.
The json content of the keycloak json config file.
The path to the keycloak json config file.
The URL on the Keycloak server that can be used to download the Keycloak config file. Usually this url is in the form
If the client has “access-type” set to “confidential” then a secret is required to download the configuration.
This secret can be found in the configuration itself, in Keycloak.