authhero 1.0.0 → 1.2.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.
Files changed (88) hide show
  1. package/README.md +126 -7
  2. package/dist/authhero.cjs +376 -0
  3. package/dist/authhero.css +1 -0
  4. package/dist/authhero.d.ts +49161 -0
  5. package/dist/authhero.mjs +46785 -0
  6. package/dist/stats.html +4949 -0
  7. package/package.json +99 -23
  8. package/.changeset/README.md +0 -8
  9. package/.changeset/config.json +0 -11
  10. package/.github/workflows/release.yml +0 -34
  11. package/.prettierignore +0 -3
  12. package/.prettierrc.json +0 -1
  13. package/apps/react-admin/.eslintrc.js +0 -21
  14. package/apps/react-admin/README.md +0 -50
  15. package/apps/react-admin/index.html +0 -125
  16. package/apps/react-admin/package.json +0 -45
  17. package/apps/react-admin/prettier.config.js +0 -1
  18. package/apps/react-admin/public/favicon.ico +0 -0
  19. package/apps/react-admin/public/manifest.json +0 -15
  20. package/apps/react-admin/src/App.spec.tsx +0 -39
  21. package/apps/react-admin/src/App.tsx +0 -75
  22. package/apps/react-admin/src/Layout.tsx +0 -12
  23. package/apps/react-admin/src/TenantsApp.tsx +0 -21
  24. package/apps/react-admin/src/auth0DataProvider.ts +0 -220
  25. package/apps/react-admin/src/authProvider.ts +0 -42
  26. package/apps/react-admin/src/components/TenantAppBar.tsx +0 -46
  27. package/apps/react-admin/src/components/TenantLayout.tsx +0 -17
  28. package/apps/react-admin/src/components/applications/create.tsx +0 -29
  29. package/apps/react-admin/src/components/applications/edit.tsx +0 -40
  30. package/apps/react-admin/src/components/applications/index.ts +0 -3
  31. package/apps/react-admin/src/components/applications/list.tsx +0 -37
  32. package/apps/react-admin/src/components/common/DateAgo.tsx +0 -6
  33. package/apps/react-admin/src/components/common/JsonOutput.tsx +0 -3
  34. package/apps/react-admin/src/components/common/index.ts +0 -1
  35. package/apps/react-admin/src/components/connections/create.tsx +0 -11
  36. package/apps/react-admin/src/components/connections/edit.tsx +0 -66
  37. package/apps/react-admin/src/components/connections/index.ts +0 -3
  38. package/apps/react-admin/src/components/connections/list.tsx +0 -15
  39. package/apps/react-admin/src/components/domains/create.tsx +0 -11
  40. package/apps/react-admin/src/components/domains/edit.tsx +0 -49
  41. package/apps/react-admin/src/components/domains/index.ts +0 -3
  42. package/apps/react-admin/src/components/domains/list.tsx +0 -15
  43. package/apps/react-admin/src/components/listActions/PostListActions.tsx +0 -10
  44. package/apps/react-admin/src/components/tenants/create.tsx +0 -15
  45. package/apps/react-admin/src/components/tenants/edit.tsx +0 -51
  46. package/apps/react-admin/src/components/tenants/index.ts +0 -2
  47. package/apps/react-admin/src/components/tenants/list.tsx +0 -48
  48. package/apps/react-admin/src/components/users/create.tsx +0 -15
  49. package/apps/react-admin/src/components/users/edit.tsx +0 -108
  50. package/apps/react-admin/src/components/users/index.ts +0 -3
  51. package/apps/react-admin/src/components/users/list.tsx +0 -30
  52. package/apps/react-admin/src/data.json +0 -121
  53. package/apps/react-admin/src/dataProvider.ts +0 -48
  54. package/apps/react-admin/src/index.tsx +0 -30
  55. package/apps/react-admin/src/lib/logs.ts +0 -19
  56. package/apps/react-admin/src/vite-env.d.ts +0 -1
  57. package/apps/react-admin/tsconfig.json +0 -9
  58. package/apps/react-admin/tsconfig.node.json +0 -4
  59. package/apps/react-admin/vercel.json +0 -20
  60. package/apps/react-admin/vite.config.ts +0 -19
  61. package/eslint.config.mjs +0 -25
  62. package/packages/authhero/CHANGELOG.md +0 -7
  63. package/packages/authhero/README.md +0 -9
  64. package/packages/authhero/package.json +0 -25
  65. package/packages/authhero/src/bun.ts +0 -16
  66. package/packages/authhero/src/index.ts +0 -34
  67. package/packages/authhero/src/routes/oauth2/index.ts +0 -1
  68. package/packages/authhero/src/routes/oauth2/well-known.ts +0 -179
  69. package/packages/authhero/src/types/Bindings.ts +0 -7
  70. package/packages/authhero/src/types/JWKS.ts +0 -37
  71. package/packages/authhero/src/types/Variables.ts +0 -1
  72. package/packages/authhero/src/types/index.ts +0 -3
  73. package/packages/authhero/src/vite-env.d.ts +0 -1
  74. package/packages/authhero/tsconfig.json +0 -11
  75. package/packages/authhero/tsconfig.node.json +0 -4
  76. package/packages/authhero/vite.config.ts +0 -11
  77. package/packages/create-authhero/package.json +0 -22
  78. package/packages/create-authhero/src/index.ts +0 -72
  79. package/packages/create-authhero/src/vite-env.d.ts +0 -1
  80. package/packages/create-authhero/templates/sqlite/package.json +0 -17
  81. package/packages/create-authhero/templates/sqlite/src/index.ts +0 -19
  82. package/packages/create-authhero/templates/sqlite/yarn.lock +0 -48
  83. package/packages/create-authhero/tsconfig.json +0 -9
  84. package/packages/create-authhero/tsconfig.node.json +0 -4
  85. package/packages/create-authhero/vite.config.ts +0 -14
  86. package/pnpm-workspace.yaml +0 -3
  87. package/tsconfig.json +0 -31
  88. package/tsconfig.node.json +0 -9
