authhero 0.81.0 → 0.82.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,9 +1,83 @@
1
1
  # Authhero
2
2
 
3
- An open-source auth library for building a drop-in replacement for Auth0.
3
+ Authhero is an open-source authentication library designed as a drop-in replacement for Auth0. It provides a fully functional auth server that you can set up in minutes.
4
4
 
5
- Setup a new project with Authhero in 5 minutes or less:
5
+ ## Getting Started
6
+
7
+ Set up a new project with Authhero in 5 minutes or less:
6
8
 
7
9
  ```bash
8
10
  npx create authhero
9
11
  ```
12
+
13
+ Alternatively, you can install the npm packages into an existing project and integrate Authhero with your existing setup.
14
+
15
+ ## Installation
16
+
17
+ Authhero consists of several npm packages that provide different authentication-related functionalities. The package includes four Hono routers, each handling a different aspect of the auth server:
18
+
19
+ - **Management API (`management-api`)**: Exposes endpoints for managing authentication data, compatible with Auth0's `/api/v2`.
20
+ - **Auth API (`auth-api`)**: Implements OAuth2/OIDC endpoints for user authentication.
21
+ - **Universal Auth (`universal-auth`)**: Provides a server-side rendered UI for login.
22
+ - **SAML App (`saml-app`)**: Handles SAML authentication endpoints.
23
+
24
+ ## Creating a New Auth Server
25
+
26
+ To initialize an auth server using Authhero:
27
+
28
+ ```javascript
29
+ const { managementApp, oauthApp, universalApp, samlApp } = init({
30
+ dataAdapter: params.dataAdapter,
31
+ });
32
+
33
+ rootApp
34
+ .route("/", oauthApp)
35
+ .route("/u", universalApp)
36
+ .route("/api/v2", managementApp)
37
+ .route("/", samlApp);
38
+ ```
39
+
40
+ ## Data Adapters
41
+
42
+ Authhero uses data adapters to handle persistence. The default adapter is `@authhero/kysely`, which connects to any SQL database using Kysely. Future versions will migrate to Drizzle as the default data adapter. You can also create custom adapters, such as DynamoDB + Elasticsearch.
43
+
44
+ ## Hooks
45
+
46
+ Authhero supports hooks to customize authentication logic. For example, you can grant roles dynamically using the `onExecuteCredentialsExchange` hook:
47
+
48
+ ```javascript
49
+ hooks: {
50
+ onExecuteCredentialsExchange: async (
51
+ event: OnExecuteCredentialsExchangeEvent,
52
+ api: OnExecuteCredentialsExchangeAPI,
53
+ ) => {
54
+ if (event.client.id === "sampleClient") {
55
+ api.accessToken.setCustomClaim("roles", "admin");
56
+ }
57
+ }
58
+ },
59
+ ```
60
+
61
+ ### Supported Hooks
62
+
63
+ - `onExecuteCredentialsExchange`
64
+ - `onExecutePreUserRegistration`
65
+ - `onExecutePostUserRegistration`
66
+
67
+ ## Email Providers
68
+
69
+ Authhero supports email providers for sending authentication-related emails. You can use pre-built email provider packages or configure a custom provider. Example:
70
+
71
+ ```javascript
72
+ emailProviders: {
73
+ sqs: sendSqsEmail,
74
+ },
75
+ ```
76
+
77
+ ## Contributing
78
+
79
+ Contributions are welcome! Feel free to open issues and submit pull requests to improve Authhero.
80
+
81
+ ## License
82
+
83
+ Authhero is open-source and available under the MIT License.