You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
description: Secure your llms.py deployment with GitHub OAuth authentication
4
4
---
5
-
## Features
6
5
7
-
Secure your llms.py deployment with GitHub OAuth authentication and optional user access restrictions.
6
+
## Overview
7
+
8
+
The [github_auth](https://github.com/ServiceStack/llms/tree/main/llms/extensions/github_auth) built-in extension enables OAuth 2.0 authentication via GitHub for your llms application. When enabled, users must sign in with their GitHub account before accessing the application.
9
+
10
+
### Key Features
8
11
9
12
- ✅ GitHub OAuth 2.0 integration
10
13
- ✅ Secure session management
@@ -14,19 +17,40 @@ Secure your llms.py deployment with GitHub OAuth authentication and optional use
14
17
- ✅ Optional user access restrictions
15
18
- ✅ Environment variable support
16
19
17
-
## Setup Instructions
20
+
## Configuration
21
+
22
+
Create a config file at `~/.llms/users/default/github_auth/config.json`:
| GET |`/auth/github`| Initiate GitHub OAuth flow |
153
+
| GET |`/auth/github/callback`| OAuth callback handler |
154
+
| GET |`/auth/session`| Get current session info |
155
+
| POST |`/auth/logout`| End the current session |
182
156
183
157
### Session Management
184
158
@@ -187,18 +161,54 @@ New authentication endpoints:
187
161
- Sessions expire after 24 hours
188
162
- CSRF protection using state tokens (expire after 10 minutes)
189
163
190
-
### Authentication Flow
191
164
192
-
1. User clicks "Sign in with GitHub"
193
-
2. Redirected to `/auth/github`
194
-
3. Server redirects to GitHub OAuth authorization
195
-
4. User authorizes on GitHub
196
-
5. GitHub redirects to `/auth/github/callback` with code
197
-
6. Server exchanges code for access token
198
-
7. Server fetches user info from GitHub API
199
-
8. Server creates session and redirects to `/?session=TOKEN`
200
-
9. Client validates session and stores user info
201
-
10. User is authenticated
165
+
## OAuth Flow
166
+
167
+
```
168
+
┌─────────┐ ┌─────────┐ ┌────────┐
169
+
│ Browser │ │ llms │ │ GitHub │
170
+
└────┬────┘ └────┬────┘ └───┬────┘
171
+
│ │ │
172
+
│ GET /auth/github │ │
173
+
├───────────────────►│ │
174
+
│ │ │
175
+
│ 302 Redirect │ │
176
+
│◄───────────────────┤ │
177
+
│ │ │
178
+
│ /login/oauth/authorize?... │
179
+
├────────────────────────────────────────►
180
+
│ │ │
181
+
│ User grants access │
182
+
│◄────────────────────────────────────────
183
+
│ │ │
184
+
│ GET /auth/github/callback?code=... │
185
+
├───────────────────►│ │
186
+
│ │ │
187
+
│ │ POST /access_token │
188
+
│ ├──────────────────►│
189
+
│ │ │
190
+
│ │ access_token │
191
+
│ │◄──────────────────┤
192
+
│ │ │
193
+
│ │ GET /user │
194
+
│ ├──────────────────►│
195
+
│ │ │
196
+
│ │ user info │
197
+
│ │◄──────────────────┤
198
+
│ │ │
199
+
│ 302 /?session=... │ │
200
+
│ Set-Cookie: token │ │
201
+
│◄───────────────────┤ │
202
+
│ │ │
203
+
```
204
+
205
+
1. User clicks "Sign in with GitHub" → redirects to `/auth/github`
206
+
2. Server generates CSRF state token and redirects to GitHub
207
+
3. User authorizes the app on GitHub
208
+
4. GitHub redirects back with authorization code
209
+
5. Server exchanges code for access token
210
+
6. Server fetches user info from GitHub API
211
+
7. Server creates session and sets cookie
202
212
203
213
### Session Data Structure
204
214
@@ -214,6 +224,21 @@ New authentication endpoints:
214
224
}
215
225
```
216
226
227
+
## UI Component
228
+
229
+
The [github_auth](https://github.com/ServiceStack/llms/tree/main/llms/extensions/github_auth) extension provides a custom `SignIn` component that displays a "Sign in with GitHub" button. This component automatically overrides the default sign-in UI when the extension is loaded.
0 commit comments