package/README.md CHANGED
@@ -1,14 +1,133 @@
1
- # authhero
1
+ # Authhero
2
2
 
3
- Monorepo for authhero containing the following apps:
4
-
5
- - Manage, a web app for managing auth tenants
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.
6
4
 
7
5
  ## Getting Started
8
6
 
9
- Get started by running the following commands:
7
+ Set up a new project with Authhero in 5 minutes or less:
10
8
 
11
9
  ```bash
12
- pnpm install
13
- pnpm dev
10
+ npx create authhero
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.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
+ - `onExecutePostLogin`
67
+
68
+ ## Email Providers
69
+
70
+ Authhero supports email providers for sending authentication-related emails. You can use pre-built email provider packages or configure a custom provider. Example:
71
+
72
+ ```javascript
73
+ emailProviders: {
74
+ sqs: sendSqsEmail,
75
+ },
76
+ ```
77
+
78
+ ## Contributing
79
+
80
+ Contributions are welcome! Feel free to open issues and submit pull requests to improve Authhero.
81
+
82
+ ## License
83
+
84
+ Authhero is open-source and available under the MIT License.
85
+
86
+ ## Using Tailwind CSS with authhero components
87
+
88
+ There are two ways to use the Tailwind CSS styles with authhero components:
89
+
90
+ ### 1. Import the CSS file (for environments with filesystem access)
91
+
92
+ ```js
93
+ // Import the CSS
94
+ import "authhero/styles";
95
+
96
+ // Then use the components
97
+ import { Button, Form } from "authhero";
98
+ ```
99
+
100
+ ### 2. Inject CSS programmatically (for Cloudflare Workers and similar environments)
101
+
102
+ For environments that don't support filesystem access, you can inject the CSS programmatically:
103
+
104
+ ```js
105
+ // Import the helper function
106
+ import { injectTailwindCSS } from "authhero";
107
+
108
+ // Call this function once to inject the CSS into the document
109
+ injectTailwindCSS();
110
+
111
+ // Then use the components
112
+ import { Button, Form } from "authhero";
113
+ ```
114
+
115
+ You can also access the raw CSS string:
116
+
117
+ ```js
118
+ import { tailwindCss } from "authhero";
119
+
120
+ // Use the CSS string as needed
121
+ // For example, in a Cloudflare Worker:
122
+ const html = `
123
+ <!DOCTYPE html>
124
+ <html>
125
+ <head>
126
+ <style>${tailwindCss}</style>
127
+ </head>
128
+ <body>
129
+ <!-- Your content -->
130
+ </body>
131
+ </html>
132
+ `;
14
133
  ```