diff --git a/apps/docs/src/content/docs/terraform/_meta.json b/apps/docs/src/content/docs/terraform/_meta.json new file mode 100644 index 0000000..69cc3e8 --- /dev/null +++ b/apps/docs/src/content/docs/terraform/_meta.json @@ -0,0 +1,5 @@ +{ + "icon": "layers", + "title": "Terraform", + "order": 6 +} diff --git a/apps/docs/src/content/docs/terraform/default/en/authentication.mdx b/apps/docs/src/content/docs/terraform/default/en/authentication.mdx new file mode 100644 index 0000000..ead6921 --- /dev/null +++ b/apps/docs/src/content/docs/terraform/default/en/authentication.mdx @@ -0,0 +1,110 @@ +--- +title: Authentication +description: "How the FerrisKey Terraform provider signs in: password and client credentials grants, environment variables, TLS, token refresh and retries." +icon: key-round +order: 3 +--- + +# Authentication + +The provider gets an access token from the token endpoint of one realm, `{url}/realms/{realm}/protocol/openid-connect/token`, and sends it as a bearer token on every API call. What the token allows is what the roles of the signed-in user, or of the client's service account, allow. See [roles and permissions](/en/discover/core-concepts/roles). + +## Choosing the grant + +The provider picks the grant from the credentials it finds: + +| Credentials set | Grant | Use it for | +|---|---|---| +| `client_id`, `client_secret` | `client_credentials` | Every day: CI, pipelines, a workstation | +| `client_id`, `username`, `password` | `password` | Once, to [bootstrap](/en/terraform/getting-started) the service account | + +Setting both `password` and `client_secret` is an error, and so is setting neither. The password grant sends no secret, so its `client_id` has to be a public client with **Direct access grants** on. The client credentials grant needs a confidential client with `service_account_enabled`. + +The password grant is [deprecated](/en/discover/core-concepts/authentication#password-resource-owner), and it fails for an admin who owes a required action or signs in with a passkey or a federated identity provider. Keep it for the bootstrap. + +## Provider arguments + +| Argument | Environment variable | Description | +|---|---|---| +| `url` | `FERRISKEY_URL` | Base URL of the API, with no `/realms` suffix. Required | +| `realm` | `FERRISKEY_REALM` | Realm the provider signs in to, often `master`. Required | +| `client_id` | `FERRISKEY_CLIENT_ID` | Client the token is requested for. Required | +| `client_secret` | `FERRISKEY_CLIENT_SECRET` | Selects the client credentials grant. Sensitive | +| `username` | `FERRISKEY_USERNAME` | User for the password grant | +| `password` | `FERRISKEY_PASSWORD` | Selects the password grant. Sensitive | +| `scope` | `FERRISKEY_SCOPE` | Scope sent with the token request. Optional | +| `ca_cert` | `FERRISKEY_CA_CERT` | PEM certificate or bundle to trust, for an instance behind a private CA | +| `tls_insecure_skip_verify` | `FERRISKEY_TLS_INSECURE` | Skip certificate verification. Development only | + +An argument set in the configuration wins over its environment variable. + +`url` is where the API answers, not where the console is. With the Helm chart, the API is served under `api.server.rootPath`, `/api` by default, so `url` is `https://auth.example.com/api`. A local server started on port 3333 with no root path is `http://localhost:3333`. + +`realm` is only where the provider signs in. Resources name their own realm, so one provider signed in to `master` can manage every realm of the instance. + +## Environment variables + +Keep credentials out of `.tf` files. A CI job sets the variables and the provider block only names what is not secret: + +```hcl +provider "ferriskey" { + url = "https://auth.example.com/api" + realm = "master" + client_id = "terraform-runner" +} +``` + +```bash +export FERRISKEY_CLIENT_SECRET='' +terraform plan +``` + +All of the provider block can come from the environment, in which case `provider "ferriskey" {}` is enough. + +## Several instances + +Use an alias per instance, and pass the alias to the resources that belong to it: + +```hcl +provider "ferriskey" { + alias = "staging" + url = "https://auth.staging.example.com/api" + realm = "master" + client_id = "terraform-runner" + client_secret = var.staging_runner_secret +} + +resource "ferriskey_realm" "acme_staging" { + provider = ferriskey.staging + name = "acme" +} +``` + +## TLS + +For an instance whose certificate comes from a private CA, pass the CA: + +```hcl +provider "ferriskey" { + url = "https://auth.internal.example/api" + realm = "master" + ca_cert = file("${path.module}/ca.pem") +} +``` + +`tls_insecure_skip_verify = true` turns verification off. It sends the client secret to whoever answers, so use it only against a local instance with a self-signed certificate. + +## Tokens and retries + +The provider requests a token on the first API call, keeps it, and gets a new one shortly before it expires: with the refresh token when it has one, with a new grant otherwise. A `401` makes it drop the token and retry the call once. A long `apply` does not need longer token lifetimes. + +Throttled and failing calls are retried up to three times with exponential backoff, honoring `Retry-After`: + +| Failure | Retried for | +|---|---| +| `429 Too Many Requests` | Every method | +| `5xx`, connection error | `GET`, `HEAD`, `PUT` and `DELETE` only | + +A `POST` or `PATCH` that failed with a `5xx` is not retried, because the change may have been applied. Run `terraform plan` to see where the server stands, then apply again. + +Set `TF_LOG=DEBUG` to see token requests and retries in the output. diff --git a/apps/docs/src/content/docs/terraform/default/en/data-sources.mdx b/apps/docs/src/content/docs/terraform/default/en/data-sources.mdx new file mode 100644 index 0000000..bb74066 --- /dev/null +++ b/apps/docs/src/content/docs/terraform/default/en/data-sources.mdx @@ -0,0 +1,57 @@ +--- +title: Data sources +description: "Read existing FerrisKey objects from Terraform: a realm and its settings, a role by name, and a realm's OpenID Connect discovery document." +icon: search +order: 5 +--- + +# Data sources + +Data sources read objects Terraform does not manage, such as the `master` realm or the roles FerrisKey creates on its own. + +## ferriskey_realm + +```hcl +data "ferriskey_realm" "master" { + name = "master" +} + +output "access_token_lifetime" { + value = data.ferriskey_realm.master.settings.access_token_lifetime +} +``` + +Takes `name` and returns `realm_id`, `created_at`, `updated_at` and `settings`, the same [realm settings](/en/discover/core-concepts/realms#realm-settings) that `ferriskey_realm_settings` manages. + +## ferriskey_role + +```hcl +data "ferriskey_role" "realm_admin" { + realm = "master" + name = "master-realm" +} + +resource "ferriskey_user_role" "runner_realm_admin" { + realm = "master" + user_id = ferriskey_client.terraform_runner.service_account_user_id + role_id = data.ferriskey_role.realm_admin.id +} +``` + +Looks a role up by `realm` and `name`, and returns its UUID as `id`, its `description` and its `permissions`. Use it to assign a role that FerrisKey created, such as `master-realm` in the [bootstrap](/en/terraform/getting-started), or one that another state manages. + +## ferriskey_openid_configuration + +```hcl +data "ferriskey_openid_configuration" "acme" { + realm = "acme" +} + +output "token_endpoint" { + value = data.ferriskey_openid_configuration.acme.token_endpoint +} +``` + +Reads the realm's [discovery document](/en/discover/core-concepts/authentication#openid-connect-discovery), which needs no authentication. It returns `issuer`, `authorization_endpoint`, `token_endpoint`, `userinfo_endpoint`, `jwks_uri`, `introspection_endpoint`, `revocation_endpoint`, `end_session_endpoint`, `grant_types_supported` and `token_endpoint_auth_methods_supported`. + +Pass these values to the applications you configure in the same run, for example as environment variables of a Kubernetes deployment, instead of building the URLs by hand. diff --git a/apps/docs/src/content/docs/terraform/default/en/getting-started.mdx b/apps/docs/src/content/docs/terraform/default/en/getting-started.mdx new file mode 100644 index 0000000..b2819e3 --- /dev/null +++ b/apps/docs/src/content/docs/terraform/default/en/getting-started.mdx @@ -0,0 +1,176 @@ +--- +title: Getting started +description: "Bootstrap a fresh FerrisKey instance with Terraform: create a service account with the admin password, then manage everything else with it." +icon: rocket +order: 2 +--- + +# Getting started + +A fresh FerrisKey instance has an admin user and nothing else. The credentials Terraform should use day to day, a confidential client with a service account, do not exist yet. The recommended setup therefore runs in two phases, each with its own state: + +```text +FerrisKey deployed (admin user from ADMIN_USERNAME / ADMIN_PASSWORD) + └─> phase 1 auth: password grant, admin user + └─> creates the terraform-runner client and gives its service account a role + └─> phase 2 auth: client credentials, terraform-runner + └─> creates realms, clients, users, roles, ... +``` + +Keep the two phases in **separate states**, in separate directories or backends. If they shared one, a `terraform destroy` of your configuration could delete the client that runs the destroy. + +## Prerequisites + +- Terraform 1.0 or later +- A running FerrisKey instance. To start one locally, follow the [deployment getting-started](/en/discover/getting-started) +- The admin username and password of the `master` realm +- A public client in `master` that allows the password grant, such as `admin-cli`. To create one, open **Clients**, choose **New client**, set **Client authentication** to **Public** and turn on **Direct access grants** under **Capability config** + +The password grant is [deprecated](/en/discover/core-concepts/authentication#password-resource-owner). Phase 1 uses it once, to create a client that does not need it. You can turn **Direct access grants** off again after phase 1. + +## Phase 1: the service account + +::::step-group +:::step{title="Write the bootstrap configuration"} +```hcl title="01-bootstrap/main.tf" +terraform { + required_providers { + ferriskey = { + source = "ferriskey/ferriskey" + } + } +} + +provider "ferriskey" { + url = "https://auth.example.com" + realm = "master" + client_id = "admin-cli" + username = "admin" + # password comes from FERRISKEY_PASSWORD +} + +resource "ferriskey_client" "terraform_runner" { + realm = "master" + client_id = "terraform-runner" + name = "Terraform Runner" + client_type = "confidential" + service_account_enabled = true + direct_access_grants_enabled = false +} + +data "ferriskey_role" "realm_admin" { + realm = "master" + name = "master-realm" +} + +resource "ferriskey_user_role" "runner_realm_admin" { + realm = "master" + user_id = ferriskey_client.terraform_runner.service_account_user_id + role_id = data.ferriskey_role.realm_admin.id +} + +output "runner_client_id" { + value = ferriskey_client.terraform_runner.client_id +} + +output "runner_client_secret" { + value = ferriskey_client.terraform_runner.secret + sensitive = true +} +``` + +`service_account_user_id` is the user behind the client's service account. A role given to that user is what the client can do once it authenticates with `client_credentials`. The `master-realm` role carries `manage_realm`, which grants everything. To give less, create a role with only the [permissions](/en/discover/core-concepts/roles#permissions-reference) your configuration needs and assign that one instead. +::: + +:::step{title="Apply it"} +```bash +cd 01-bootstrap +export FERRISKEY_PASSWORD='' +terraform init +terraform apply +``` +::: + +:::step{title="Store the secret"} +```bash +terraform output -raw runner_client_secret +``` + +The secret is also in this phase's state, in clear text, like every value Terraform reads. Store the state in an encrypted backend, and copy the secret to your secrets manager or your CI variables for phase 2. +::: +:::: + +## Phase 2: everything else + +::::step-group +:::step{title="Write the configuration"} +```hcl title="02-resources/main.tf" +terraform { + required_providers { + ferriskey = { + source = "ferriskey/ferriskey" + } + } +} + +provider "ferriskey" { + url = "https://auth.example.com" + realm = "master" + client_id = "terraform-runner" + # client_secret comes from FERRISKEY_CLIENT_SECRET +} + +resource "ferriskey_realm" "acme" { + name = "acme" +} + +resource "ferriskey_realm_settings" "acme" { + realm = ferriskey_realm.acme.name + access_token_lifetime = 900 + user_registration_enabled = true + passkey_enabled = true +} + +resource "ferriskey_client" "web" { + realm = ferriskey_realm.acme.name + client_id = "acme-web" + name = "Acme Web App" + client_type = "confidential" + redirect_uris = ["https://app.acme.example/callback"] +} +``` + +`realm` in the provider block is the realm Terraform signs in to, `master` here. It does not restrict where resources live: each resource names its own realm. +::: + +:::step{title="Apply it"} +```bash +cd 02-resources +export FERRISKEY_CLIENT_SECRET='' +terraform init +terraform apply +``` +::: +:::: + +Instead of copying the secret by hand, phase 2 can read the outputs of phase 1 with a `terraform_remote_state` data source. Phase 2 only reads that state and never writes it, so the two lifecycles stay apart: + +```hcl +data "terraform_remote_state" "bootstrap" { + backend = "local" + config = { + path = "${path.module}/../01-bootstrap/terraform.tfstate" + } +} + +provider "ferriskey" { + url = "https://auth.example.com" + realm = "master" + client_id = data.terraform_remote_state.bootstrap.outputs.runner_client_id + client_secret = data.terraform_remote_state.bootstrap.outputs.runner_client_secret +} +``` + +## Taking over an existing instance + +On an instance that was configured by hand, write the resources that match what exists, then [import](/en/terraform/resources) them before the first `apply`. A resource that is not imported is created from scratch, next to or in conflict with the one that already exists. `terraform plan` after the imports shows the differences between your files and the server. diff --git a/apps/docs/src/content/docs/terraform/default/en/overview.mdx b/apps/docs/src/content/docs/terraform/default/en/overview.mdx new file mode 100644 index 0000000..321d024 --- /dev/null +++ b/apps/docs/src/content/docs/terraform/default/en/overview.mdx @@ -0,0 +1,95 @@ +--- +title: Overview +description: "The FerrisKey Terraform provider manages realms, clients, users, roles and organizations as code, through the FerrisKey REST API." +icon: layers +order: 1 +--- + +# Terraform provider + +The `ferriskey/ferriskey` provider manages the configuration of a FerrisKey instance from Terraform: realms and their settings, clients, users, roles, organizations, identity providers, the password policy and SMTP. It is a client of the REST API, like `ferris-ctl`, with Terraform's plan, state and drift detection on top. + +It does not deploy FerrisKey. The [Helm chart or the operator](/en/kubernetes/overview) runs the server, and the provider configures what is inside it. + +::::card-group{cols=3} +:::card{label="Getting started" icon="lucide:rocket" href="/en/terraform/getting-started"} +Bootstrap a fresh instance in two phases: a service account first, then everything else. +::: +:::card{label="Authentication" icon="lucide:key-round" href="/en/terraform/authentication"} +Password and client credentials grants, environment variables, TLS, retries. +::: +:::card{label="Resources" icon="lucide:box" href="/en/terraform/resources"} +Every resource, what it manages, what it leaves alone, and how to import it. +::: +:::: + +## Requirements + +- Terraform 1.0 or later +- A reachable FerrisKey instance, API 0.6 or later +- A client the provider can authenticate with, see [authentication](/en/terraform/authentication) + +## Minimal configuration + +```hcl title="main.tf" +terraform { + required_providers { + ferriskey = { + source = "ferriskey/ferriskey" + } + } +} + +provider "ferriskey" { + url = "https://auth.example.com" + realm = "master" + client_id = "terraform-runner" + client_secret = var.ferriskey_client_secret +} + +resource "ferriskey_realm" "acme" { + name = "acme" +} + +resource "ferriskey_client" "web" { + realm = ferriskey_realm.acme.name + client_id = "acme-web" + name = "Acme Web App" + client_type = "confidential" + redirect_uris = ["https://app.acme.example/callback"] +} +``` + +`terraform init` downloads the provider from the Terraform Registry. Leave `client_secret` out of the file and set `FERRISKEY_CLIENT_SECRET` instead: every provider argument has a [`FERRISKEY_*` equivalent](/en/terraform/authentication#environment-variables). + +## What it covers + +| Type | Name | Manages | +|---|---|---| +| Resource | [`ferriskey_realm`](/en/terraform/resources#ferriskey_realm) | A realm | +| Resource | [`ferriskey_realm_settings`](/en/terraform/resources#ferriskey_realm_settings) | Token lifetimes, registration, passkeys, magic links, email verification | +| Resource | [`ferriskey_client`](/en/terraform/resources#ferriskey_client) | An OpenID Connect client, its redirect URIs and its service account | +| Resource | [`ferriskey_user`](/en/terraform/resources#ferriskey_user) | A user and its required actions | +| Resource | [`ferriskey_role`](/en/terraform/resources#ferriskey_role) | A realm role and its permissions | +| Resource | [`ferriskey_user_role`](/en/terraform/resources#ferriskey_user_role) | A role assigned to a user or a service account | +| Resource | [`ferriskey_organization`](/en/terraform/resources#ferriskey_organization) | An organization | +| Resource | [`ferriskey_organization_member`](/en/terraform/resources#ferriskey_organization_member) | A user's membership in an organization | +| Resource | [`ferriskey_password_policy`](/en/terraform/resources#ferriskey_password_policy) | The realm's password policy | +| Resource | [`ferriskey_smtp_config`](/en/terraform/resources#ferriskey_smtp_config) | The realm's SMTP settings | +| Resource | [`ferriskey_identity_provider`](/en/terraform/resources#ferriskey_identity_provider) | An OIDC or SAML identity provider | +| Data source | [`ferriskey_realm`](/en/terraform/data-sources#ferriskey_realm) | Reads a realm and its settings | +| Data source | [`ferriskey_role`](/en/terraform/data-sources#ferriskey_role) | Looks up a role by name | +| Data source | [`ferriskey_openid_configuration`](/en/terraform/data-sources#ferriskey_openid_configuration) | Reads the realm's discovery document | + +Client scopes, protocol mappers, token exchange policies, SAML service providers, webhooks and the modules (Compass, SeaWatch, maintenance) have no resource yet. Manage them in the console, with the API, or with [`ferris-ctl`](/en/cli/overview). + +## Identifiers + +Realm-scoped resources use a composite ID, `{realm}/{uuid}`, which is also what `terraform import` takes. A realm is identified by its name. Resources that exist once per realm (settings, password policy, SMTP) use the realm name as their ID. + +```bash +terraform import ferriskey_realm.acme acme +terraform import ferriskey_client.web acme/3a8c6128-1111-2222-3333-444455556666 +``` + +The [resources](/en/terraform/resources) page lists the import ID of each one. diff --git a/apps/docs/src/content/docs/terraform/default/en/resources.mdx b/apps/docs/src/content/docs/terraform/default/en/resources.mdx new file mode 100644 index 0000000..53397d7 --- /dev/null +++ b/apps/docs/src/content/docs/terraform/default/en/resources.mdx @@ -0,0 +1,275 @@ +--- +title: Resources +description: "Every resource of the FerrisKey Terraform provider: what it manages, the attributes that matter, what it leaves alone, and its import ID." +icon: box +order: 4 +--- + +# Resources + +Each section shows an example, the attributes worth knowing about and the import command. The [provider repository](https://github.com/ferriskey/terraform-provider-ferriskey/tree/main/docs) has the full schema of every resource. + +An attribute marked **replaces** cannot be changed in place: changing it destroys the object and creates a new one, with a new UUID. For a user or a client, that also drops what hangs off the old one, such as credentials, sessions and role assignments. + +## ferriskey_realm + +```hcl +resource "ferriskey_realm" "acme" { + name = "acme" +} +``` + +| Attribute | Description | +|---|---| +| `name` | Realm name. Renamed in place, but every URL and issuer of the realm changes with it | +| `realm_id` | UUID, read-only | +| `settings` | Read-only copy of the realm settings. Manage them with `ferriskey_realm_settings` | + +Destroying the resource deletes the realm and everything in it. The `master` realm cannot be deleted, so do not manage it with this resource: read it with the [`ferriskey_realm` data source](/en/terraform/data-sources#ferriskey_realm). + +```bash +terraform import ferriskey_realm.acme acme +``` + +## ferriskey_realm_settings + +```hcl +resource "ferriskey_realm_settings" "acme" { + realm = ferriskey_realm.acme.name + access_token_lifetime = 600 + refresh_token_lifetime = 43200 + user_registration_enabled = true + forgot_password_enabled = true + passkey_enabled = true +} +``` + +Manages the [realm settings](/en/discover/core-concepts/realms#realm-settings): token lifetimes, `default_signing_algorithm`, registration, forgotten password, remember me, magic links, passkeys, email verification and `compass_enabled`. Lifetimes are in seconds, `email_verification_ttl_hours` in hours and `magic_link_ttl` in minutes. + +An update is a partial merge, like the API: a setting you leave out keeps its current value, it is not reset to the default. Destroying the resource stops managing the settings and changes nothing on the server. + +`require_mfa`, `login_aliases`, the lockout, consent, locale and branding settings are not in the resource yet. Set them in the console or with `PUT /realms/{realm_name}/settings`. + +```bash +terraform import ferriskey_realm_settings.acme acme +``` + +## ferriskey_client + +```hcl +resource "ferriskey_client" "web" { + realm = ferriskey_realm.acme.name + client_id = "acme-web" + name = "Acme Web App" + client_type = "confidential" + redirect_uris = [ + "https://app.acme.example/callback", + "https://app.acme.example/silent-renew", + ] + access_token_lifetime = 300 +} + +resource "ferriskey_client" "spa" { + realm = ferriskey_realm.acme.name + client_id = "acme-spa" + name = "Acme SPA" + client_type = "public" + public_client = true + direct_access_grants_enabled = false + redirect_uris = ["https://spa.acme.example/callback"] +} +``` + +| Attribute | Description | +|---|---| +| `client_id` | The `client_id` applications send | +| `client_type` | `confidential`, `public` or `system`. **Replaces** | +| `public_client` | No secret, PKCE carries the protection. **Replaces** | +| `service_account_enabled` | Allows the `client_credentials` grant. **Replaces** | +| `direct_access_grants_enabled` | Allows the deprecated password grant | +| `redirect_uris` | A set, so order does not matter. Leave it out to leave the client's redirect URIs alone, set `[]` to remove them all. See [redirect URIs](/en/discover/core-concepts/clients#redirect-uris) | +| `access_token_lifetime`, `refresh_token_lifetime`, `id_token_lifetime`, `temporary_token_lifetime` | Per-client overrides, in seconds. The realm value applies when unset | +| `secret` | Generated by the server, read-only and sensitive. Stored in the state | +| `service_account_user_id` | The service account user, when `service_account_enabled` is on. Give it roles with `ferriskey_user_role` | + +The other [client properties](/en/discover/core-concepts/clients#client-properties), such as `require_pkce`, `token_exchange_enabled`, `consent_required`, back-channel logout, post-logout redirects and web origins, are not in the resource yet. A client created by the provider gets the server defaults for them. + +```bash +terraform import ferriskey_client.web acme/3a8c6128-1111-2222-3333-444455556666 +``` + +## ferriskey_user + +```hcl +resource "ferriskey_user" "alice" { + realm = ferriskey_realm.acme.name + username = "alice" + email = "alice@acme.example" + email_verified = true + firstname = "Alice" + lastname = "Liddell" + required_actions = ["update_password"] +} +``` + +| Attribute | Description | +|---|---| +| `username` | **Replaces** | +| `email` | Once set, it can be changed but not cleared: removing it from the configuration leaves the server value | +| `email_verified` | `false` by default | +| `enabled` | `true` by default | +| `required_actions` | `verify_email`, `update_password`, `configure_passkey`. See [required actions](/en/discover/core-concepts/users#required-actions) | +| `user_uuid` | UUID, read-only. Use it in `ferriskey_user_role` and `ferriskey_organization_member` | + +The resource sets no password and no credential. Set them in the console, with the API, or let the user sign in another way, such as a magic link or an identity provider. + +Leave `configure_otp` out of `required_actions`. FerrisKey works it out at each sign-in from the realm and the user's roles and never stores it, so Terraform would plan to add it on every run. + +The user removes `verify_email` and `update_password` from their account by completing them. Terraform then plans to add them back. Add `lifecycle { ignore_changes = [required_actions] }` when the actions are set once at creation. + +```bash +terraform import ferriskey_user.alice acme/9f1c0e2a-aaaa-bbbb-cccc-ddddeeeeffff +``` + +## ferriskey_role + +```hcl +resource "ferriskey_role" "support" { + realm = ferriskey_realm.acme.name + name = "support" + description = "Read-only support staff" + permissions = ["view_users", "query_users", "view_clients"] +} +``` + +`permissions` takes the snake_case names of the [permissions reference](/en/discover/core-concepts/roles#permissions-reference), and replaces the whole set on update. `realm` **replaces**. The resource manages realm roles only: `client_id` is read-only. + +A name that matches no permission is dropped silently when the provider's account holds `manage_realm`, and refused with a 403 otherwise. In the first case, the server never stores it, so every `plan` shows it again. Check the names when a role keeps showing a change. + +```bash +terraform import ferriskey_role.support acme/4b2d7f90-1111-2222-3333-444455556666 +``` + +## ferriskey_user_role + +```hcl +resource "ferriskey_user_role" "alice_support" { + realm = ferriskey_realm.acme.name + user_id = ferriskey_user.alice.user_uuid + role_id = ferriskey_role.support.role_uuid +} +``` + +Assigns a realm role to a user, or to a client's service account through `service_account_user_id`. It is a link with no attributes of its own: every change replaces it. Destroying it removes the assignment, not the user or the role. + +```bash +terraform import ferriskey_user_role.alice_support acme/USER_UUID/ROLE_UUID +``` + +## ferriskey_organization + +```hcl +resource "ferriskey_organization" "globex" { + realm = ferriskey_realm.acme.name + name = "Globex" + alias = "globex" + description = "Globex Corporation tenant" + domain = "globex.example" +} +``` + +`alias` is the stable, URL-safe identifier of the organization within the realm. `enabled` is `true` by default, `redirect_url` is optional, and `realm` **replaces**. + +```bash +terraform import ferriskey_organization.globex acme/7c3e9a14-1111-2222-3333-444455556666 +``` + +## ferriskey_organization_member + +```hcl +resource "ferriskey_organization_member" "alice_globex" { + realm = ferriskey_realm.acme.name + organization_id = ferriskey_organization.globex.organization_uuid + user_id = ferriskey_user.alice.user_uuid +} +``` + +Adds a user to an organization. Like `ferriskey_user_role`, it is a link and every change replaces it. + +```bash +terraform import ferriskey_organization_member.alice_globex acme/ORG_UUID/USER_UUID +``` + +## ferriskey_password_policy + +```hcl +resource "ferriskey_password_policy" "acme" { + realm = ferriskey_realm.acme.name + min_length = 14 + require_uppercase = true + require_lowercase = true + require_number = true + require_special = true + max_age_days = 365 +} +``` + +Manages the realm's [password policy](/en/discover/core-concepts/password-policy). Leave `max_age_days` unset for passwords that never expire. A realm always has a policy, so destroying the resource stops managing it and leaves the policy as it is. + +```bash +terraform import ferriskey_password_policy.acme acme +``` + +## ferriskey_smtp_config + +```hcl +resource "ferriskey_smtp_config" "acme" { + realm = ferriskey_realm.acme.name + host = "smtp.example.com" + port = 587 + username = "mailer" + password = var.smtp_password + from_email = "no-reply@acme.example" + from_name = "Acme" + encryption = "tls" +} +``` + +Manages the realm's SMTP settings, described in the [email guide](/en/discover/guides/email). All attributes are required. `encryption` is `tls`, `ssl` or `none`. + +The API never returns `password`. Terraform keeps the value from the configuration, so a password changed in the console is not seen as drift, and after an import the password has to be set in the configuration before the next `apply`. Destroying the resource deletes the realm's SMTP configuration. + +```bash +terraform import ferriskey_smtp_config.acme acme +``` + +## ferriskey_identity_provider + +```hcl +resource "ferriskey_identity_provider" "google" { + realm = ferriskey_realm.acme.name + alias = "google" + provider_id = "oidc" + display_name = "Google" + + config = { + clientId = var.google_client_id + clientSecret = var.google_client_secret + } +} +``` + +| Attribute | Description | +|---|---| +| `alias` | Unique within the realm. **Replaces** | +| `provider_id` | `oidc` or `saml`. **Replaces** | +| `config` | Provider-specific keys, such as `clientId`, `clientSecret` or `authorizationUrl`. Only the keys you set are managed: keys the server adds are ignored | +| `enabled` | `true` by default | +| `trust_email`, `link_only`, `store_token`, `add_read_token_role_on_create` | Booleans, server default when unset | +| `first_broker_login_flow_alias`, `post_broker_login_flow_alias` | Flow aliases | + +The import ID uses the alias, not a UUID: + +```bash +terraform import ferriskey_identity_provider.google acme/google +``` diff --git a/apps/website/src/i18n/ui.ts b/apps/website/src/i18n/ui.ts index f1fbf66..6b69a54 100644 --- a/apps/website/src/i18n/ui.ts +++ b/apps/website/src/i18n/ui.ts @@ -18,7 +18,7 @@ export const ui = { 'hero.secondaryAction': 'View on GitHub', 'hero.badge.oss': 'Open source', 'hero.badge.license': 'Apache 2.0', - 'hero.badge.version': 'Early Access · v0.9.0', + 'hero.badge.version': 'Early Access · v0.10.0', // Features 'whyNow.label': 'Why now', diff --git a/apps/website/src/lib/release-notes.ts b/apps/website/src/lib/release-notes.ts index 3c71259..a3d5c28 100644 --- a/apps/website/src/lib/release-notes.ts +++ b/apps/website/src/lib/release-notes.ts @@ -18,6 +18,25 @@ export interface ReleaseNoteTranslation { } export const releaseNotes: ReleaseNote[] = [ + { + version: 'v0.10.0', + publishedAt: '2026-10-27T15:52:20Z', + title: 'Authorization server for MCP, tenant authorization with Cedar, and a hardened login path', + summary: + 'FerrisKey 0.10.0 lets a realm act as the authorization server of an MCP server and adds tenant authorization rules evaluated with Cedar behind an AuthZEN endpoint. Most of the cycle went into the login path itself: an OIDC audit ended in around forty fixes, secrets are sealed at rest, and the token endpoint runs far fewer SQL statements per grant.', + kind: 'major', + githubUrl: 'https://github.com/ferriskey/ferriskey/releases/tag/v0.10.0', + compareUrl: 'https://github.com/ferriskey/ferriskey/compare/v0.9.0...v0.10.0', + highlights: [ + 'Makes a realm the authorization server of an MCP server: RFC 8414 metadata, the iss authorization response parameter (RFC 9207), resource indicators (RFC 8707), Client ID Metadata Documents and Dynamic Client Registration (RFC 7591), so an MCP client discovers the realm, registers itself and signs the user in with no client created by hand. Both registration modes are realm toggles, off by default.', + 'Adds tenant authorization: a realm stores its own rules, validates and evaluates them with Cedar, loads the facts of a principal from PostgreSQL, and answers its applications over an AuthZEN 1.0 evaluation endpoint called by a service account. The endpoint is disabled by default.', + 'Lands around forty security and protocol fixes from an OIDC audit whose findings were first written as failing tests: atomic code redemption with revocation on replay, PKCE required on new clients, one client authentication method on every endpoint with throttling of failed attempts, management API routes that accept only tokens issued for them, brokered logins linked by email only to a verified account, and consent, maintenance mode and lockout applied to every way a login completes.', + 'Seals realm signing keys, TOTP seeds and SMTP passwords with AES-256-GCM when SECRETS_ENCRYPTION_KEYS is set, with key rotation and a sweep at startup that seals the values still stored in clear. The console keeps its tokens per tab under a content security policy, and email templates are sanitized on the server.', + 'Cuts the work of a login: realms, clients, scopes and mappers are served from memory between requests, audit and Compass writes are batched, a browser login goes from 79 to 51 SQL statements, and client_credentials tokens are issued without a database round trip. The Argon2 cost becomes a setting, and every listing of the API is paginated with one shared contract.', + ], + transition: + 'Where 0.9 put the realm boundary under the compiler, 0.10 opens FerrisKey to two new callers, MCP clients and the policy enforcement points of tenant applications, and spends the rest of the cycle making the login path both stricter and cheaper.', + }, { version: 'v0.9.0', publishedAt: '2026-10-03T00:00:00Z', @@ -312,6 +331,21 @@ export const latestRelease = releaseNotes[0] export const releaseNoteTranslations: Record> = { fr: { + 'v0.10.0': { + title: + "Serveur d'autorisation pour MCP, autorisation des tenants avec Cedar et un parcours de login durci", + summary: + "FerrisKey 0.10.0 permet à un realm de servir de serveur d'autorisation à un serveur MCP et ajoute des règles d'autorisation par tenant, évaluées avec Cedar derrière un endpoint AuthZEN. L'essentiel du cycle est passé dans le parcours de login lui-même : un audit OIDC s'est conclu par une quarantaine de correctifs, les secrets sont scellés au repos et le token endpoint exécute beaucoup moins de requêtes SQL par grant.", + highlights: [ + "Fait d'un realm le serveur d'autorisation d'un serveur MCP : métadonnées RFC 8414, paramètre iss dans la réponse d'autorisation (RFC 9207), resource indicators (RFC 8707), Client ID Metadata Documents et Dynamic Client Registration (RFC 7591). Un client MCP découvre le realm, s'enregistre et connecte l'utilisateur sans client créé à la main. Les deux modes d'enregistrement sont des options du realm, désactivées par défaut.", + "Ajoute l'autorisation des tenants : un realm stocke ses propres règles, les valide et les évalue avec Cedar, charge les faits d'un principal depuis PostgreSQL et répond à ses applications via un endpoint d'évaluation AuthZEN 1.0 appelé par un service account. L'endpoint est désactivé par défaut.", + "Livre une quarantaine de correctifs de sécurité et de protocole issus d'un audit OIDC dont les constats ont d'abord été écrits sous forme de tests en échec : échange du code atomique avec révocation en cas de rejeu, PKCE obligatoire sur les nouveaux clients, une seule méthode d'authentification client sur tous les endpoints avec limitation des échecs, routes de l'API de management qui n'acceptent que les tokens émis pour elles, logins fédérés liés par email uniquement à un compte vérifié, et consentement, mode maintenance et verrouillage appliqués à toutes les façons de terminer un login.", + "Scelle les clés de signature des realms, les seeds TOTP et les mots de passe SMTP en AES-256-GCM quand SECRETS_ENCRYPTION_KEYS est défini, avec rotation des clés et un balayage au démarrage qui scelle les valeurs encore stockées en clair. La console garde ses tokens par onglet sous une content security policy, et les templates d'email sont assainis côté serveur.", + "Réduit le travail d'un login : realms, clients, scopes et mappers sont servis depuis la mémoire entre les requêtes, les écritures d'audit et de Compass sont groupées, un login navigateur passe de 79 à 51 requêtes SQL et les tokens client_credentials sont émis sans aller-retour en base. Le coût Argon2 devient un réglage, et chaque listing de l'API est paginé avec un contrat commun.", + ], + transition: + "Là où la 0.9 plaçait la frontière entre realms sous le contrôle du compilateur, la 0.10 ouvre FerrisKey à deux nouveaux appelants, les clients MCP et les points d'application des politiques des applications tenantes, et consacre le reste du cycle à rendre le parcours de login à la fois plus strict et moins coûteux.", + }, 'v0.9.0': { title: "Token exchange, back-channel logout et isolation des realms garantie par le système de types",