-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updates the docs for Celest V1. Improves the file structure and naming conventions of items as well.
- Loading branch information
Showing
29 changed files
with
2,339 additions
and
1,970 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,13 @@ | ||
import { FingerprintIcon, FlowerIcon, LayersIcon, ShieldIcon, WebhookIcon } from "lucide-react"; | ||
import { DatabaseIcon, FingerprintIcon, GlobeIcon, LayersIcon, ShieldIcon } from "lucide-react"; | ||
|
||
export const FunctionsIcon = LayersIcon; | ||
|
||
export const AuthIcon = FingerprintIcon; | ||
|
||
export const DataIcon = FlowerIcon; // OrigamiIcon; | ||
export const DataIcon = DatabaseIcon; | ||
|
||
export const PoliciesIcon = ShieldIcon; | ||
|
||
export const StorageIcon = LayersIcon; | ||
|
||
export const WebsiteIcon = GlobeIcon |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,23 @@ | ||
--- | ||
title: Celest Auth | ||
title: Auth | ||
description: Learn how to add authentication to your Celest project. | ||
--- | ||
|
||
import { Callout } from 'nextra-theme-docs' | ||
# Auth | ||
|
||
# Celest Auth | ||
Celest comes with built-in auth support via our [Cloud Auth](https://github.com/celest-dev/celest/tree/main/services/celest_cloud_auth) package: an open-source, Dart-native service for | ||
authenticating and authorizing users in any Dart backend. | ||
|
||
Celest currently supports email-based authentication via one-time passcodes. This is a simple and secure way to authenticate users in your app without needing to worry about passwords. | ||
<div className="flex flex-row justify-around items-center"> | ||
<img src="https://github.com/cedar-policy/.github/raw/main/profile/logo.svg" alt="Cedar Logo" className="h-full m-2 p-8 w-1/2" /> | ||
<img src="https://www.sqlite.org/images/sqlite370_banner.gif" alt="SQLite Logo" className="h-full m-2 p-8 w-1/2" /> | ||
</div> | ||
|
||
<Callout> | ||
We are working on adding social sign-in and passkeys in future releases. If you have a specific use case you'd like to see, please let us know by creating an [issue](https://github.com/celest-dev/celest/issues/new/choose). | ||
</Callout> | ||
Cloud Auth is built on top of the [Cedar](https://www.cedarpolicy.com/en) policy engine and [SQLite](https://www.sqlite.org/) to both manage user accounts | ||
and enforce consistent access controls in a single Dart package. The Celest CLI will automatically integrate Cloud Auth into your project when | ||
using Celest Auth, but the service is exposed as a Shelf router and middleware which can be used in any Dart project. | ||
|
||
Adding Auth to your Celest project takes 5 lines of code. In your `project.dart` file, add the following code: | ||
To get started with Cloud Auth, continue to the next page to see how to add it to your Celest project 🚀 | ||
|
||
```dart copy filename="celest/project.dart" | ||
import 'package:celest/celest.dart'; | ||
const project = /* .. */; | ||
const auth = Auth( | ||
providers: [ | ||
AuthProvider.email(), | ||
], | ||
); | ||
``` | ||
|
||
That's it! When you run `celest start`, Celest will automatically generate an Auth client for you to use in your Flutter app. | ||
|
||
## Signing In | ||
|
||
To sign in a user, you can use the `authenticate` method on the `celest.auth` object. It's called `authenticate` because there is no longer a distinction between signing in or signing up! | ||
If the user doesn't exist, they will be created. | ||
|
||
```dart | ||
final flow = await celest.auth.email.authenticate( | ||
email: '[email protected]', | ||
); | ||
// Prompt user for OTP code sent to the email | ||
final user = await flow.verify(otpCode: '123456'); | ||
print('User signed in: ${user.id}'); | ||
``` | ||
|
||
A full example of a typical auth flow can be found in our [repo](https://github.com/celest-dev/celest/tree/main/packages/celest_auth/example). | ||
|
||
## Authorizing your functions | ||
|
||
Once a user is signed in, they can access functions marked `@authenticated`. To learn more about authorizing your functions, check out [Authorizing functions](/docs/functions/authorizing-functions). | ||
> Celest Auth also suppors integrating [Supabase](./auth/supabase-auth.mdx) and [Firebase](./auth/firebase-auth.mdx) for cases where you | ||
> already have an existing user base. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"celest-auth": "Celest Auth", | ||
"using-the-auth-client": "Using the Auth client", | ||
"--external": { | ||
"title": "External Providers", | ||
"type": "separator" | ||
}, | ||
"firebase-auth": "Firebase Auth", | ||
"supabase-auth": "Supabase Auth" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
--- | ||
title: Celest Auth | ||
description: Learn how to use Celest's built-in Cloud Auth for authenticating users in your Celest project. | ||
--- | ||
|
||
import { Callout } from 'nextra-theme-docs' | ||
|
||
# Celest Auth | ||
|
||
Adding Auth to your Celest project takes 5 lines of code. In your `project.dart` file, add the following code: | ||
|
||
```dart copy filename="celest/lib/src/project.dart" | ||
import 'package:celest/celest.dart'; | ||
const project = Project(name: 'my-project'); | ||
const auth = Auth( | ||
providers: [ | ||
AuthProvider.email(), | ||
], | ||
); | ||
``` | ||
|
||
That's it! When you run `celest start`, Celest will automatically integrate our open-source Auth backend | ||
[Cloud Auth](https://github.com/celest-dev/celest/tree/main/services/celest_cloud_auth) and generate an Auth | ||
client for you to use in your Flutter app. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
--- | ||
title: Firebase Auth | ||
description: Learn how to use Firebase Auth for authenticating users in your Celest project. | ||
--- | ||
|
||
import { Callout } from 'nextra-theme-docs' | ||
|
||
# Firebase Auth | ||
|
||
If you're migrating to Celest from another framework, chances are you already have a user base that you'd like to use. | ||
|
||
As of Celest V1, Firebase can be used as your auth provider in Celest. And doing so is just as easy as with Celest's built-in auth. | ||
|
||
## In your Celest project | ||
|
||
To use Firebase as your auth provider, add the following code to your `project.dart` file: | ||
|
||
```dart copy filename="celest/lib/src/project.dart" | ||
import 'package:celest/celest.dart'; | ||
const project = Project(name: 'firebase'); | ||
const auth = Auth( | ||
providers: [ | ||
ExternalAuthProvider.firebase(), | ||
], | ||
); | ||
``` | ||
|
||
Verifying users with Firebase requires knowing your Firebase project ID. When you run `celest start`, Celest will automatically search your environment for | ||
any available Firebase projects. If it can't figure out which project to use, you'll be prompted to enter it manually. | ||
|
||
Celest will securely store your Firebase project ID for future use so it doesn't need to prompt you again. | ||
|
||
## In your Flutter app | ||
|
||
In your Flutter app, Celest will listen for changes to Firebase's auth state and update the Celest state accordingly so that | ||
calls to your Cloud Functions are authenticated appropriately. | ||
|
||
To do so, it needs access to your Firebase client, which you pass into the `celest.init` call in your `main` function. | ||
|
||
```dart copy filename="lib/main.dart" | ||
import 'package:firebase_auth/firebase_auth.dart'; | ||
import 'package:firebase_core/firebase_core.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:my_project_client/my_project_client.dart'; | ||
Future<void> main() async { | ||
WidgetsFlutterBinding.ensureInitialized(); | ||
await Firebase.initializeApp(); | ||
celest.init( | ||
externalAuth: ExternalAuth.firebase(FirebaseAuth.instance), | ||
); | ||
runApp(const MyApp()); | ||
} | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
--- | ||
title: Supabase Auth | ||
description: Learn how to use Supabase Auth for authenticating users in your Celest project. | ||
--- | ||
|
||
import { Callout } from 'nextra-theme-docs' | ||
|
||
# Supabase Auth | ||
|
||
If you're migrating to Celest from another framework, chances are you already have a user base that you'd like to use. | ||
|
||
As of Celest V1, Supabase can be used as your auth provider in Celest. And doing so is just as easy as with Celest's built-in auth. | ||
|
||
## In your Celest project | ||
|
||
To use Supabase as your auth provider, add the following code to your `project.dart` file: | ||
|
||
```dart copy filename="celest/lib/src/project.dart" | ||
import 'package:celest/celest.dart'; | ||
const project = Project(name: 'supabase'); | ||
const auth = Auth( | ||
providers: [ | ||
ExternalAuthProvider.supabase(), | ||
], | ||
); | ||
``` | ||
|
||
Verifying users with Supabase requires knowing your Supabase project's URL. When you run `celest start`, Celest will automatically search your environment for | ||
any available Supabase projects. If it can't figure out which project to use, you'll be prompted to enter it manually. | ||
|
||
Celest will securely store your Supabase project URL for future use so it doesn't need to prompt you again. | ||
|
||
## In your Flutter app | ||
|
||
In your Flutter app, Celest will listen for changes to Supabase's auth state and update the Celest state accordingly so that | ||
calls to your Cloud Functions are authenticated appropriately. | ||
|
||
To do so, it needs access to your Supabase client, which you pass into the `celest.init` call in your `main` function. | ||
|
||
```dart copy filename="lib/main.dart" | ||
import 'package:flutter/material.dart'; | ||
import 'package:my_project_client/my_project_client.dart'; | ||
import 'package:supabase_flutter/supabase_flutter.dart'; | ||
Future<void> main() async { | ||
WidgetsFlutterBinding.ensureInitialized(); | ||
final supabase = await Supabase.initialize( | ||
url: 'YOUR_SUPABASE_URL', | ||
anonKey: 'YOUR_SUPABASE_ANON_KEY', | ||
); | ||
celest.init( | ||
externalAuth: ExternalAuth.supabase(supabase.client.auth), | ||
); | ||
runApp(const MyApp()); | ||
} | ||
``` |
Oops, something went wrong.