1
0
Fork 0
Commit Graph

22 Commits (fb9ac66ad392117c39f78ad3ef4cce9747661a08)

Author SHA1 Message Date
Dustin 897923a172 authelia: Bypass Authelia for Paperless-ngx API
The [Paperless Mobile][0] app for Android uses the Paperless-ngx API.

[0]: https://github.com/astubenbord/paperless-mobile/
2024-01-19 13:42:03 -06:00
Dustin ce3bc87f9e authelia: Reduce concent durations
After considering the implications of Authelia's pre-configured consent
feature, I decided I did not like the fact that a malicious program
could potentially take over my entire Kubernetes cluster without my
knowledge, since `kubectl` may not require any interaction, and could
therefore be executed without my knowledge.  I stopped ticking the
"Remember Consent" checkbox out of paranoia, but that's gotten kind of
annoying.  I figure a good compromise is to only prompt for consent a
couple of times per day.
2024-01-04 09:08:07 -06:00
Dustin 8d796a7c01 authelia: Fix argocd-cli OIDC client
The `argocd` CLI needs the audience claim in OIDC identity tokens to be
`argocd-cli` or it will refuse to use the token.
2023-12-27 15:30:31 -06:00
Dustin 12773c7fd2 authelia: Restrict access to paperless-ngx
Since all Paperless-ngx users see the same content, we should restrict
who can log in.
2023-12-27 15:29:46 -06:00
Dustin 39d19cb3ea authelia: Restrict access to firefly
Since we've configured the Ingress for Firefly III to log everyone in as
*dustin* via a faked `Remote-User` request header, any user on the
Pyrocufflink domain would be able to see my finances.  Using Authelia's
access control mechanism, we can restrict this to only users in a
specific group.
2023-12-27 15:27:44 -06:00
Dustin b07e141fa3 authelia: Convert to a stateless service
By default, Authelia uses a local SQLite database for persistent data
(e.g. authenticator keys, TOTP secrets, etc.) and keeps session data in
memory.  Together, these have some undesirable side effects.  First,
since needing access to the filesystem to store the SQLite database
means that the pod has to be managed by a StatefulSet.  Restarting
StatefulSet pods means stopping them all and then starting them back up,
which causes downtime.  Additionally, the SQLite database file needs to
be backed up, which I never got around to setting up.  Further, any time
the service is restarted, all sessions are invalidated, so users have to
sign back in.

All of these issues can be resolved by configuring Authelia to store all
of its state externally.  The persistent data can be stored in a
PostgreSQL database and the session state can be stored in Redis.  Using
a database managed by the existing Postgres Operator infrastructure
automaticaly enables high availability and backups as well.

To migrate the contents of the database, I used [pgloader].  With
Authelia shut down, I ran the migration job.  Authelia's database schema
is pretty simple, so there were no problems with the conversion.
Authelia started back up with the new database configuration without any
issues.

Session state are still stored only in memory of the Redis process.
This is probably fine, since Redis will not need restarted often, except
for updates.  At least restarting Authelia to adjust its configuration
will not log everyone out.

[pgloader]: https://pgloader.readthedocs.io/en/latest/ref/sqlite.html
2023-10-19 07:12:02 -05:00
Dustin 629d1bb93a argocd: Configure SSO for CLI
The `argocd` command needs to have its own OIDC client configuration,
since it works like a "public" client.  To log in, run

```sh
argocd login argocd.pyrocufflink.blue --sso
```
2023-10-14 11:13:06 -05:00
Dustin 721edd0d59 authelia: Use ConfigMap name suffix hash
Without `disableNameSuffixHash` enabled, Kustomize will create a unique
ConfigMap any time the contents of source file change.  It will also
update any Deployment, StatefulSet, etc resources to point to the new
ConfigMap.  This has the effect of restarting any pods that refer to the
ConfigMap whenever its contents change.

I had avoided using this initially because Kustomize does *not* delete
previous ConfigMap resources whenever it creates a new one.  Now that we
have Argo CD, though, this is not an issue, as it will clean up the old
resources whenever it synchronizes.
2023-10-14 10:47:23 -05:00
Dustin 7bdf1f86b9 authelia: Set instance label for Argo CD
Argo CD wants every resource managed by an application to have that
application's name as the value of the `app.kubernetes.io/instance`
label.
2023-10-14 10:47:07 -05:00
Dustin 63ff1bf637 authelia: Migrate to Sealed Secrets 2023-10-14 10:35:54 -05:00
Dustin fdbf1d3432 argocd: Deploy Argo CD
[Argo CD] is a Kubernetes-native GitOps/continuous deployment manager.
It monitors the state of Kubnernetes resources, such as Pods,
Deployments, ConfigMaps, Secrets, and Custom Resources, and synchronizes
them with their canonical definitions from a Git repository.

