Skip to content

Commit bcd58d6

Browse files
authored
fix: gitlab pkce auth error (#7110)
1 parent 016aca1 commit bcd58d6

File tree

4 files changed

+18
-10
lines changed

4 files changed

+18
-10
lines changed

packages/decap-cms-backend-aws-cognito-github-proxy/src/AuthenticationPage.js

-2
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,12 @@ export default class GenericPKCEAuthenticationPage extends React.Component {
2424
app_id = '',
2525
auth_endpoint = 'oauth2/authorize',
2626
auth_token_endpoint = 'oauth2/token',
27-
redirect_uri = document.location.origin + document.location.pathname,
2827
} = this.props.config.backend;
2928
this.auth = new PkceAuthenticator({
3029
base_url,
3130
auth_endpoint,
3231
app_id,
3332
auth_token_endpoint,
34-
redirect_uri,
3533
auth_token_endpoint_content_type: 'application/x-www-form-urlencoded; charset=utf-8',
3634
});
3735
// Complete authentication if we were redirected back to from the provider.

packages/decap-cms-backend-gitea/src/AuthenticationPage.js

-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ export default class GiteaAuthenticationPage extends React.Component {
2626
app_id,
2727
auth_token_endpoint: 'login/oauth/access_token',
2828
auth_token_endpoint_content_type: 'application/json; charset=utf-8',
29-
redirect_uri: document.location.origin + document.location.pathname,
3029
});
3130
// Complete authentication if we were redirected back to from the provider.
3231
this.auth.completeAuth((err, data) => {

packages/decap-cms-backend-gitlab/src/AuthenticationPage.js

+16-4
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,30 @@ const LoginButtonIcon = styled(Icon)`
1313
`;
1414

1515
const clientSideAuthenticators = {
16-
pkce: ({ base_url, auth_endpoint, app_id, auth_token_endpoint }) =>
16+
pkce: ({
17+
base_url,
18+
auth_endpoint,
19+
app_id,
20+
auth_token_endpoint}) =>
1721
new PkceAuthenticator({
1822
base_url,
1923
auth_endpoint,
2024
app_id,
2125
auth_token_endpoint,
2226
auth_token_endpoint_content_type: 'application/json; charset=utf-8',
23-
redirect_uri: document.location.origin + document.location.pathname,
2427
}),
2528

26-
implicit: ({ base_url, auth_endpoint, app_id, clearHash }) =>
27-
new ImplicitAuthenticator({ base_url, auth_endpoint, app_id, clearHash }),
29+
implicit: ({
30+
base_url,
31+
auth_endpoint,
32+
app_id,
33+
clearHash }) =>
34+
new ImplicitAuthenticator({
35+
base_url,
36+
auth_endpoint,
37+
app_id,
38+
clearHash,
39+
}),
2840
};
2941

3042
export default class GitLabAuthenticationPage extends React.Component {

packages/decap-cms-lib-auth/src/pkce-oauth.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ export default class PkceAuthenticator {
5454
this.auth_url = `${baseURL}/${authEndpoint}`;
5555
this.auth_token_url = `${baseURL}/${authTokenEndpoint}`;
5656
this.auth_token_endpoint_content_type = config.auth_token_endpoint_content_type;
57-
this.redirect_uri = trim(config.redirect_uri, '/');
5857
this.appID = config.app_id;
5958
}
6059

@@ -65,7 +64,7 @@ export default class PkceAuthenticator {
6564

6665
const authURL = new URL(this.auth_url);
6766
authURL.searchParams.set('client_id', this.appID);
68-
authURL.searchParams.set('redirect_uri', this.redirect_uri);
67+
authURL.searchParams.set('redirect_uri', document.location.origin + document.location.pathname);
6968
authURL.searchParams.set('response_type', 'code');
7069
authURL.searchParams.set('scope', options.scope);
7170

@@ -118,7 +117,7 @@ export default class PkceAuthenticator {
118117
client_id: this.appID,
119118
code,
120119
grant_type: 'authorization_code',
121-
redirect_uri: this.redirect_uri,
120+
redirect_uri: document.location.origin + document.location.pathname,
122121
code_verifier: getCodeVerifier(),
123122
};
124123

0 commit comments

Comments
 (0)