Authenticate Users via OpenID Connect¶
Note
OpenID Connect Authentication is a Flower Enterprise feature. See Flower Enterprise for details.
In this guide, you’ll learn how to configure SuperLink with user-level authentication
and authorization, and how to log in using the flwr
CLI. Once logged in, any users
that are authorized on the SuperLink can run Flower CLI commands that interact with the
SuperLink.
Important
With user authentication and authorization enabled, only users that have submitted
the flwr run
command can view and interact with their runs. This means that your
runs are private by default, ensuring that only authorized users can access
them.
Prérequis¶
To enable user authentication and authorization, the SuperLink must be deployed with an
OpenID Connect (OIDC) provider and
an OpenFGA server. The OIDC provider is used for user
authentication, while OpenFGA is used for fine-grained access control. This means an
authenticated user can only run flwr
CLI commands on the SuperLink if they have been
granted the necessary permissions by the SuperLink administrator. When enabled, both
user authentication and authorization must be configured on the SuperLink.
Login to the SuperLink¶
Once a SuperLink with user authentication and authorization is up and running, a user
can interface with it after installing the flwr
PyPI package via the Flower CLI.
Then, ensure that the enable-user-auth
field is set to true
in the federation
section in the pyproject.toml
of the Flower app you want to run:
[tool.flwr.federations]
default = "my-federation"
[tool.flwr.federations.my-federation]
address = "<SUPERLINK-ADDRESS>:9093" # Address of the SuperLink Exec API
root-certificates = "<PATH/TO/ca.crt>" # TLS certificate set for the SuperLink. Required for self-signed certificates.
enable-user-auth = true # Enables the user auth mechanism on the `flwr` CLI side
Note
User authentication and authorization is only supported with TLS connections.
Now, you need to login first before other CLI commands can be executed. Upon executing
flwr login
, a URL will be returned by the authentication plugin in the SuperLink.
Click on it and authenticate directly against the OIDC provider.
flwr login [APP] [FEDERATION]
Loading project configuration...
Success
Creating a new `.gitignore` with `.credentials` entry...
Please login with your user credentials here: https://account.flower.ai/realms/flower/device?user_code=...
# [... user follows URL and logs in ... in the meantime the CLI will wait ...]
âś… Login successful.
Once the login is successful, the credentials returned by the OIDC provider via the
SuperLink will be saved to the app’s directory under
.flwr/.credentials/<federation-name>.json
. The tokens stored in this file will be
sent transparently with each subsequent flwr
CLI request to the SuperLink, and it
will relay them to OIDC provider to perform the authentication checks.