Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

fix: using new new application secret to process oauth (#1277)

h3n4l0162f586005e
diff --git a/frontend/src/store/modules/oauth.ts b/frontend/src/store/modules/oauth.ts
index fe801ad350..4f73823c22 100644
--- a/frontend/src/store/modules/oauth.ts
+++ b/frontend/src/store/modules/oauth.ts
@@ -15,11 +15,15 @@ export const useOAuthStore = defineStore("oauth", {
actions: {
// exchangeVCSTokenWithID uses "vcsId" to let the backend infer the details from an existing VCS provider.
async exchangeVCSTokenWithID({
- vcsId,
code,
+ vcsId,
+ clientId,
+ clientSecret,
}: {
- vcsId: VCSId;
code: string;
+ vcsId: VCSId;
+ clientId: string;
+ clientSecret: string;
}): Promise<OAuthToken> {
const data = (
await axios.post(`/api/oauth/vcs/exchange-token`, {
@@ -28,6 +32,8 @@ export const useOAuthStore = defineStore("oauth", {
attributes: {
code,
vcsId,
+ clientId,
+ clientSecret,
},
},
})
diff --git a/frontend/src/views/SettingWorkspaceVCSDetail.vue b/frontend/src/views/SettingWorkspaceVCSDetail.vue
index 2bc349dc66..82b5363419 100644
--- a/frontend/src/views/SettingWorkspaceVCSDetail.vue
+++ b/frontend/src/views/SettingWorkspaceVCSDetail.vue
@@ -232,8 +232,10 @@ export default defineComponent({
) {
useOAuthStore()
.exchangeVCSTokenWithID({
- vcsId: idFromSlug(props.vcsSlug),
code: payload.code,
+ vcsId: idFromSlug(props.vcsSlug),
+ clientId: state.applicationId,
+ clientSecret: state.secret,
})
.then((token: OAuthToken) => {
state.oAuthResultCallback!(token);
diff --git a/server/oauth.go b/server/oauth.go
index 2c3844c53d..eae974de71 100644
--- a/server/oauth.go
+++ b/server/oauth.go
@@ -15,9 +15,9 @@ import (
func (s *Server) registerOAuthRoutes(g *echo.Group) {
// This is a generic endpoint of exchanging access token for VCS providers. It
- // requires either the "vcsId" to infer the details from an existing VCS
- // provider or "vcsType", "instanceURL", "clientId" and "clientSecret" to
- // directly compose the request to the VCS host.
+ // requires either the "vcsId", "clientId", "clientSecret" to infer the other details
+ // from an existing VCS provider or "vcsType", "instanceURL", "clientId" and "clientSecret"
+ // to directly compose the request to the VCS host.
g.POST("/oauth/vcs/exchange-token", func(c echo.Context) error {
req := &api.VCSExchangeToken{}
if err := jsonapi.UnmarshalPayload(c.Request().Body, req); err != nil {
@@ -39,8 +39,8 @@ func (s *Server) registerOAuthRoutes(g *echo.Group) {
vcsType = vcs.Type
instanceURL = vcs.InstanceURL
oauthExchange = &common.OAuthExchange{
- ClientID: vcs.ApplicationID,
- ClientSecret: vcs.Secret,
+ ClientID: req.ClientID,
+ ClientSecret: req.ClientSecret,
Code: req.Code,
}
} else {