# CrushOIDC with Apple

This sets up "Sign in with Apple" on the login page, with [CrushOIDC](Plugin-CrushOIDC.md).

Apple differs from other providers in one thing: there is no client secret to copy. The server makes a fresh one whenever it needs it, from a private key that Apple gives you once. So the plugin has three fields for Apple in the place of the secret.

You need an Apple Developer account.

## 1. At Apple

In the Apple Developer site, under **Certificates, Identifiers & Profiles**:

### An App ID

**Identifiers** › **+** › **App IDs** › **App**.

| Field | Give |
|---|---|
| **Description** | a name, such as "Example file server" |
| **Bundle ID** | an identifier of your own, such as `com.example.files` |
| **Capabilities** | tick **Sign In with Apple** |

### A Services ID

This is the "client" for a web site. **Identifiers** › **+** › **Services IDs**.

| Field | Give |
|---|---|
| **Description** | what people see when they sign in |
| **Identifier** | another identifier, such as `com.example.files.signin`. It becomes the **Client ID**. |

Open it again, tick **Sign In with Apple**, press **Configure**:

| Field | Give |
|---|---|
| **Primary App ID** | the App ID from above |
| **Domains and Subdomains** | the server's name: `files.example.com` |
| **Return URLs** | `https://files.example.com/SSO_OIDC/` |

### A key

**Keys** › **+**. Give it a name, tick **Sign in with Apple**, choose the App ID, register, and **download** the file. It ends in `.p8` and can be downloaded once.

Note the **Key ID** shown with the key, and your **Team ID**, at the top right of the developer site.

## 2. Set the plugin

| Setting | Value |
|---|---|
| **OpenID Configuration URL** | `https://appleid.apple.com/.well-known/openid-configuration`. Then **Fetch Configuration**. The plugin recognises Apple by this address and shows Apple's fields. |
| **Client ID** | the identifier of the Services ID |
| **.p8 key** | the content of the key file: open it in a text editor and paste all of it |
| **Team ID**, **Key ID** | from above. "Error: Invalid plugin configuration! Team ID is missing!" |
| **Claim as Username** | `sub`, or `email`: see below |
| **Login button text** | "Sign in with Apple" |

### Only who somebody is

With the **Scope** `openid` and the usual **Authorization URL**, Apple sends one useful claim: `sub`, a long identifier that is unique to the person and to your application. Use it as **Claim as Username** together with **OIDC only used for Authentication**, if each person exists in the User Manager under that identifier.

### With the email address

To get the address, ask for it and tell Apple to send its answer as a form:

| Setting | Value |
|---|---|
| **Scope** | `openid email name` |
| **Authorization URL** | the usual one with `&response_mode=form_post` added at the end |
| **Claim as Username** | `email` |

## Things to know

- **People can hide their address.** Apple lets everybody choose "Hide My Email" and then sends an address of the form `…@privaterelay.appleid.com`, different for each application. Matching by your own domain does not work for them. Decide whether such users are welcome; if they are, name them by `sub`.
- **No groups.** Apple knows nothing about your organisation. Roles by claim do not apply; sort people in the User Manager.
- **The key does not end, but can be revoked** at Apple. Keep the file somewhere safe; the plugin holds a copy.
- **Apple requires HTTPS** and a real domain name for the return address.

## Not tried for this page

Nothing was run against Apple: no account there was used. The steps on the provider's side follow the earlier documentation and the provider's console as it is known; names of menus change over time. The plugin's side is from its screen. Try the first setup with one test user, with **Debug** and **Log HTTP Request Calls** on.
