You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: add Apple Sign-In support to ory_social_provider resource
Add apple_team_id, apple_private_key_id, and apple_private_key attributes
to the social provider resource. Apple uses a non-standard OAuth2 flow
where Ory generates the JWT client_secret from these fields instead of
requiring a static secret.
- Make client_secret optional (Apple providers don't need it)
- Add ValidateConfig with rules for Apple vs non-Apple providers
- Validate empty strings and handle unknown values correctly
- Update buildProviderConfig/Read to handle Apple fields
- Add acceptance tests for Apple create/import/update
- Generate test PEM keys at runtime to avoid secret scanner flags
- Update docs and examples
Closes#80
Copy file name to clipboardExpand all lines: docs/resources/social_provider.md
+46-13Lines changed: 46 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -33,6 +33,18 @@ The `provider_type` attribute determines which OAuth2/OIDC integration to use:
33
33
34
34
~> **Note:** When using `provider_type = "generic"`, you **must** set `issuer_url` to the OIDC issuer URL. The provider uses OIDC discovery to find authorization and token endpoints automatically.
35
35
36
+
## Apple Sign-In
37
+
38
+
Apple uses a non-standard authentication flow. Instead of a static `client_secret`, Apple requires:
39
+
40
+
-**`apple_team_id`** — Your Apple Developer Team ID (e.g., `KP76DQS54M`)
41
+
-**`apple_private_key_id`** — The key ID from the Apple Developer portal (e.g., `UX56C66723`)
42
+
-**`apple_private_key`** — The private key in PEM format (the contents of your `.p8` file)
43
+
44
+
Ory uses these to automatically generate the JWT `client_secret` required by Apple's OAuth2 flow. You do **not** need to set `client_secret` when using Apple-specific fields.
45
+
46
+
Alternatively, you may provide a pre-generated `client_secret` directly if you prefer to manage the JWT yourself.
description = "Apple Service ID (e.g., com.example.auth)"
148
+
type = string
134
149
}
135
150
136
-
variable "apple_client_secret" {
137
-
type = string
138
-
sensitive = true
151
+
variable "apple_team_id" {
152
+
description = "Apple Developer Team ID"
153
+
type = string
154
+
}
155
+
156
+
variable "apple_private_key_id" {
157
+
description = "Apple private key ID from the Developer portal"
158
+
type = string
159
+
}
160
+
161
+
variable "apple_private_key" {
162
+
description = "Apple private key in PEM format (.p8 file contents)"
163
+
type = string
164
+
sensitive = true
139
165
}
140
166
141
167
variable "sso_client_id" {
@@ -173,6 +199,7 @@ If not set, the provider uses a default mapper that extracts the email claim.
173
199
-**`provider_id` and `provider_type` cannot be changed** after creation. Changing either forces a new resource.
174
200
-**`client_secret` is write-only.** The API does not return secrets on read, so Terraform cannot detect external changes to the secret.
175
201
-**`tenant` maps to `microsoft_tenant`** in the Ory API. This is only used with `provider_type = "microsoft"`.
202
+
-**Apple-specific fields** (`apple_team_id`, `apple_private_key_id`, `apple_private_key`) are only valid with `provider_type = "apple"`. The `apple_private_key` is write-only (not returned by API).
176
203
-**Deleting the last provider** resets the entire OIDC configuration to a disabled state with an empty providers array.
177
204
178
205
## Import
@@ -183,21 +210,27 @@ Import using the provider ID:
183
210
terraform import ory_social_provider.google google
184
211
```
185
212
186
-
The `provider_id` is the unique identifier you chose when creating the provider. After import, you must provide `client_secret` in your configuration since it cannot be read from the API.
213
+
The `provider_id` is the unique identifier you chose when creating the provider. After import, you must provide write-only credentials in your configuration since they cannot be read from the API:
214
+
215
+
-**Non-Apple providers:** Set `client_secret`.
216
+
-**Apple providers:** Set either `client_secret` (pre-generated JWT) or all three Apple-specific fields (`apple_team_id`, `apple_private_key_id`, and `apple_private_key`).
187
217
188
218
<!-- schema generated by tfplugindocs -->
189
219
## Schema
190
220
191
221
### Required
192
222
193
223
-`client_id` (String) OAuth2 client ID from the provider.
194
-
-`client_secret` (String, Sensitive) OAuth2 client secret from the provider.
195
224
-`provider_id` (String) Unique identifier for the provider (used in callback URLs).
196
225
-`provider_type` (String) Provider type (google, github, microsoft, apple, generic, etc.).
197
226
198
227
### Optional
199
228
229
+
-`apple_private_key` (String, Sensitive) Apple private key in PEM format (contents of the .p8 file). Required when provider_type is "apple" and client_secret is not set. Ory uses this to generate the JWT client secret automatically.
230
+
-`apple_private_key_id` (String) Apple private key ID from the Apple Developer portal (e.g., "UX56C66723"). Required when provider_type is "apple" and client_secret is not set.
231
+
-`apple_team_id` (String) Apple Developer Team ID (e.g., "KP76DQS54M"). Required when provider_type is "apple" and client_secret is not set.
-`client_secret` (String, Sensitive) OAuth2 client secret from the provider. Required for all providers except Apple (where Ory generates the secret from apple_team_id, apple_private_key_id, and apple_private_key).
201
234
-`issuer_url` (String) OIDC issuer URL (required for generic providers).
202
235
-`mapper_url` (String) Jsonnet mapper URL for claims mapping. Can be a URL or base64-encoded Jsonnet (base64://...). If not set, a default mapper that extracts email from claims will be used.
203
236
-`project_id` (String) Project ID. If not set, uses provider's project_id.
Description: "OAuth2 client secret from the provider.",
93
-
Required: true,
96
+
Description: "OAuth2 client secret from the provider. Required for all providers except Apple (where Ory generates the secret from apple_team_id, apple_private_key_id, and apple_private_key).",
Description: "Tenant ID (for Microsoft/Azure providers).",
119
123
Optional: true,
120
124
},
125
+
"apple_team_id": schema.StringAttribute{
126
+
Description: "Apple Developer Team ID (e.g., \"KP76DQS54M\"). Required when provider_type is \"apple\" and client_secret is not set.",
127
+
Optional: true,
128
+
},
129
+
"apple_private_key_id": schema.StringAttribute{
130
+
Description: "Apple private key ID from the Apple Developer portal (e.g., \"UX56C66723\"). Required when provider_type is \"apple\" and client_secret is not set.",
131
+
Optional: true,
132
+
},
133
+
"apple_private_key": schema.StringAttribute{
134
+
Description: "Apple private key in PEM format (contents of the .p8 file). Required when provider_type is \"apple\" and client_secret is not set. Ory uses this to generate the JWT client secret automatically.",
0 commit comments