-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rename create auth functions (#7137)
* auth0 * azure * clerk * custom * dbAuth * firebase * netlify * supabase * supertokens * cli-helpers * update test project fixture
- Loading branch information
Showing
39 changed files
with
95 additions
and
102 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,5 +1,5 @@ | ||
import { createDbAuthClient, createDbAuth } from '@redwoodjs/auth-dbauth-web' | ||
import { createDbAuthClient, createAuth } from '@redwoodjs/auth-dbauth-web' | ||
|
||
const dbAuthClient = createDbAuthClient() | ||
|
||
export const { AuthProvider, useAuth } = createDbAuth(dbAuthClient) | ||
export const { AuthProvider, useAuth } = createAuth(dbAuthClient) |
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 +1 @@ | ||
export { createAuth0Auth } from './auth0' | ||
export { createAuth } from './auth0' |
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 +1 @@ | ||
export { createAzureActiveDirectoryAuth } from './azureActiveDirectory' | ||
export { createAuth } from './azureActiveDirectory' |
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 +1 @@ | ||
export { createClerkAuth } from './clerk' | ||
export { createAuth } from './clerk' |
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,19 +1,17 @@ | ||
import { createAuthentication } from '@redwoodjs/auth' | ||
|
||
// If you're integrating with an auth service provider you should delete this | ||
// interface | ||
// Instead you should import the type from their auth client sdk | ||
export interface CustomAuthClient { | ||
// If you're integrating with an auth service provider you should delete this interface. | ||
// Instead you should import the type from their auth client sdk. | ||
export interface AuthClient { | ||
login: () => User | ||
logout: () => void | ||
signup: () => User | ||
getToken: () => string | ||
getUserMetadata: () => User | null | ||
} | ||
|
||
// If you're integrating with an auth service provider you should delete this | ||
// interface | ||
// This type should be inferred from the general interface above | ||
// If you're integrating with an auth service provider you should delete this interface. | ||
// This type should be inferred from the general interface above. | ||
interface User { | ||
// The name of the id variable will vary depending on what auth service | ||
// provider you're integrating with. Another common name is `sub` | ||
|
@@ -23,16 +21,15 @@ interface User { | |
roles: string[] | ||
} | ||
|
||
// If you're integrating with an auth service provider you should delete this | ||
// interface | ||
// If you're integrating with an auth service provider you should delete this interface | ||
// This type should be inferred from the general interface above | ||
export interface ValidateResetTokenResponse { | ||
error?: string | ||
[key: string]: string | undefined | ||
} | ||
|
||
// Replace this with the auth service provider client sdk | ||
const customClient = { | ||
const client = { | ||
login: () => ({ | ||
id: 'unique-user-id', | ||
email: '[email protected]', | ||
|
@@ -52,8 +49,8 @@ const customClient = { | |
}), | ||
} | ||
|
||
function createCustomAuth() { | ||
const authImplementation = createCustomAuthImplementation(customClient) | ||
function createAuth() { | ||
const authImplementation = createAuthImplementation(client) | ||
|
||
// You can pass custom provider hooks here if you need to as a second | ||
// argument. See the Redwood framework source code for how that's used | ||
|
@@ -64,14 +61,14 @@ function createCustomAuth() { | |
// the shape of this object (i.e. keep all the key names) but change all the | ||
// values/functions to use methods from the auth service provider client sdk | ||
// you're integrating with | ||
function createCustomAuthImplementation(customClient: CustomAuthClient) { | ||
function createAuthImplementation(client: AuthClient) { | ||
return { | ||
type: 'custom-auth', | ||
client: customClient, | ||
login: async () => customClient.login(), | ||
logout: async () => customClient.logout(), | ||
signup: async () => customClient.signup(), | ||
getToken: async () => customClient.getToken(), | ||
client, | ||
login: async () => client.login(), | ||
logout: async () => client.logout(), | ||
signup: async () => client.signup(), | ||
getToken: async () => client.getToken(), | ||
/** | ||
* Actual user metadata might look something like this | ||
* { | ||
|
@@ -88,8 +85,8 @@ function createCustomAuthImplementation(customClient: CustomAuthClient) { | |
* "updated_at": "2016-05-15T19:53:12.368652374-07:00" | ||
* } | ||
*/ | ||
getUserMetadata: async () => customClient.getUserMetadata(), | ||
getUserMetadata: async () => client.getUserMetadata(), | ||
} | ||
} | ||
|
||
export const { AuthProvider, useAuth } = createCustomAuth() | ||
export const { AuthProvider, useAuth } = createAuth() |
4 changes: 2 additions & 2 deletions
4
packages/auth-providers/dbAuth/setup/src/templates/web/auth.ts.template
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,5 +1,5 @@ | ||
import { createDbAuthClient, createDbAuth } from '@redwoodjs/auth-dbauth-web' | ||
import { createDbAuthClient, createAuth } from '@redwoodjs/auth-dbauth-web' | ||
|
||
const dbAuthClient = createDbAuthClient() | ||
|
||
export const { AuthProvider, useAuth } = createDbAuth(dbAuthClient) | ||
export const { AuthProvider, useAuth } = createAuth(dbAuthClient) |
4 changes: 2 additions & 2 deletions
4
packages/auth-providers/dbAuth/setup/src/templates/web/auth.webAuthn.ts.template
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,6 +1,6 @@ | ||
import { createDbAuthClient, createDbAuth } from '@redwoodjs/auth-dbauth-web' | ||
import { createDbAuthClient, createAuth } from '@redwoodjs/auth-dbauth-web' | ||
import WebAuthnClient from '@redwoodjs/auth-dbauth-web/webAuthn' | ||
|
||
const dbAuthClient = createDbAuthClient({ webAuthn: new WebAuthnClient() }) | ||
|
||
export const { AuthProvider, useAuth } = createDbAuth(new WebAuthnClient()) | ||
export const { AuthProvider, useAuth } = createAuth(new WebAuthnClient()) |
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
Oops, something went wrong.