This repository has been archived by the owner on Apr 4, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 110
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Apply GitHub authentication plugin (#604)
Add a plugin that authenticates vscode GitHub PR plugin launched in Che-Theia The plugin calls Che oAuth API service to get the GitHub token. Then it injects it to the user preferences. When the browser page is refreshed the vscode GitHub PR plugin fetches the token and cleans the token from the preferences file.
- Loading branch information
Showing
14 changed files
with
172 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
lib/ | ||
node_modules/ | ||
*.theia |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Theia - vscode Github pull-request plugin authenticator | ||
|
||
The plugin calls Che oAuth API service to get the GitHub token. | ||
Then it injects it to the user preferences. When the browser page is refreshed, | ||
the vscode GitHub PR plugin fetches the token and cleans the token from the preferences file. | ||
|
||
## License | ||
|
||
[EPL-2.0](http://www.eclipse.org/legal/epl-2.0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
{ | ||
"name": "@eclipse-che/github-auth-plugin", | ||
"version": "0.0.1", | ||
"publisher": "Eclipse Che", | ||
"keywords": [ | ||
"theia-plugin" | ||
], | ||
"description": "Authenticates the vscode Github pull-request plugin", | ||
"license": "EPL-2.0", | ||
|
||
"files": [ | ||
"src" | ||
], | ||
"activationEvents": [ | ||
"*" | ||
], | ||
"devDependencies": { | ||
"@theia/plugin": "next", | ||
"@theia/plugin-packager": "latest", | ||
"@eclipse-che/plugin": "0.0.1", | ||
"rimraf": "2.6.2", | ||
"typescript-formatter": "7.2.2", | ||
"typescript": "2.9.2", | ||
"ts-loader": "^4.1.0" | ||
}, | ||
"scripts": { | ||
"prepare": "yarn run clean && yarn run build", | ||
"clean": "rimraf lib", | ||
"format": "tsfmt -r --useTsfmt ../../configs/tsfmt.json", | ||
"lint": "tslint -c ../../configs/tslint.json --project tsconfig.json", | ||
"lint:fix": "tslint -c ../../configs/tslint.json --fix --project .", | ||
"compile": "tsc", | ||
"build": "yarn lint:fix && concurrently -n \"format,lint,compile\" -c \"red,green,blue\" \"yarn format\" \"yarn lint\" \"yarn compile\" && theia-plugin pack", | ||
"watch": "tsc -w" | ||
}, | ||
"engines": { | ||
"theiaPlugin": "next" | ||
}, | ||
"theiaPlugin": { | ||
"backend": "lib/github-auth-plugin.js" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/********************************************************************* | ||
* Copyright (c) 2020 Red Hat, Inc. | ||
* | ||
* This program and the accompanying materials are made | ||
* available under the terms of the Eclipse Public License 2.0 | ||
* which is available at https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
**********************************************************************/ | ||
|
||
import * as theia from '@theia/plugin'; | ||
import * as che from '@eclipse-che/plugin'; | ||
|
||
export function start(context: theia.PluginContext) { | ||
if (theia.plugins.getPlugin('github.vscode-pull-request-github')) { | ||
const command = { | ||
id: 'github-plugin-authenticate', | ||
label: 'GitHub authenticate' | ||
}; | ||
context.subscriptions.push(theia.commands.registerCommand(command, async () => { | ||
const token = await che.github.getToken(); | ||
const conf = await theia.workspace.getConfiguration(); | ||
await conf.update('githubPullRequests.hosts', [{ | ||
host: 'github.com', | ||
token | ||
}], theia.ConfigurationTarget.Global); | ||
theia.window.showWarningMessage('GitHub token has been set to preferences. ' + | ||
'Refresh the page to reinitialise the vscode GitHub pull-request plugin with the token'); | ||
})); | ||
} | ||
} | ||
|
||
export function stop() { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"extends": "../../configs/base.tsconfig", | ||
"compilerOptions": { | ||
"skipLibCheck": true, | ||
"lib": [ | ||
"es6", | ||
"webworker" | ||
], | ||
"rootDir": "src", | ||
"outDir": "lib" | ||
}, | ||
"include": [ | ||
"src" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"baseIndentSize": 0, | ||
"newLineCharacter": "\n", | ||
"indentSize": 4, | ||
"tabSize": 4, | ||
"indentStyle": 4, | ||
"convertTabsToSpaces": true, | ||
"insertSpaceAfterCommaDelimiter": true, | ||
"insertSpaceAfterSemicolonInForStatements": true, | ||
"insertSpaceBeforeAndAfterBinaryOperators": true, | ||
"insertSpaceAfterKeywordsInControlFlowStatements": true, | ||
"insertSpaceAfterFunctionKeywordForAnonymousFunctions": false, | ||
"insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis": false, | ||
"insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets": false, | ||
"insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces": false, | ||
"placeOpenBraceOnNewLineForFunctions": false, | ||
"placeOpenBraceOnNewLineForControlBlocks": false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters