MCP server (api.scribase.com) plus the scribase skills for creating a project, adding auth/storage, writing a safe RLS policy, branch-per-PR and the preview-branch-and-confirm workflow. Content ported as-is from the live Scribase agents plugin (rithub.dev/scribase/scribase-agents), packaged with a .grok-plugin/plugin.json manifest for Grok Build. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
78 lines
3.2 KiB
Markdown
78 lines
3.2 KiB
Markdown
---
|
|
name: scribase-add-auth
|
|
description: Add or change sign-in on a Scribase project — email/password, native Apple or Google sign-in (signInWithIdToken) for a mobile app, or a web OAuth redirect — and read back users while debugging. Use when the user asks to add login, auth, sign-in, sign-up, "Sign in with Apple/Google", magic links, or wants to enable or configure an auth provider on an existing Scribase project.
|
|
---
|
|
|
|
# Scribase: add sign-in
|
|
|
|
The auth service is GoTrue-compatible: the app uses plain
|
|
`supabase.auth.*` from `@supabase/supabase-js`, unchanged.
|
|
|
|
## 1. Email and password (works with zero configuration)
|
|
|
|
```ts
|
|
await supabase.auth.signUp({ email, password })
|
|
await supabase.auth.signInWithPassword({ email, password })
|
|
```
|
|
|
|
## 2. Native Apple / Google sign-in (mobile, no browser redirect)
|
|
|
|
The mobile app exchanges a platform ID token for a Scribase session — no
|
|
client secret ever ships in the app.
|
|
|
|
1. Save the provider's client id and turn it on. MCP: call `auth_config_set`
|
|
with `provider` (`apple` or `google`) and `provider_config` — for native
|
|
sign-in only the client id is required (the iOS bundle id for Apple; the
|
|
web/iOS client id(s) for Google):
|
|
|
|
```json
|
|
{ "provider": "apple", "provider_config": { "enabled": true, "client_id": "com.acme.app" } }
|
|
```
|
|
|
|
Read the current settings and providers first with `auth_config_get` if
|
|
unsure what is already configured. Needs an owner- or admin-scoped token;
|
|
if the current token lacks it, tell the user instead of trying a workaround.
|
|
|
|
2. In the app:
|
|
|
|
```ts
|
|
// Apple (expo-apple-authentication)
|
|
const credential = await AppleAuthentication.signInAsync({
|
|
requestedScopes: [AppleAuthentication.AppleAuthenticationScope.EMAIL],
|
|
nonce: hashedNonce, // sha256 of rawNonce
|
|
})
|
|
await supabase.auth.signInWithIdToken({ provider: 'apple', token: credential.identityToken!, nonce: rawNonce })
|
|
|
|
// Google (@react-native-google-signin/google-signin)
|
|
const { data } = await GoogleSignin.signIn()
|
|
await supabase.auth.signInWithIdToken({ provider: 'google', token: data!.idToken! })
|
|
```
|
|
|
|
## 3. Web OAuth redirect (`signInWithOAuth`)
|
|
|
|
Needs the provider's secret too (`provider_config.secret`, stored sealed and
|
|
never returned by `auth_config_get`) and the site's URL in the redirect
|
|
allow list (`auth_config_set` with `settings.uri_allow_list`).
|
|
|
|
```ts
|
|
await supabase.auth.signInWithOAuth({ provider: 'google', options: { redirectTo: 'https://app.example.com/auth/callback' } })
|
|
```
|
|
|
|
## 4. Never ask the user to paste a provider secret into the chat
|
|
|
|
If a client secret or Apple key is needed, tell the user the exact
|
|
`auth_config_set` call to make from a terminal they trust (or point them at
|
|
the console), never type the secret into this conversation for them.
|
|
|
|
## 5. Protect what signed-in users can see
|
|
|
|
A session alone grants nothing — every table still needs row level security
|
|
scoped to `auth.uid()`. See the `scribase-write-rls-policy` skill before
|
|
exposing any new table to signed-in users.
|
|
|
|
## 6. Debugging
|
|
|
|
`auth_users` (MCP) lists users without ever returning a secret. If a sign-in
|
|
is rejected, check `auth_config_get` for the provider's `enabled` flag and
|
|
the redirect allow list before assuming the client code is wrong.
|