*Argo CD* consists of various components, including a Repository
Service, an Application Controller, a Notification Controller, and an
API server/Web UI.  It also has some optional components, such as a
bundled Dex server for authentication/authorization, and an
ApplicationSet controller, which we will not be using.

[Argo CD]: https://argo-cd.readthedocs.io/
2023-10-14 10:17:04 -05:00
Dustin 92a5aee7b4 authelia: Add OIDC client for step-ca
*step-ca* uses OpenID Connect to authenticate requests for SSH and X.509
certificates.
2023-10-10 22:31:44 -05:00
Dustin 5d5b69a629 firefly-iii: Deploy Firefly III
[Firefly III][0] is a free and open source, web-based personal finance
management application.  It features a double-entry bookkeeping system
for tracking transactions, plus other classification options like
budgets, categories, and tags.  It has a rule engine that can
automatically manipulate transactions, plus several other really useful
features.

The application itself is mostly standard browser-based GUI written in
PHP.  There is an official container image, though it is not
particularly well designed and must be run as root (it does drop
privileges before launching the actual application, thankfully).  I may
decide to create a better image later.

Along with the main application, there is a separate tool for importing
transactions from a CSV file.  Its design is rather interesting: though
it is a web-based application, it does not have any authentication or
user management, but uses a user API key to access the main Firefly III
application.  This effectively requires us to have one instance of the
importer per user.  While not ideal, it isn't particularly problematic
since there are only two of us (and Tabitha may not even end up using
it; she seems to like YNAB).

[0]: https://www.firefly-iii.org/
2023-05-14 11:15:15 -05:00
Dustin d8aadb01af authelia: add OIDC client for MinIO
This configuration is for the instance of MinIO running on the BURP
server, which will be used to store PostgreSQL backups created by the
Postgres Operator.
2023-05-12 11:45:20 -05:00
Dustin 572ea54dd3 authelia: Set OIDC consent duration
By default, Authelia requires the user to explicitly consent to allow
an application access to personal information *every time the user
authenticates*.  This is rather annoying, so luckily, it provides a
way to remember the consent for a period of time.
2023-04-23 15:56:50 -05:00
Dustin b5574fa5fc authelia: Skip scanserv-js auth for internal
For convenience, clients on the internal network do not need to
authenticate in order to access *scanserv-js*.  There isn't anything
particularly sensitive about this application, anyway.
2023-04-23 15:55:42 -05:00
Dustin 24465dc7da authelia: Set up OIDC for k8s API server
Enabling OpenID Connect authentication for the Kubernetes API server
will allow clients, particularly `kubectl` to log in without needing
TLS certificates and private keys.
2023-04-22 21:37:23 -05:00
Dustin bcb54d4010 authelia: Add README 2023-04-22 21:35:28 -05:00
Dustin b2e1e29087 authelia: Enable two-factor auth for Paperless-ngx 2023-04-22 08:00:19 -05:00
Dustin 8a966a7ffb authelia: Enable OIDC provider
Authelia can act as an Open ID Connect identity provider.  This allows
it to provide authentication/authorization for other applications
besides those inside the Kubernetes cluster using it for Ingress
authentication.

To start with, we'll configure an OIDC client for Jenkins.
2023-01-25 10:36:22 -06:00
Dustin e38245dc63 authelia: Add startup probe
I am not entirely sure why, but it seems like the Kubelet *always*
misses the first check in the readiness probe.  This causes a full
60-second delay before the Authelia pod is marked as "ready," even
though it was actually ready within a second of the container starting.

To avoid this very long delay, during which Authelia is unreachable,
even though it is working fine, we can add a startup probe with a much
shorter check interval.  The kubelet will not start readiness probes
until the startup probe returns successfully, so it won't miss the first
one any more.
2023-01-25 10:32:30 -06:00
Dustin 42bc4ae187 authelia: Install Authelia
Authelia is a general authentication provider that works (primarily)
by integrating with *nginx* using its subrequest mechanism.  It works
great with Kubernetes/*ingress-nginx* to provide authentication for
services running in the cluster, especially those that do not provide
their own authentication system.

Authelia needs a database to store session data.  It supports various
engines, but since we're only running a very small instance with no real
need for HA, SQLite on a Longhorn persistent volume is sufficient.

Configuration is done mostly through a YAML document, although some
secret values are stored in separate files, which are pointed to by
environment variables.
2023-01-13 21:33:14 -06:00