Skip to content

Commit 3325d76

Browse files
authored
Improve documentation for Associated Domains setup (#46)
I found the original guide a bit hard to follow and accidentally used the wrong identifiers in the file, which Apple cached. I'm hoping this rework makes it a bit clearer
1 parent 1358e6c commit 3325d76

File tree

1 file changed

+56
-31
lines changed

1 file changed

+56
-31
lines changed

DOMAINS.md

Lines changed: 56 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,28 @@
1-
## Setting up Associated Domains
1+
# Setting up Associated Domains
22

3-
Native apps require configuring Associated Domains in order to support passkeys.
3+
Native apps **require** configuring Associated Domains in order to support passkeys.
44
This allows a domain to provide an allow-list of apps that may authenticate using a saved passkey or other authenticator.
55

6-
> [!WARNING]
6+
> [!IMPORTANT]
77
> If you have not configured Associated Domains, all SnapAuth APIs will immediately fail!
8+
> This involves publishing a JSON file on your domain, and updating a setting in Xcode.
89
10+
## Xcode
911

1012
### Add the Associated Domains capability
1113

12-
> [!TIP]
13-
> You may have already done this if your existing app supports password autofill.
14-
>
15-
> Still, fully review this section!
16-
17-
More info:
18-
19-
- https://developer.apple.com/documentation/xcode/supporting-associated-domains
20-
- https://developer.apple.com/documentation/bundleresources/entitlements/com_apple_developer_associated-domains
14+
You may have already done this if your existing app supports password autofill.
15+
Still, fully review this section!
2116

2217
In XCode, select your root-level project in the Navigator.
2318

2419
Select your Target, and navigate to the Signing & Capabilities tab.
2520

2621
Click `+ Capability` and select `Associated Domains`
2722

28-
> [!WARNING]
29-
> This capability is restricted on free Apple Developer accounts.
30-
> Unfortunately, this means you must have a current, paid account to proceed.
31-
32-
<!-- Also, personal accounts might not work? -->
23+
> [!NOTE]
24+
> This capability is unavailable on free Apple Developer accounts.
25+
> Unfortunately, this means you **must have a current, paid account** to proceed.
3326
3427
In the new Associated Domains section, click `+` and add your domain(s):
3528

@@ -39,48 +32,73 @@ This should match the `RP ID` from the SnapAuth dashboard.
3932

4033
<!-- Must match exactly? Registrable domain match? -->
4134

42-
### Publish the domain association file
35+
## Website
36+
37+
### Create (or update) the domain association file
4338

4439
Create the assoication file (or, if you already have one for other capabilities, add this section):
4540

4641
```json
4742
{
4843
"webcredentials": {
4944
"apps": [
50-
"your App ID"
45+
"<Team ID>.<Bundle ID>"
5146
]
5247
}
5348
}
5449
```
5550

56-
This file must be served at `https://yourdomain.tld/.well-known/apple-app-site-association`.
57-
58-
`curl https://yourdomain.tld/.well-known/apple-app-site-association` to test it.
51+
This full string in `apps` will look something like `A5B4C3D2E1.tld.yourdomain.YourAppName`.
52+
See below for details.
5953

6054
> [!CAUTION]
6155
> If you already have a Domain Association file, be sure only to append or merge this change.
6256
> Do not replace other content in the file, which could lead to breaking other app functionality!
6357
64-
#### Your App ID
58+
### `Team ID`
6559

66-
Your App ID can be obtained from the Apple developer portal(s):
60+
> [!WARNING]
61+
> The `TeamId` is NOT the App ID from App Store Connect, nor is it your personal developer ID.
62+
> Even if you're registered as an individual developer account, you still have a Team ID.
63+
>
64+
> If you publish the incorrect id in this file, you may have to wait a while before being able to proceed.
65+
> It's cached fairly aggressively by Apple's CDNs, and there's no known way to force a cache bust.
66+
> See the bottom of this page for a possible workaround.
6767
68-
https://developer.apple.com/account/resources/identifiers/list > Select your app
68+
This can be found in a few different places with the Apple developer portal.
69+
Depending on your role and permissions, not all may work.
6970

70-
or
71+
1) https://developer.apple.com/account/resources/identifiers/list
72+
- Select your app
73+
- Look near the top for `App ID Prefix`
7174

72-
https://developer.apple.com/account#MembershipDetailsCard > Look for Team ID, and
75+
2) https://developer.apple.com/account#MembershipDetailsCard
76+
- Scroll down to Membership Details
77+
- Look for Team ID
7378

79+
3) https://appstoreconnect.apple.com/access/users
80+
- Click into your own account
81+
- Look for Team ID
82+
83+
### `Bundle Id`
7484
XCode > Your app (the root-level object in Navigator) > Targets > (pick one) > General, look for Bundle Identifier
7585

76-
The App ID is the combination of the Team ID (typically 10 characters) and the Bundle ID (typically configured in-app, frequently in reverse-DNS format): `TeamID.BundleID`
7786

78-
This will result in something like `A5B4C3D2E1.tld.yourdomain.YourAppName`
7987

80-
#### Optional: enable SWC Developer Mode
88+
### Publish the file
89+
90+
This file must be served at `https://yourdomain.tld/.well-known/apple-app-site-association`.
91+
92+
`curl https://yourdomain.tld/.well-known/apple-app-site-association` to test it.
93+
94+
It should be served with an `application/json` `mime-type`, but it's not strictly required.
95+
Be sure it's not blocked by robots.txt or firewall rules.
96+
97+
98+
## Optional: enable SWC Developer Mode
8199

82100
In production applications, Apple caches the Associated Domains file for about a day.
83-
For local development, you can bypass this cache:
101+
For local development of a macOS app, you can bypass this cache:
84102

85103
1) _Add_ a second entry to the Associated Domains section:
86104
`webcredentials:yourdomain.tld?mode=developer`
@@ -96,3 +114,10 @@ sudo swcutil developer-mode -e 1
96114
You still **must** publish the association file; this only bypasses the cache.
97115

98116
On iOS devices, this is done in Settings.app -> Developer -> Associated Domains Development
117+
118+
## External Resources
119+
120+
More info:
121+
122+
- https://developer.apple.com/documentation/xcode/supporting-associated-domains
123+
- https://developer.apple.com/documentation/bundleresources/entitlements/com_apple_developer_associated-domains

0 commit comments

Comments
 (0)