Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

added auth-apple

Mark Burggraf18f03ec79d2f
diff --git a/web/docs/guides/auth/auth-apple.mdx b/web/docs/guides/auth/auth-apple.mdx
index e621aacb459..19854be6fc1 100644
--- a/web/docs/guides/auth/auth-apple.mdx
+++ b/web/docs/guides/auth/auth-apple.mdx
@@ -7,6 +7,209 @@ description: Setting up Apple Login
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
-### Setting up Apple Login
-
## Description
+
+How to set up Apple Login ("Sign In With Apple")
+
+
+The setup process consists of six parts:
+
+* obtain an `App Id` with “Sign In with Apple” capabilities
+* obtain a `Services Id` - this will serve as the `cliend_id`
+* obtain a `secret key` that will be used to get our `client_secret`
+* generate the `client_secret` using the `secret key`
+* Add your `client id` and `client secret` keys to your [Supabase Project](https://supabase.io)
+* Add the login code to your [Supabase JS Client App](https://github.com/supabase/supabase-js)
+
+## Steps
+
+### Log into your [Apple Developer Account](https://developer.apple.com)
+
+- Go to [https://developer.apple.com](https://developer.apple.com)
+- Click on `Account` at the top right to log in
+
+Once logged into your *"Apple Deveoper Account"*:
+
+### Obtain an App Id with “Sign In with Apple” capabilities.
+
+- Go to Certificates, Identifiers & Profiles
+- Click on "Identifiers" at the left
+- Click on the + sign in the upper left next to “Identifiers”
+- Select "App IDs" and click "Continue"
+- Select type "App" and click "Continue"
+- Fill out your app information
+ - App description
+ - Bundle ID (Apple recommends reverse-domain name style, so if your domain is acme.com and your app is called roadrunner, use: "com.acme.roadrunner")
+ - Scroll down and check "Sign In With Apple"
+ - Click "Contine" at the top right
+ - Click "Register" at the top right
+
+### Obtain a Services ID
+This will serve as the `cliend_id` when you make API calls to authenticate the user.
+
+- Go to Certificates, Identifiers & Profiles
+- Click on "Identifiers" at the left
+- Click on the + sign in the upper left next to “Identifiers”
+- Select "Services IDs" and click "Continue"
+- Fill out your information
+ - App description
+ - Bundle ID (you can't use the same Bundle ID from the previous step, but you can just add something to the beginning, such "app." to make it app.com.acme.roadrunner")
+ - SAVE THIS ID -- this ID will become your "client_id" later
+ - Click "Contine" at the top right
+ - Click "Register" at the top right
+
+#### Configure your Services ID
+
+- Under "Identifiers", click on your newly-created Services ID
+- Check the box next to "Sign In With Apple" to enable it
+- Click "Configure" to the right
+- Make sure your newly created Bundle ID is selected under "Primary App ID"
+- Add your domain to the "Domains and Subdomains" box (do not add https://, just add the domain)
+- In the "Return URLs" box, type the callback URL of your app.
+ - Your "Return URL" (OAuth Redirect URI) looks like this:
+ - `https://<project-ref>.supabase.co/auth/v1/callback`
+ - where `https://<project-ref>.supabase.co` is your Supabase Project API URL
+ - Go to your [Supasebase Project Dashboard](https://supabase.io)
+ - Click on the "Settings" icon at the bottom of the left sidebar
+ - Click on "API" in the list
+ - Under Config / URL you'll find your API URL, you can click "Copy" to copy it to the clipboard
+ - Now just add "/auth/v1/callback" to the end of that to get your full "OAauth Redirect URI"
+ - Enter this in the "Return URLs" box
+ - Click "Next" at the bottom right
+- Click "Done" at the bottom
+- Click "Contine" at the top right
+- Click "Save" at the top right
+
+### Download you secret key
+Now you'll need to download a "secret key" file from Apple that will be used to generate your `client_secret`.
+
+- Go to "Certificates, Identifiers & Profiles"
+- Click on "Keys" at the left
+- Click on the + sign in the upper left next to "Keys"
+- Enter a Key Name
+- Check "Sign In with Apple"
+- Click "Configure" to the right
+- Select your newly-created Services ID from the dropdown selector
+- Click "Save" at the top right
+- Click "Continue" at the top right
+- Click "Register" at the top right
+- Click "Download" at the top right
+- Save the downloaded file -- this contains your "secret key" that will be used to generate your `client_secret`
+- Click "Done" at the top right
+
+### Generate your `client_secret`
+The "secret key" you downloaded is used to create the `client_secret` string you'll need to authenticate your users.
+
+According to the [Apple Docs](https://developer.apple.com/documentation/signinwithapplerestapi/generate_and_validate_tokens) it needs to be a JWT token encrypted using the Elliptic Curve Digital Signature Algorithm (ECDSA) with the P-256 curve and the SHA-256 hash algorithm.
+
+At this time, the easiest way to generate this JWT token is with [Ruby](https://www.ruby-lang.org/en/). If you don't have Ruby installed, you can [Download Ruby Here](https://www.ruby-lang.org/en/downloads).
+
+- Install Ruby (or check to make sure it's installed on your system)
+- Install [ruby-jwt](https://github.com/jwt/ruby-jwt)
+ - From the command line, run: `sudo gem install jwt`
+
+Create the script below using a text editor: `secret_gen.rb`
+
+```ruby
+require "jwt"
+
+key_file = "Path to the private key"
+team_id = "Your Team ID"
+client_id = "The Service ID of the service you created"
+key_id = "The Key ID of the private key"
+
+validity_period = 180 # In days. Max 180 (6 months) according to Apple docs.
+
+private_key = OpenSSL::PKey::EC.new IO.read key_file
+
+token = JWT.encode(
+ {
+ iss: team_id,
+ iat: Time.now.to_i,
+ exp: Time.now.to_i + 86400 * validity_period,
+ aud: "https://appleid.apple.com",
+ sub: client_id
+ },
+ private_key,
+ "ES256",
+ header_fields=
+ {
+ kid: key_id
+ }
+)
+puts token
+```
+
+- Edit the `secret_gen.rb` file:
+ - key_file = "Path to the private key you downloaded from Apple"
+ - It should look like this: AuthKey_XXXXXXXXXX.p8
+ - team_id = "Your Team ID"
+ - This is found at the top right of the Apple Developer site (next to your name)
+ - client_id = "The Service ID of the service you created"
+ - This is the "Services ID" you created in the above step "Obtain a Services ID"
+ - If you've lost this ID, you can find it in the Apple Developer Site:
+ - Go to "Certificates, Identifiers & Profiles"
+ - Click "Identifiers" at the left
+ - At the top right drop-down, select "Services IDs"
+ - Find your Identifier in the list (i.e. app.com.acme.roadrunner)
+ - key_id = "The Key ID of the private key"
+ - This can be found in the name of your downloaded secret file (For a file named "AuthKey_XXXXXXXXXX.p8" your key_id is "XXXXXXXXXX")
+ - If you've lost this ID, you can find it in the Apple Developer Site:
+ - Go to "Certificates, Identifiers & Profiles"
+ - Click "Keys" at the left
+ - Click on your newly-created key in the list
+ - Look under "Key ID" to find your key_id
+ - Once you've entered values for all 4 items (key_file, team_id, client_id, key_id) save the `secret_gen.rb` file
+- Generate your `client_secret`
+ - From the command line, run: `ruby secret_gen.rb > client_secret.txt`
+ - Your `client_secret` is now stored in this `client_secret.txt` file
+
+You should now have a `client_id` and `client_secret`
+
+
+### Enter your Github Client ID and Client Secret into your Supabase Project
+
+- Go to your [Supasebase Project Dashboard](https://supabase.io)
+- In the left sidebar, click the "Authentication" icon (near the top)
+- Click "Settings" from the list to go to the "Authentication Settings" page
+- Enter the final (hosted) URL of your app under "Site URL" (this is important)
+- Under "External OAuth Providers" turn "Apple Enabled" to ON
+- Enter your `client_id` and `client_secret` saved in the previous steps
+- Click "Save"
+
+### Add login code to your client app
+
+The JavaScript client code is documented here: [Supabase OAauth Client Code](https://supabase.io/docs/reference/javascript/auth-signin#sign-in-using-third-party-providers)
+
+```js
+const { user, session, error } = await supabase.auth.signIn({
+ provider: 'apple'
+})
+```
+
+Just put this code in a function and create a button or a link or any other UI element to call the function.
+
+```js
+function signInWithGithub() {
+ const { user, session, error } = await supabase.auth.signIn({
+ provider: 'apple'
+ });
+}
+```
+
+To log out:
+
+```js
+function signout() {
+ const { error } = await supabase.auth.signOut();
+}
+```
+
+## Resources
+
+* [Supabase Account - Free Tier OK](https://supabase.io)
+* [Supabase JS Client](https://github.com/supabase/supabase-js)
+* [Apple Developer Account](https://developer.apple.com)
+* [Ruby](https://www.ruby-lang.org/en/)
+* [ruby-jwt](https://github.com/jwt/ruby-jwt)
+
diff --git a/web/docs/guides/storage/storage-sample.mdx b/web/docs/guides/storage/storage-sample.mdx
new file mode 100644
index 00000000000..cd9ec88a3b4
--- /dev/null
+++ b/web/docs/guides/storage/storage-sample.mdx
@@ -0,0 +1,12 @@
+---
+id: storage-sample
+title: "Storage Sample Doc"
+description: Storage Sample Doc
+---
+
+import Tabs from '@theme/Tabs';
+import TabItem from '@theme/TabItem';
+
+## Description
+
+Sample...
\ No newline at end of file
diff --git a/web/sidebars.js b/web/sidebars.js
index ea67e1b6108..1a4ad71ca85 100755
--- a/web/sidebars.js
+++ b/web/sidebars.js
@@ -128,7 +128,7 @@ module.exports = {
type: 'category',
label: 'Storage',
collapsed: false,
- items: ['guides/auth/auth-apple'],
+ items: ['guides/storage/storage-sample'],
},
],
resources: [