Skip to content

Fully autonomous AI Agents system capable of performing complex penetration testing tasks

docs: clarify OAuth callback configuration

Mason Kim(ZINUS US_SALES)72a5671562bf
diff --git a/README.md b/README.md
index 7ddc15ba..390cead8 100644
--- a/README.md
+++ b/README.md
@@ -2331,9 +2331,38 @@ OAuth integration with GitHub and Google allows users to authenticate using thei
- Access to user profile information from GitHub/Google accounts
- Seamless integration with existing development workflows
-For using GitHub OAuth you need to create a new OAuth application in your GitHub account and set the `OAUTH_GITHUB_CLIENT_ID` and `OAUTH_GITHUB_CLIENT_SECRET` in `.env` file.
+PentAGI uses `PUBLIC_URL` as the public base URL for OAuth redirects. In the default deployment, both GitHub and Google callbacks are handled by:
-For using Google OAuth you need to create a new OAuth application in your Google account and set the `OAUTH_GOOGLE_CLIENT_ID` and `OAUTH_GOOGLE_CLIENT_SECRET` in `.env` file.
+```text
+${PUBLIC_URL}/auth/login-callback
+```
+
+For GitHub OAuth:
+
+1. Create a new OAuth App in your GitHub account.
+2. Set **Homepage URL** to your `PUBLIC_URL`.
+3. Set **Authorization callback URL** to `${PUBLIC_URL}/auth/login-callback`.
+4. Add the client credentials to your `.env` file:
+
+```bash
+PUBLIC_URL=https://pentagi.example.com
+OAUTH_GITHUB_CLIENT_ID=your_github_client_id
+OAUTH_GITHUB_CLIENT_SECRET=your_github_client_secret
+```
+
+For Google OAuth:
+
+1. Create OAuth credentials in your Google Cloud project.
+2. Use the same callback endpoint: `${PUBLIC_URL}/auth/login-callback`.
+3. Add the client credentials to your `.env` file:
+
+```bash
+PUBLIC_URL=https://pentagi.example.com
+OAUTH_GOOGLE_CLIENT_ID=your_google_client_id
+OAUTH_GOOGLE_CLIENT_SECRET=your_google_client_secret
+```
+
+Make sure `PUBLIC_URL` matches the externally accessible HTTPS address of your PentAGI instance. If the URL configured in the OAuth provider does not exactly match the callback generated by PentAGI, the provider will reject the login attempt with a redirect URI mismatch error.
### Docker Image Configuration
diff --git a/backend/docs/config.md b/backend/docs/config.md
index 26b2c342..c2a65e91 100644
--- a/backend/docs/config.md
+++ b/backend/docs/config.md
@@ -382,7 +382,7 @@ These settings control authentication mechanisms, including cookie-based session
| Option | Environment Variable | Default Value | Description |
| ----------------------- | ---------------------------- | ------------- | ------------------------------------------------------ |
| CookieSigningSalt | `COOKIE_SIGNING_SALT` | *(none)* | Salt for signing and securing cookies used in sessions |
-| PublicURL | `PUBLIC_URL` | *(none)* | Public URL for auth callbacks from OAuth providers |
+| PublicURL | `PUBLIC_URL` | *(none)* | Public base URL used to build OAuth callback URLs such as `/auth/login-callback` |
| OAuthGoogleClientID | `OAUTH_GOOGLE_CLIENT_ID` | *(none)* | Google OAuth client ID for authentication |
| OAuthGoogleClientSecret | `OAUTH_GOOGLE_CLIENT_SECRET` | *(none)* | Google OAuth client secret |
| OAuthGithubClientID | `OAUTH_GITHUB_CLIENT_ID` | *(none)* | GitHub OAuth client ID for authentication |
@@ -407,6 +407,29 @@ The authentication settings are used in `pkg/server/router.go` to set up authent
publicURL, err := url.Parse(cfg.PublicURL)
```
+ The router builds the login callback path by appending `/auth/login-callback` to this public URL:
+ ```go
+ oauthLoginCallbackURL := "/auth/login-callback"
+
+ publicURL, err := url.Parse(cfg.PublicURL)
+ if err == nil {
+ publicURL.Path = path.Join(baseURL, oauthLoginCallbackURL)
+ }
+ ```
+
+ In the default deployment, configure your OAuth providers with:
+ - **Homepage URL**: `PUBLIC_URL`
+ - **Authorization callback URL / Redirect URI**: `${PUBLIC_URL}/auth/login-callback`
+
+ Example:
+ ```bash
+ PUBLIC_URL=https://pentagi.example.com
+ OAUTH_GITHUB_CLIENT_ID=your_github_client_id
+ OAUTH_GITHUB_CLIENT_SECRET=your_github_client_secret
+ OAUTH_GOOGLE_CLIENT_ID=your_google_client_id
+ OAUTH_GOOGLE_CLIENT_SECRET=your_google_client_secret
+ ```
+
- **OAuth Provider Settings**: Used to configure authentication with Google and GitHub:
```go
// Google OAuth setup
@@ -430,6 +453,8 @@ The authentication settings are used in `pkg/server/router.go` to set up authent
}
```
+ Google and GitHub both use the same PentAGI login callback endpoint. If the URL configured in the provider console does not exactly match the generated callback URL, authentication will fail with a redirect URI mismatch error.
+
These settings are essential for:
- Secure user authentication and session management
- Supporting social login through OAuth providers