Skip to content

Commit e787ec3

Browse files
committed
Merge branch 'main' of https://github.com/foss42/apidash into pr/890
2 parents ba8b9e0 + a9546be commit e787ec3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+7925
-72
lines changed

.github/dependabot.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# To get started with Dependabot version updates, you'll need to specify which
2+
# package ecosystems to update and where the package manifests are located.
3+
# Please see the documentation for all configuration options:
4+
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
5+
6+
version: 2
7+
updates:
8+
- package-ecosystem: "pub" # See documentation for possible values
9+
directories:
10+
- "/" # Location of package manifests
11+
- "/packages/*/"
12+
schedule:
13+
interval: "monthly"

.github/workflows/aur-publish.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
name: Update AUR Package
2+
permissions:
3+
contents: read
24

35
on:
46
push:
@@ -12,7 +14,7 @@ jobs:
1214
runs-on: ubuntu-latest
1315
steps:
1416
- name: Checkout code
15-
uses: actions/checkout@v4
17+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
1618

1719
- name: Get version from pubspec
1820
id: get_version
@@ -42,7 +44,7 @@ jobs:
4244
echo "license_checksum=$LICENSE_CHECKSUM" >> $GITHUB_OUTPUT
4345
4446
- name: Publish AUR package
45-
uses: KSXGitHub/github-actions-deploy-aur@v2.7.0
47+
uses: KSXGitHub/github-actions-deploy-aur@2ac5a4c1d7035885d46b10e3193393be8460b6f1 # v4.1.1
4648
with:
4749
pkgname: apidash-bin
4850
pkgbuild: |
@@ -85,4 +87,4 @@ jobs:
8587
commit_username: ${{ secrets.AUR_USERNAME }}
8688
commit_email: ${{ secrets.AUR_EMAIL }}
8789
ssh_private_key: ${{ secrets.AUR_SSH_PRIVATE_KEY }}
88-
commit_message: "Update to version ${{ steps.get_version.outputs.version }}"
90+
commit_message: "Update to version ${{ steps.get_version.outputs.version }}"

.github/workflows/scorecard.yml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# This workflow uses actions that are not certified by GitHub. They are provided
2+
# by a third-party and are governed by separate terms of service, privacy
3+
# policy, and support documentation.
4+
5+
name: Scorecard supply-chain security
6+
on:
7+
# For Branch-Protection check. Only the default branch is supported. See
8+
# https://github.com/ossf/scorecard/blob/main/docs/checks.md#branch-protection
9+
branch_protection_rule:
10+
# To guarantee Maintained check is occasionally updated. See
11+
# https://github.com/ossf/scorecard/blob/main/docs/checks.md#maintained
12+
schedule:
13+
- cron: '30 5 1 * *'
14+
push:
15+
branches: [ "main" ]
16+
17+
# Declare default permissions as read only.
18+
permissions: read-all
19+
20+
jobs:
21+
analysis:
22+
name: Scorecard analysis
23+
runs-on: ubuntu-latest
24+
# `publish_results: true` only works when run from the default branch. conditional can be removed if disabled.
25+
if: github.event.repository.default_branch == github.ref_name || github.event_name == 'pull_request'
26+
permissions:
27+
# Needed to upload the results to code-scanning dashboard.
28+
security-events: write
29+
# Needed to publish results and get a badge (see publish_results below).
30+
id-token: write
31+
# Uncomment the permissions below if installing in a private repository.
32+
# contents: read
33+
# actions: read
34+
35+
steps:
36+
- name: "Checkout code"
37+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
38+
with:
39+
persist-credentials: false
40+
41+
- name: "Run analysis"
42+
uses: ossf/scorecard-action@f49aabe0b5af0936a0987cfb85d86b75731b0186 # v2.4.1
43+
with:
44+
results_file: results.sarif
45+
results_format: sarif
46+
# (Optional) "write" PAT token. Uncomment the `repo_token` line below if:
47+
# - you want to enable the Branch-Protection check on a *public* repository, or
48+
# - you are installing Scorecard on a *private* repository
49+
# To create the PAT, follow the steps in https://github.com/ossf/scorecard-action?tab=readme-ov-file#authentication-with-fine-grained-pat-optional.
50+
# repo_token: ${{ secrets.SCORECARD_TOKEN }}
51+
52+
# Public repositories:
53+
# - Publish results to OpenSSF REST API for easy access by consumers
54+
# - Allows the repository to include the Scorecard badge.
55+
# - See https://github.com/ossf/scorecard-action#publishing-results.
56+
# For private repositories:
57+
# - `publish_results` will always be set to `false`, regardless
58+
# of the value entered here.
59+
publish_results: true
60+
61+
# (Optional) Uncomment file_mode if you have a .gitattributes with files marked export-ignore
62+
# file_mode: git
63+
64+
# Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF
65+
# format to the repository Actions tab.
66+
- name: "Upload artifact"
67+
uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1
68+
with:
69+
name: SARIF file
70+
path: results.sarif
71+
retention-days: 5
72+
73+
# Upload the results to GitHub's code scanning dashboard (optional).
74+
# Commenting out will disable upload of results to your repo's Code Scanning dashboard
75+
- name: "Upload to code-scanning"
76+
uses: github/codeql-action/upload-sarif@v3
77+
with:
78+
sarif_file: results.sarif

