Add GitLab Duo OAuth and PAT cards to Web UI#143
Add GitLab Duo OAuth and PAT cards to Web UI#143LuxVTZ wants to merge 1 commit intorouter-for-me:mainfrom
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the Web UI's authentication capabilities by introducing direct support for GitLab Duo. Previously, users, especially those on Windows or release versions, lacked a convenient way to connect GitLab Duo through the HTML interface. This change addresses that gap by providing both OAuth and Personal Access Token (PAT) based authentication methods, making it easier for users to integrate their GitLab accounts and utilize Duo's features. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
|
Related backend PR for the management endpoints and callback flow: router-for-me/CLIProxyAPIPlus#433 |
There was a problem hiding this comment.
Code Review
This pull request effectively adds support for GitLab Duo authentication through both OAuth and Personal Access Tokens (PAT). However, a high-severity security vulnerability has been identified where the OAuth client_secret is insecurely transmitted as a query parameter in a GET request during authorization initiation. This could lead to the exposure of sensitive credentials in server logs and browser history, and it is strongly recommended to transition to POST requests for sensitive data transmission. The overall implementation is well-structured, with suggestions provided to improve code readability and maintainability in the OAuthPage.tsx component.
| if (options?.clientSecret) { | ||
| params.client_secret = options.clientSecret; | ||
| } | ||
| } | ||
| return apiClient.get<OAuthStartResponse>(`/${provider}-auth-url`, { | ||
| params: Object.keys(params).length ? params : undefined | ||
| }); |
There was a problem hiding this comment.
The oauthApi.startAuth function transmits the GitLab client_secret as a query parameter in a GET request. Sensitive information such as OAuth client secrets should never be transmitted in query parameters because they are frequently logged by web servers, reverse proxies, and browser history. This exposure can lead to the compromise of the OAuth application credentials.
if (provider === 'gitlab') {
const payload: Record<string, string> = {};
if (options?.baseUrl) {
payload.base_url = options.baseUrl;
}
if (options?.clientId) {
payload.client_id = options.clientId;
}
if (options?.clientSecret) {
payload.client_secret = options.clientSecret;
}
return apiClient.post<OAuthStartResponse>(`/${provider}-auth-url`, payload);
}
return apiClient.get<OAuthStartResponse>(`/${provider}-auth-url`, {
params: Object.keys(params).length ? params : undefined
});| const res = await oauthApi.startAuth( | ||
| provider, | ||
| provider === 'gemini-cli' ? { projectId: projectId || undefined } : undefined | ||
| provider === 'gemini-cli' | ||
| ? { projectId: projectId || undefined } | ||
| : provider === 'gitlab' | ||
| ? { | ||
| baseUrl: gitlabBaseUrl || undefined, | ||
| clientId: gitlabClientId, | ||
| clientSecret: gitlabClientSecret || undefined | ||
| } | ||
| : undefined | ||
| ); |
There was a problem hiding this comment.
The nested ternary operator for constructing the options object can be hard to read and maintain. Consider refactoring this into a more explicit if/else if structure to improve clarity.
let authOptions: Parameters<typeof oauthApi.startAuth>[1];
if (provider === 'gemini-cli') {
authOptions = { projectId: projectId || undefined };
} else if (provider === 'gitlab') {
authOptions = {
baseUrl: gitlabBaseUrl || undefined,
clientId: gitlabClientId,
clientSecret: gitlabClientSecret || undefined
};
}
const res = await oauthApi.startAuth(provider, authOptions);
| onChange={(e) => | ||
| setGitlabPat((prev) => ({ | ||
| ...prev, | ||
| baseUrl: e.target.value | ||
| })) | ||
| } | ||
| placeholder={t('auth_login.gitlab_pat_base_url_placeholder')} | ||
| /> | ||
| <Input | ||
| type="password" | ||
| autoComplete="off" | ||
| label={t('auth_login.gitlab_pat_token_label')} | ||
| hint={t('auth_login.gitlab_pat_token_hint')} | ||
| value={gitlabPat.personalAccessToken} | ||
| onChange={(e) => | ||
| setGitlabPat((prev) => ({ | ||
| ...prev, | ||
| personalAccessToken: e.target.value | ||
| })) | ||
| } |
There was a problem hiding this comment.
The onChange handlers for the gitlabPat state are repetitive. To improve maintainability and reduce code duplication, you could create a generic handler function that updates a specific field in the gitlabPat state. For example, you could add this function inside your component:
const handleGitlabPatChange = (field: keyof Pick<GitLabPatState, 'baseUrl' | 'personalAccessToken'>) => (e: ChangeEvent<HTMLInputElement>) => {
setGitlabPat((prev) => ({ ...prev, [field]: e.target.value }));
};Then you can use it in your Input components like onChange={handleGitlabPatChange('baseUrl')}. This makes the code cleaner and easier to extend if more fields are added to the gitlabPat state in the future.
|
CPAMC will not adapt to CPAP |
Summary
Why
The control panel currently has no GitLab entry, so Windows/release users cannot conveniently connect GitLab Duo from the HTML UI.
Testing