Skip to content

Commit 1a9f955

Browse files
committed
chore: replace clientSecret in github ci
1 parent 7212e11 commit 1a9f955

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

.github/workflows/marketplace-publish.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ jobs:
3333
- run: npm i -g vsce
3434
# replace client_id
3535
- run: sed -i "s/clientId:\ 'vscode-cnb'/clientId:\ '${{ secrets.OAUTHCLIENTID }}'/" src/models/config.ts
36+
# replace client_secret
37+
- run: sed -i "s/clientId:\ ''/clientSecret:\ '${{ secrets.OAUTHCLIENTSECRET }}'/" src/models/config.ts
3638
- run: echo "src/models/config.ts\n" && cat src/models/config.ts
3739
# use env.VERSION to replace version property in package.json
3840
- run: sed -i 's/\"version\":\ \"[0-9]\.[0-9]\.[0-9]\"/\"version\":\ \"${{ env.VERSION }}\"/' package.json

src/models/config.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1+
import { env } from 'process';
2+
13
export interface IConfig {
24
oauth: {
35
authority: string;
46
tokenEndpoint: string;
57
authorizeEndpoint: string;
68
userInfoEndpoint: string;
79
clientId: string;
10+
clientSecret: string;
811
responseType: string;
912
scope: string;
1013
revocationEndpoint: string;
@@ -23,6 +26,7 @@ export const defaultConfig: IConfig = {
2326
authorizeEndpoint: '/connect/authorize',
2427
userInfoEndpoint: '/connect/userinfo',
2528
clientId: 'vscode-cnb',
29+
clientSecret: '',
2630
responseType: 'code',
2731
scope: 'openid profile CnBlogsApi CnblogsAdminApi',
2832
revocationEndpoint: '/connection/revocation',
@@ -32,7 +36,9 @@ export const defaultConfig: IConfig = {
3236

3337
export const devConfig = Object.assign({}, defaultConfig, {
3438
oauth: Object.assign({}, defaultConfig.oauth, {
35-
authority: 'https://my-oauth.cnblogs.com',
39+
authority: env.Authority ? env.Authority : 'https://my-oauth.cnblogs.com',
40+
clientId: env.ClientId ? env.ClientId : 'vscode-cnb',
41+
clientSecret: env.ClientSecret ? env.ClientSecret : '',
3642
}),
3743
apiBaseUrl: 'https://admin.cnblogs.com',
3844
});

src/services/account.service.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export class AccountService extends vscode.Disposable {
4444
this.handleAuthorized(authorizationInfo);
4545
}
4646
});
47-
const { clientId, responseType, scope, authorizeEndpoint, authority } = globalState.config.oauth;
47+
const { clientId, responseType, scope, authorizeEndpoint, authority, clientSecret } = globalState.config.oauth;
4848
let url = `${authority}${authorizeEndpoint}`;
4949
const search = new URLSearchParams([
5050
['client_id', clientId],
@@ -54,6 +54,7 @@ export class AccountService extends vscode.Disposable {
5454
['code_challenge', codeChallenge],
5555
['code_challenge_method', 'S256'],
5656
['scope', scope],
57+
['client_secret', clientSecret],
5758
]);
5859
url = `${url}?${search}`;
5960
await vscode.commands.executeCommand('vscode.open', vscode.Uri.parse(url));

0 commit comments

Comments
 (0)