doc/dev_guide/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
4. [Integration Testing](https://github.com/foss42/apidash/blob/main/doc/dev_guide/integration_testing.md)
77
5. [List of API Endpoints for Testing](https://github.com/foss42/apidash/blob/main/doc/dev_guide/api_endpoints_for_testing.md)
88
6. [Packaging API Dash](https://github.com/foss42/apidash/blob/main/doc/dev_guide/packaging.md)
9-
7. Other Topics
9+
7. [OAuth Authentication Limitations](https://github.com/foss42/apidash/blob/main/doc/dev_guide/oauth_authentication_limitations.md)
10+
8. Other Topics
1011
- [Flutter Rust Bridge Experiment for Parsing Hurl](https://github.com/foss42/apidash/blob/main/doc/dev_guide/flutter_rust_bridge_experiment.md)
1112

1213
## Code Walkthrough for New Contributors
Lines changed: 182 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,182 @@
1+
# OAuth Authentication Limitations
2+
3+
This document outlines the current limitations and implementation details of OAuth authentication in API Dash.
4+
5+
## Table of Contents
6+
7+
1. [OAuth2 Limitations](#oauth2-limitations)
8+
2. [OAuth1 Limitations](#oauth1-limitations)
9+
3. [Platform-Specific Behavior](#platform-specific-behavior)
10+
4. [Technical Implementation Details](#technical-implementation-details)
11+
5. [Workarounds](#workarounds)
12+
6. [Future Improvements](#future-improvements)
13+
14+
## OAuth2 Limitations
15+
16+
### Response Format Restriction
17+
18+
**Limitation**: OAuth2 implementation only supports `application/json` response format as specified in [RFC 6749, Section 5.1](https://tools.ietf.org/html/rfc6749#section-5.1).
19+
20+
**Details**:
21+
- The OAuth2 client automatically sets the `Accept: application/json` header for token requests
22+
- Servers that return token responses in other formats (e.g., `application/x-www-form-urlencoded`, `text/plain`) are not supported
23+
- This is enforced by the `_JsonAcceptClient` wrapper in the HTTP client manager
24+
25+
**Impact**:
26+
- Some legacy OAuth2 providers that don't return JSON responses will fail
27+
- Non-standard OAuth2 implementations may not work correctly
28+
29+
**Code Reference**:
30+
```dart
31+
// In HttpClientManager.createClientWithJsonAccept()
32+
class _JsonAcceptClient extends http.BaseClient {
33+
@override
34+
Future<http.StreamedResponse> send(http.BaseRequest request) {
35+
request.headers['Accept'] = 'application/json';
36+
return _inner.send(request);
37+
}
38+
}
39+
```
40+
41+
### Port Range Limitation (Desktop Only)
42+
43+
**Limitation**: For desktop platforms, the OAuth2 callback server requires at least one free port in the range 8080-8090.
44+
45+
**Details**:
46+
- The callback server attempts to bind to ports starting from 8080
47+
- If all ports in the range (8080-8090) are occupied, the OAuth flow will fail
48+
- This only affects desktop platforms (macOS, Windows, Linux)
49+
50+
**Impact**:
51+
- Users running other services on these ports may experience OAuth failures
52+
- Development environments with multiple applications may conflict
53+
54+
**Code Reference**:
55+
```dart
56+
// In OAuthCallbackServer.start()
57+
for (int port = 8080; port <= 8090; port++) {
58+
try {
59+
_server = await HttpServer.bind(InternetAddress.loopbackIPv4, port);
60+
_port = port;
61+
break;
62+
} catch (e) {
63+
if (port == 8090) {
64+
throw Exception('Unable to find available port for OAuth callback server');
65+
}
66+
}
67+
}
68+
```
69+
70+
## OAuth1 Limitations
71+
72+
### Incomplete Flow Implementation
73+
74+
**Limitation**: OAuth1 implementation does not handle the complete OAuth1 authorization flow.
75+
76+
**Details**:
77+
- The implementation assumes that the necessary steps to obtain the access token have already been performed manually or through a backend service
78+
- Users must provide pre-obtained access tokens and token secrets
79+
- The three-legged OAuth1 flow (request token → user authorization → access token) is not implemented
80+
- This aligns with the behavior in other API clients such as Postman and Insomnia
81+
82+
**Impact**:
83+
- Users cannot complete OAuth1 authentication entirely within API Dash
84+
- External tools or manual processes are required to obtain tokens
85+
- Limited to scenarios where tokens are already available
86+
87+
**Workaround**:
88+
Users need to:
89+
1. Obtain request tokens from the OAuth1 provider
90+
2. Complete user authorization outside of API Dash
91+
3. Exchange the authorized request token for an access token
92+
4. Manually enter the access token and token secret in API Dash
93+
94+
## Platform-Specific Behavior
95+
96+
### Redirect URI Handling
97+
98+
**Mobile Platforms (iOS, Android)**:
99+
- **Default Redirect URI**: `apidash://oauth2`
100+
- **Mechanism**: Uses `flutter_web_auth_2` with custom URL scheme
101+
- **User Experience**: Opens authorization in a WebView within the app
102+
103+
**Desktop Platforms (macOS, Windows, Linux)**:
104+
- **Default Redirect URI**: `http://localhost:{port}/callback`
105+
- **Port Range**: 8080-8090 (automatically selects first available port)
106+
- **Mechanism**: Opens authorization in the system's default browser
107+
- **User Experience**: External browser window with automatic callback handling
108+
109+
**Code Reference**:
110+
```dart
111+
// Platform detection logic
112+
static bool get shouldUseLocalhostCallback => isDesktop;
113+
114+
// Redirect URL determination
115+
if (PlatformUtils.shouldUseLocalhostCallback) {
116+
callbackServer = OAuthCallbackServer();
117+
final localhostUrl = await callbackServer.start();
118+
actualRedirectUrl = Uri.parse(localhostUrl);
119+
} else {
120+
// Use custom scheme for mobile
121+
actualRedirectUrl = redirectUrl; // apidash://oauth2
122+
}
123+
```
124+
125+
## Technical Implementation Details
126+
127+
### Grant Types Supported
128+
129+
**OAuth2**:
130+
- ✅ Authorization Code Grant
131+
- ✅ Client Credentials Grant
132+
- ✅ Resource Owner Password Grant
133+
- ❌ Implicit Grant (deprecated by OAuth2.1)
134+
- ❌ Device Authorization Grant
135+
136+
**OAuth1**:
137+
- ✅ Manual token entry (post-authorization)
138+
- ❌ Automated three-legged flow
139+
140+
### PKCE Support
141+
142+
**Status**: ✅ Supported for Authorization Code Grant
143+
- Code Challenge Method: SHA-256 or Plaintext
144+
- Automatically generates code verifier and challenge
145+
- Configurable through the UI
146+
147+
### Token Storage
148+
149+
**Mechanism**: File-based credential storage
150+
- **Location**: `{workspaceFolderPath}/oauth2_credentials.json`
151+
- **Format**: JSON with access token, refresh token, expiration time
152+
- **Security**: Stored as plain text (limitation for local development tool)
153+
154+
**Auto-refresh**: ✅ Supported
155+
- Automatically refreshes expired tokens using refresh tokens
156+
- Updates stored credentials file
157+
158+
## Workarounds
159+
160+
### For Non-JSON OAuth2 Responses
161+
162+
If you encounter an OAuth2 provider that doesn't return JSON responses:
163+
164+
1. **Contact the provider** to request JSON support (recommended)
165+
2. **Use a proxy server** to convert the response format
166+
3. **Consider alternative authentication methods** if available
167+
168+
### For Port Conflicts on Desktop
169+
170+
If ports 8080-8090 are occupied:
171+
172+
1. **Stop conflicting services** temporarily during OAuth flow
173+
2. **Use mobile platform** for OAuth authentication if possible
174+
3. **Configure OAuth provider** to use a different callback URL (if supported)
175+
176+
## Related Documentation
177+
178+
- [Setup and Run Guide](setup_run.md)
179+
- [Platform-Specific Instructions](platform_specific_instructions.md)
180+
- [Testing Guide](testing.md)
181+
- [OAuth2 RFC 6749](https://tools.ietf.org/html/rfc6749)
182+
- [OAuth1 RFC 5849](https://tools.ietf.org/html/rfc5849)

0 commit comments

Comments
 (0)