@golocalinteractive/golocal-cloud-wrapper 1.0.14 → 1.0.15

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,6 +1,6 @@
1
1
  # Go Local Interactive Cloud Wrapper
2
2
 
3
- A React provider component for Go Local Interactive's cloud services with built-in styling.
3
+ A React provider component for Go Local Interactive's cloud services with built-in styling and authentication middleware.
4
4
 
5
5
  ## Installation
6
6
 
@@ -26,6 +26,75 @@ function App() {
26
26
  }
27
27
  ```
28
28
 
29
+ ### Authentication Setup
30
+
31
+ This package includes Auth0 authentication utilities and middleware helpers. To set up authentication in your Next.js app:
32
+
33
+ #### 1. Environment Variables
34
+
35
+ Add these to your `.env.local`:
36
+
37
+ ```env
38
+ AUTH0_SECRET='use [openssl rand -hex 32] to generate a 32 bytes value'
39
+ AUTH0_BASE_URL='http://localhost:3000'
40
+ AUTH0_ISSUER_BASE_URL='https://YOUR_DOMAIN'
41
+ AUTH0_CLIENT_ID='your_client_id'
42
+ AUTH0_CLIENT_SECRET='your_client_secret'
43
+ AUTH0_AUDIENCE='your_audience'
44
+ ```
45
+
46
+ #### 2. Middleware Setup
47
+
48
+ Create a `middleware.ts` file in your project root:
49
+
50
+ ```typescript
51
+ import {
52
+ handleAuthMiddleware,
53
+ authMiddlewareMatcher,
54
+ } from "@golocalinteractive/golocal-cloud-wrapper";
55
+
56
+ export async function middleware(request: NextRequest) {
57
+ return handleAuthMiddleware(request);
58
+ }
59
+
60
+ export const config = {
61
+ matcher: authMiddlewareMatcher,
62
+ };
63
+ ```
64
+
65
+ #### 3. Auth API Routes
66
+
67
+ Create `app/api/auth/[auth0]/route.ts`:
68
+
69
+ ```typescript
70
+ import { handleAuth } from "@auth0/nextjs-auth0";
71
+
72
+ export const GET = handleAuth;
73
+ ```
74
+
75
+ #### 4. Login/Logout Links
76
+
77
+ ```jsx
78
+ import { useUser } from "@auth0/nextjs-auth0/client";
79
+
80
+ function AuthButtons() {
81
+ const { user, isLoading } = useUser();
82
+
83
+ if (isLoading) return <div>Loading...</div>;
84
+
85
+ if (user) {
86
+ return (
87
+ <div>
88
+ <span>Welcome {user.name}!</span>
89
+ <a href="/api/auth/logout">Logout</a>
90
+ </div>
91
+ );
92
+ }
93
+
94
+ return <a href="/api/auth/login">Login</a>;
95
+ }
96
+ ```
97
+
29
98
  ### Manual CSS Import (Alternative)
30
99
 
31
100
  If you prefer to manually control CSS imports, you can import the styles separately: