🎨 Improve code readability by reformatting and updating function definitions and comments
This commit is contained in:
@@ -179,8 +179,9 @@
|
||||
"obsidian-importer:Open Importer": false
|
||||
}
|
||||
},
|
||||
"active": "db667fd073afcf6d",
|
||||
"active": "16c60370ceca95ef",
|
||||
"lastOpenFiles": [
|
||||
"TODO-challonge-oauth.md",
|
||||
"Christina/Feelings Conversations/Christina Feelings -.md",
|
||||
"Christina/Feelings Conversations/Christina Feelings - - Dec 20.md",
|
||||
"Christina/Feelings Conversations/Christina Feelings - 51624.md",
|
||||
@@ -209,7 +210,6 @@
|
||||
"Apple Notes/Christina 1/!+mime& !+togep& !+burm& !+riolu& !+larv& !+chime& !+happ& !+sable….md",
|
||||
"Apple Notes/Animal Crossing/Ribbot.md",
|
||||
"attachments/100 1.png",
|
||||
"Apple Notes/Animal Crossing/Retro Action Items.md",
|
||||
"attachments/IMG_1115.jpeg",
|
||||
"attachments/Drawing 2.png",
|
||||
"attachments/IMG_6415.heic",
|
||||
|
||||
231
docs/projects/memorypalace/.sync/Archive/.obsidian/workspace.7.json
vendored
Normal file
231
docs/projects/memorypalace/.sync/Archive/.obsidian/workspace.7.json
vendored
Normal file
@@ -0,0 +1,231 @@
|
||||
{
|
||||
"main": {
|
||||
"id": "65118307aef94695",
|
||||
"type": "split",
|
||||
"children": [
|
||||
{
|
||||
"id": "fb78540f6b0817b8",
|
||||
"type": "tabs",
|
||||
"children": [
|
||||
{
|
||||
"id": "6bd06c473a6df9f7",
|
||||
"type": "leaf",
|
||||
"state": {
|
||||
"type": "markdown",
|
||||
"state": {
|
||||
"file": "Random & To Sort/The Tower.md",
|
||||
"mode": "source",
|
||||
"source": false
|
||||
},
|
||||
"icon": "lucide-file",
|
||||
"title": "The Tower"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "db667fd073afcf6d",
|
||||
"type": "leaf",
|
||||
"state": {
|
||||
"type": "markdown",
|
||||
"state": {
|
||||
"file": "Christina/Feelings Conversations/Christina Talk - Jan 15 2024.md",
|
||||
"mode": "source",
|
||||
"source": false
|
||||
},
|
||||
"icon": "lucide-file",
|
||||
"title": "Christina Talk - Jan 15 2024"
|
||||
}
|
||||
}
|
||||
],
|
||||
"currentTab": 1
|
||||
}
|
||||
],
|
||||
"direction": "vertical"
|
||||
},
|
||||
"left": {
|
||||
"id": "87ef67fcdb70cca7",
|
||||
"type": "split",
|
||||
"children": [
|
||||
{
|
||||
"id": "51896b8d031f12a7",
|
||||
"type": "tabs",
|
||||
"children": [
|
||||
{
|
||||
"id": "16c60370ceca95ef",
|
||||
"type": "leaf",
|
||||
"state": {
|
||||
"type": "file-explorer",
|
||||
"state": {
|
||||
"sortOrder": "alphabetical",
|
||||
"autoReveal": false
|
||||
},
|
||||
"icon": "lucide-folder-closed",
|
||||
"title": "Files"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "67df3fa6c50b7b8f",
|
||||
"type": "leaf",
|
||||
"state": {
|
||||
"type": "search",
|
||||
"state": {
|
||||
"query": "",
|
||||
"matchingCase": false,
|
||||
"explainSearch": false,
|
||||
"collapseAll": false,
|
||||
"extraContext": false,
|
||||
"sortOrder": "alphabetical"
|
||||
},
|
||||
"icon": "lucide-search",
|
||||
"title": "Search"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "4735c1046deb84d5",
|
||||
"type": "leaf",
|
||||
"state": {
|
||||
"type": "bookmarks",
|
||||
"state": {},
|
||||
"icon": "lucide-bookmark",
|
||||
"title": "Bookmarks"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"direction": "horizontal",
|
||||
"width": 300
|
||||
},
|
||||
"right": {
|
||||
"id": "fa8d807905c5f186",
|
||||
"type": "split",
|
||||
"children": [
|
||||
{
|
||||
"id": "15acd1bca30e4e69",
|
||||
"type": "tabs",
|
||||
"children": [
|
||||
{
|
||||
"id": "ec633bee723e26ed",
|
||||
"type": "leaf",
|
||||
"state": {
|
||||
"type": "backlink",
|
||||
"state": {
|
||||
"file": "Christina/Feelings Conversations/Christina Talk - Jan 15 2024.md",
|
||||
"collapseAll": false,
|
||||
"extraContext": false,
|
||||
"sortOrder": "alphabetical",
|
||||
"showSearch": false,
|
||||
"searchQuery": "",
|
||||
"backlinkCollapsed": false,
|
||||
"unlinkedCollapsed": true
|
||||
},
|
||||
"icon": "links-coming-in",
|
||||
"title": "Backlinks for Christina Talk - Jan 15 2024"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "76553812ae09d02a",
|
||||
"type": "leaf",
|
||||
"state": {
|
||||
"type": "outgoing-link",
|
||||
"state": {
|
||||
"file": "Welcome.md",
|
||||
"linksCollapsed": false,
|
||||
"unlinkedCollapsed": true
|
||||
},
|
||||
"icon": "links-going-out",
|
||||
"title": "Outgoing links from Welcome"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "a90689d024131f8e",
|
||||
"type": "leaf",
|
||||
"state": {
|
||||
"type": "tag",
|
||||
"state": {
|
||||
"sortOrder": "frequency",
|
||||
"useHierarchy": true
|
||||
},
|
||||
"icon": "lucide-tags",
|
||||
"title": "Tags"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "b05875d99c295b3e",
|
||||
"type": "leaf",
|
||||
"state": {
|
||||
"type": "outline",
|
||||
"state": {
|
||||
"file": "Welcome.md"
|
||||
},
|
||||
"icon": "lucide-list",
|
||||
"title": "Outline of Welcome"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"direction": "horizontal",
|
||||
"width": 300
|
||||
},
|
||||
"left-ribbon": {
|
||||
"hiddenItems": {
|
||||
"bases:Create new base": false,
|
||||
"switcher:Open quick switcher": false,
|
||||
"graph:Open graph view": false,
|
||||
"canvas:Create new canvas": false,
|
||||
"daily-notes:Open today's daily note": false,
|
||||
"templates:Insert template": false,
|
||||
"command-palette:Open command palette": false,
|
||||
"obsidian-importer:Open Importer": false
|
||||
}
|
||||
},
|
||||
"active": "db667fd073afcf6d",
|
||||
"lastOpenFiles": [
|
||||
"Christina/Feelings Conversations/Christina Feelings -.md",
|
||||
"Christina/Feelings Conversations/Christina Feelings - - Dec 20.md",
|
||||
"Christina/Feelings Conversations/Christina Feelings - 51624.md",
|
||||
"Christina/Feelings Conversations/Christina Feelings - Jan 31 2024.md",
|
||||
"Christina/Feelings Conversations/Christina Feelings - Apr 19.md",
|
||||
"Christina/Feelings Conversations/Christina Feelings - Dec 24 2023.md",
|
||||
"Christina/Feelings Conversations/Christina Feelings - Aug 11 2022.md",
|
||||
"Christina/Feelings Conversations/Christina Feelings - May 16 2024.md",
|
||||
"Christina/Feelings Conversations/Christina Feelings - Apr 17 2024.md",
|
||||
"Christina/Feelings Conversations/Christina Feelings - Mar 20 2024.md",
|
||||
"Christina/Feelings Conversations/Christina Feelings - Feb 9 2024.md",
|
||||
"Christina/Feelings Conversations/Christina Feelings June 29.md",
|
||||
"Christina/Feelings Conversations/Christina Feelings - Dec 11 2025.md",
|
||||
"Christina/Feelings Conversations/Christina Feelings - Jan 8 2026.md",
|
||||
"Home Setup/Used Ports Synology Server.md",
|
||||
"Icon\r",
|
||||
"Apple Notes/Gift ideas ChristmasBirthday.md",
|
||||
"Random & To Sort/The Tower.md",
|
||||
"Christina/Feelings Conversations/Christina Talks - May 10 2025.md",
|
||||
"Christina/Feelings Conversations",
|
||||
"Apple Notes/-250.md",
|
||||
"Apple Notes/- httpswrapbootstrap.comthememonarch-admin-responsive-angularjs….md",
|
||||
"Apple Notes/______ earli-isasmchdoes lanes lashed mmy..md",
|
||||
"Apple Notes/Christina 1/Christina Happy Mothers Day!.md",
|
||||
"Apple Notes/Christina 1/age0-14& !shiny& !shadow& !legendary& !mythical& !lucky& !hatched….md",
|
||||
"Apple Notes/Christina 1/!+mime& !+togep& !+burm& !+riolu& !+larv& !+chime& !+happ& !+sable….md",
|
||||
"Apple Notes/Animal Crossing/Ribbot.md",
|
||||
"attachments/100 1.png",
|
||||
"Apple Notes/Animal Crossing/Retro Action Items.md",
|
||||
"attachments/IMG_1115.jpeg",
|
||||
"attachments/Drawing 2.png",
|
||||
"attachments/IMG_6415.heic",
|
||||
"attachments/Drawing 1.png",
|
||||
"attachments/Drawing.png",
|
||||
"attachments/Image.png",
|
||||
"attachments/Feelings Chat 0528.jpeg",
|
||||
"attachments/Pasted Graphic 2 1.png",
|
||||
"attachments/mapstogpx202101793729.gpx",
|
||||
"attachments/FavoriteLists_iTools_202101793649.json",
|
||||
"attachments/Pasted Graphic 5.png",
|
||||
"attachments/Pasted Graphic 4.png",
|
||||
"attachments/iSpooferLicense.txt",
|
||||
"attachments/Naka.gpx",
|
||||
"attachments/Pasted Graphic 1.pdf",
|
||||
"Apple Notes/Milwaukee 2025 Staff Notes",
|
||||
"Apple Notes/Christina 1"
|
||||
]
|
||||
}
|
||||
274
docs/projects/memorypalace/TODO-challonge-oauth.md
Normal file
274
docs/projects/memorypalace/TODO-challonge-oauth.md
Normal file
@@ -0,0 +1,274 @@
|
||||
# OAuth Implementation TODO
|
||||
|
||||
This document outlines the steps needed to implement OAuth 2.0 authentication for the Challonge API v2.1.
|
||||
|
||||
## Current Status
|
||||
|
||||
✅ **Completed:**
|
||||
- API v2.1 service supports OAuth authentication (`AuthType.OAUTH`)
|
||||
- UI toggle for OAuth is present in ChallongeTest.vue (disabled)
|
||||
- Service client can accept Bearer tokens
|
||||
|
||||
🚧 **Not Implemented:**
|
||||
- OAuth authorization flow
|
||||
- Token storage and management
|
||||
- Token refresh logic
|
||||
- OAuth scope selection
|
||||
|
||||
## OAuth Flow Options
|
||||
|
||||
Challonge supports three OAuth flows. Choose based on your use case:
|
||||
|
||||
### 1. Authorization Code Flow (Recommended for Web Apps)
|
||||
**Best for:** Browser-based applications where users can authorize access
|
||||
|
||||
**Steps to Implement:**
|
||||
1. Register application at https://connect.challonge.com
|
||||
- Get `client_id` and `client_secret`
|
||||
- Set redirect URI (e.g., `http://localhost:5173/oauth/callback`)
|
||||
|
||||
2. Create OAuth authorization URL:
|
||||
```javascript
|
||||
const authUrl = `https://api.challonge.com/oauth/authorize?` +
|
||||
`client_id=${CLIENT_ID}&` +
|
||||
`redirect_uri=${REDIRECT_URI}&` +
|
||||
`response_type=code&` +
|
||||
`scope=me+tournaments:read+tournaments:write+matches:read+matches:write+participants:read+participants:write`;
|
||||
```
|
||||
|
||||
3. Redirect user to authorization URL
|
||||
4. Handle callback with authorization code
|
||||
5. Exchange code for access token:
|
||||
```javascript
|
||||
POST https://api.challonge.com/oauth/token
|
||||
Body: {
|
||||
client_id, client_secret, grant_type: "authorization_code",
|
||||
code, redirect_uri
|
||||
}
|
||||
```
|
||||
|
||||
6. Store access_token and refresh_token
|
||||
7. Use access_token with API requests
|
||||
|
||||
### 2. Device Authorization Grant Flow
|
||||
**Best for:** Devices with no browser or limited input (TVs, consoles, IoT)
|
||||
|
||||
**Steps:**
|
||||
1. Request device code
|
||||
2. Show QR code or user code to user
|
||||
3. Poll for access token while user authorizes on their phone/PC
|
||||
4. Store and use access token
|
||||
|
||||
### 3. Client Credentials Flow
|
||||
**Best for:** Server-side applications managing their own tournaments
|
||||
|
||||
**Steps:**
|
||||
1. Use client_id and client_secret to get application-scoped token
|
||||
2. Access all tournaments created via your app
|
||||
|
||||
## Available OAuth Scopes
|
||||
|
||||
- `me` - Read user details
|
||||
- `tournaments:read` - Read tournaments
|
||||
- `tournaments:write` - Create/update/delete tournaments
|
||||
- `matches:read` - Read matches
|
||||
- `matches:write` - Update matches, report scores
|
||||
- `participants:read` - Read participants
|
||||
- `participants:write` - Add/update/remove participants
|
||||
- `attachments:read` - Read match attachments
|
||||
- `attachments:write` - Upload match attachments
|
||||
- `communities:manage` - Access community resources
|
||||
- `application:organizer` - Full access to user's resources for your app
|
||||
- `application:player` - Read user's resources, register, report scores
|
||||
- `application:manage` - Full access to all tournaments connected to your app
|
||||
|
||||
## Implementation Checklist
|
||||
|
||||
### Phase 1: OAuth Setup
|
||||
- [ ] Register app at https://connect.challonge.com
|
||||
- [ ] Store client_id in environment variables
|
||||
- [ ] Store client_secret securely (backend only, never expose to frontend)
|
||||
- [ ] Add OAuth callback route to Vue Router (`/oauth/callback`)
|
||||
- [ ] Create OAuth configuration module
|
||||
|
||||
### Phase 2: Authorization Flow
|
||||
- [ ] Create OAuth composable (`useChallongeOAuth.js`)
|
||||
- [ ] Implement authorization URL generation
|
||||
- [ ] Create "Sign in with Challonge" button
|
||||
- [ ] Handle OAuth redirect and code extraction
|
||||
- [ ] Implement token exchange (requires backend proxy for client_secret)
|
||||
|
||||
### Phase 3: Token Management
|
||||
- [ ] Create secure token storage (localStorage for access token)
|
||||
- [ ] Implement token refresh logic
|
||||
- [ ] Check token expiration before requests
|
||||
- [ ] Auto-refresh expired tokens
|
||||
- [ ] Handle refresh token failure (re-authorize user)
|
||||
|
||||
### Phase 4: API Key Manager Integration
|
||||
- [ ] Update `useChallongeApiKey` composable to support OAuth tokens
|
||||
- [ ] Add OAuth token storage alongside API keys
|
||||
- [ ] Create OAuth setup wizard in API Key Manager
|
||||
- [ ] Show token expiration date and refresh status
|
||||
- [ ] Allow users to revoke OAuth access
|
||||
|
||||
### Phase 5: UI Updates
|
||||
- [ ] Enable OAuth toggle in ChallongeTest.vue
|
||||
- [ ] Add OAuth status indicator (connected/disconnected)
|
||||
- [ ] Show current OAuth scopes
|
||||
- [ ] Add "Connect with OAuth" button
|
||||
- [ ] Add "Disconnect OAuth" button
|
||||
- [ ] Show which permissions are granted
|
||||
|
||||
### Phase 6: Scope Management
|
||||
- [ ] Create scope selection UI
|
||||
- [ ] Allow users to request specific scopes
|
||||
- [ ] Show which features require which scopes
|
||||
- [ ] Handle insufficient permission errors gracefully
|
||||
|
||||
### Phase 7: Testing
|
||||
- [ ] Test authorization flow (desktop browser)
|
||||
- [ ] Test authorization flow (mobile browser)
|
||||
- [ ] Test token refresh
|
||||
- [ ] Test expired token handling
|
||||
- [ ] Test with different scope combinations
|
||||
- [ ] Test OAuth + API v1 key fallback
|
||||
- [ ] Test concurrent sessions (multiple tabs)
|
||||
|
||||
## Security Considerations
|
||||
|
||||
### Client Secret Protection
|
||||
⚠️ **CRITICAL**: Never expose `client_secret` in frontend code!
|
||||
|
||||
**Solution:** Implement backend proxy for token exchange:
|
||||
```javascript
|
||||
// Frontend requests token from your backend
|
||||
POST /api/oauth/token
|
||||
Body: { code, redirect_uri }
|
||||
|
||||
// Your backend exchanges code with Challonge
|
||||
POST https://api.challonge.com/oauth/token
|
||||
Body: { client_id, client_secret, code, ... }
|
||||
```
|
||||
|
||||
### Token Storage
|
||||
- ✅ **Access Token**: Can store in localStorage (limited lifetime)
|
||||
- ⚠️ **Refresh Token**: More sensitive, consider httpOnly cookies or secure backend storage
|
||||
- ❌ **Client Secret**: Never in frontend
|
||||
|
||||
### PKCE (Proof Key for Code Exchange)
|
||||
Consider implementing PKCE for additional security:
|
||||
- Generate `code_verifier` (random string)
|
||||
- Create `code_challenge` (SHA256 hash of verifier)
|
||||
- Send challenge with authorization request
|
||||
- Send verifier with token request
|
||||
- Prevents authorization code interception attacks
|
||||
|
||||
## Backend Requirements
|
||||
|
||||
To properly implement OAuth, you need a backend proxy for:
|
||||
|
||||
1. **Token Exchange** (requires client_secret)
|
||||
2. **Token Refresh** (requires client_secret)
|
||||
3. **Secure Storage** (optional, for refresh tokens)
|
||||
|
||||
### Minimal Backend Example (Node.js/Express)
|
||||
```javascript
|
||||
app.post('/api/oauth/token', async (req, res) => {
|
||||
const { code, redirect_uri } = req.body;
|
||||
|
||||
const response = await fetch('https://api.challonge.com/oauth/token', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
|
||||
body: new URLSearchParams({
|
||||
client_id: process.env.CHALLONGE_CLIENT_ID,
|
||||
client_secret: process.env.CHALLONGE_CLIENT_SECRET,
|
||||
grant_type: 'authorization_code',
|
||||
code,
|
||||
redirect_uri
|
||||
})
|
||||
});
|
||||
|
||||
const tokens = await response.json();
|
||||
res.json(tokens);
|
||||
});
|
||||
```
|
||||
|
||||
### Alternative: Serverless Functions
|
||||
Can use:
|
||||
- Netlify Functions
|
||||
- Vercel Edge Functions
|
||||
- Cloudflare Workers
|
||||
- AWS Lambda
|
||||
|
||||
## Token Response Format
|
||||
|
||||
```json
|
||||
{
|
||||
"access_token": "long-access-token-string",
|
||||
"token_type": "Bearer",
|
||||
"expires_in": 604800,
|
||||
"refresh_token": "long-refresh-token-string",
|
||||
"scope": "me tournaments:read tournaments:write ...",
|
||||
"created_at": 1623246724
|
||||
}
|
||||
```
|
||||
|
||||
**Note:** `expires_in` is in seconds (604800 = 1 week)
|
||||
|
||||
## Refresh Token Usage
|
||||
|
||||
When access token expires:
|
||||
```javascript
|
||||
POST https://api.challonge.com/oauth/token
|
||||
Body: {
|
||||
client_id,
|
||||
client_secret,
|
||||
grant_type: "refresh_token",
|
||||
refresh_token: "your-refresh-token"
|
||||
}
|
||||
```
|
||||
|
||||
Response includes new `access_token` and optionally a new `refresh_token`.
|
||||
|
||||
## Migration Path
|
||||
|
||||
Users with API v1 keys can continue using them with v2.1 API:
|
||||
1. API v1 keys work with `Authorization-Type: v1` header
|
||||
2. No migration required for existing users
|
||||
3. OAuth is optional but recommended for:
|
||||
- Better security (scoped permissions)
|
||||
- Acting on behalf of other users
|
||||
- Building multi-user applications
|
||||
|
||||
## Resources
|
||||
|
||||
- [Challonge API Documentation](https://challonge.apidog.io/getting-started-1726706m0)
|
||||
- [Authorization Guide](https://challonge.apidog.io/authorization-1726705m0)
|
||||
- [Developer Portal](https://connect.challonge.com/)
|
||||
- [OAuth 2.0 RFC](https://datatracker.ietf.org/doc/html/rfc6749)
|
||||
|
||||
## Estimated Implementation Time
|
||||
|
||||
- **Phase 1 (Setup):** 1-2 hours
|
||||
- **Phase 2 (Auth Flow):** 3-4 hours
|
||||
- **Phase 3 (Token Management):** 2-3 hours
|
||||
- **Phase 4 (API Integration):** 2-3 hours
|
||||
- **Phase 5-6 (UI):** 3-4 hours
|
||||
- **Phase 7 (Testing):** 2-3 hours
|
||||
|
||||
**Total:** ~15-20 hours for full OAuth implementation
|
||||
|
||||
## Priority
|
||||
|
||||
📅 **Medium Priority** - API v1 keys work fine with v2.1 API. Implement OAuth when:
|
||||
- Building features that require user-specific access
|
||||
- Need to act on behalf of multiple users
|
||||
- Want better security with scoped permissions
|
||||
- Challonge announces v1 key deprecation
|
||||
|
||||
---
|
||||
|
||||
**Status:** Not started
|
||||
**Last Updated:** 2026-01-28
|
||||
**Assigned To:** Future development
|
||||
Reference in New Issue
Block a user