Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Microsoft Authentication provider as default method #78

Merged
merged 8 commits into from
Nov 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -353,4 +353,5 @@ preview-src

.eslintcache
.eslintcache.browser
*.tsbuildinfo
*.tsbuildinfo
.vscode-test-web
50 changes: 47 additions & 3 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"runtimeExecutable": "${execPath}",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}",
"--disable-extension=GitHub.vscode-pull-request-github-insiders"
"--disable-extension=GitHub.vscode-pull-request-github"
],
"skipFiles": ["<node_internals>/**/*.js", "**/node_modules/**/*.js"],
"smartStep": true,
Expand All @@ -23,6 +23,7 @@
"runtimeExecutable": "${execPath}",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}",
"--disable-extension=GitHub.vscode-pull-request-github",
"--disable-extension=GitHub.vscode-pull-request-github-insiders"
],
"skipFiles": ["<node_internals>/**/*.js", "**/node_modules/**/*.js"],
Expand All @@ -37,7 +38,7 @@
"runtimeExecutable": "${execPath}",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}",
"--disable-extension=GitHub.vscode-pull-request-github-insiders",
"--disable-extension=GitHub.vscode-pull-request-github",
],
"skipFiles": ["<node_internals>/**/*.js", "**/node_modules/**/*.js"],
"preLaunchTask": "npm: watch",
Expand All @@ -53,7 +54,7 @@
"runtimeExecutable": "${execPath}",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}",
"--disable-extension=GitHub.vscode-pull-request-github-insiders",
"--disable-extension=GitHub.vscode-pull-request-github",
],
"skipFiles": ["<node_internals>/**/*.js", "**/node_modules/**/*.js"],
"preLaunchTask": "npm: watch",
Expand All @@ -77,6 +78,49 @@
"smartStep": true,
"sourceMaps": true,
"outFiles": ["${workspaceFolder}/out/src/test/**/*.js"]
},
{
"type": "pwa-node",
"request": "launch",
"name": "Attach Web Test",
"program": "${workspaceFolder}/node_modules/@vscode/test-web/out/index.js",
"args": [
"--extensionTestsPath=dist/browser/test/index.js",
"--extensionDevelopmentPath=.",
"--browserType=chromium",
"--attach=9229"
],
"cascadeTerminateToConfigurations": [
"Launch Web Test"
],
"presentation": {
"hidden": true,
}
},
{
"type": "pwa-chrome",
"request": "launch",
"name": "Launch Web Test",
"skipFiles": [
"<node_internals>/**"
],
"port": 9229,
"resolveSourceMapLocations": [
"!**/vs/**", // exclude core vscode sources
"!**/static/build/extensions/**", // exclude built-in extensions
],
"presentation": {
"hidden": true,
}
}
],
"compounds": [
{
"name": "Debug Web Test",
"configurations": [
"Attach Web Test",
"Launch Web Test"
]
}
]
}
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

## 0.2.0
- Fixed [#68](https://github.com/ankitbko/vscode-pull-request-azdo/issues/68) - Changed the authentication mechanism from PAT to OAuth using vscode provided authentication session. This will require users to re-authenticate.

## 0.0.25

- Removed explicit check of azdo url to resolve [#55](https://github.com/ankitbko/vscode-pull-request-azdo/issues/55)
Expand Down
12 changes: 1 addition & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,23 +28,13 @@ It's easy to get started with Azure Devops Pull Requests for Visual Studio Code.
1. Reload VS Code after the installation (click the reload button next to the extension).
1. Open your desired Azure Devops repository.
1. You will need to configure the `azdoPullRequests.projectName` and `azdoPullRequests.orgUrl` setting. You can configure it in workspace settings and commit it so others in your team wouldn't need to do this configuration again. (Look at the next section to understand the format of these settings).
1. You will need to configure [PAT token in Azure Devops](https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=azure-devops&tabs=preview-page) to login. Click on _show all scopes_ and select the following scopes for the token - `Code: Read & Write`, `Pull Request Threads: Read & Write`, `Work Items: Read & Write`, `Member Entitlement Management: Read`. Read more about these scope in next section.
1. A new tab would have appeared on the activity bar on the left. Open it and click on `Sign in` button. Enter the PAT token and press enter.
1. Signin to VS Code using same Microsoft account that you use to signin to Azure Devops. Authentication will work automatically. **PAT token is no longer required**.
1. You should be good to go!

## Features

Learn all about different features of the extension in the [wiki](https://github.com/ankitbko/vscode-pull-request-azdo/wiki).

### Scopes required by PAT Token

- **Minimum**: These scopes are required for extension to access Pull Requests and Threads. Without these scopes the extension will not even start.
- `Code: Read & Write`: Required to access repository metadata and pull requests.
- `Pull Request Threads: Read & Write`: Access Pull Request comment threads.
- **Additional**: These scopes are required to experience the extension in its completeness. Without these some functionality of extension may not work or the extension may cause errors.
- `Work Items: Read & Write`: Allow to read and associate work items to a PR.
- `Member Entitlement Management: Read`: Used to search for users when adding reviewers to PR.

## Configuring the extension

#### azdoPullRequests.orgUrl
Expand Down
23 changes: 17 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
},
"enableProposedApi": false,
"preview": true,
"version": "0.0.25",
"version": "0.2.0",
"publisher": "ankitbko",
"engines": {
"vscode": "^1.53.0"
"vscode": "^1.79.0"
},
"categories": [
"Other"
Expand All @@ -29,7 +29,8 @@
"capabilities": {
"untrustedWorkspaces": {
"supported": true
}
},
"virtualWorkspaces": true
},
"contributes": {
"configuration": {
Expand Down Expand Up @@ -732,6 +733,8 @@
"scripts": {
"postinstall": "yarn update-dts",
"vscode:prepublish": "yarn run bundle",
"browsertest:preprocess": "yarn run compile && tsc ./src/test/browser/runTests.ts --outDir ./dist/browser/test --rootDir ./src/test/browser --target es6 --module commonjs",
"browsertest": "yarn run browsertest:preprocess && node ./dist/browser/test/runTests.js",
"bundle": "webpack --mode production --env esbuild",
"bundle:node": "webpack --mode production --config-name extension:node --config-name webviews",
"bundle:web": "webpack --mode production --config-name extension:webworker --config-name webviews",
Expand Down Expand Up @@ -763,12 +766,17 @@
"@types/sinon": "7.0.11",
"@types/temp": "0.8.34",
"@types/uuid": "^8.3.0",
"@types/vscode": "1.79.0",
"@types/webpack-env": "^1.16.0",
"@typescript-eslint/eslint-plugin": "4.18.0",
"@typescript-eslint/parser": "4.18.0",
"@vscode/test-electron": "^1.6.1",
"@vscode/test-web": "^0.0.8",
"assert": "2.0.0",
"browserify-zlib": "0.2.0",
"buffer": "6.0.3",
"buffer": "^6.0.3",
"chai": "^4.2.0",
"constants-browserify": "^1.0.0",
"crypto-browserify": "3.12.0",
"css-loader": "5.1.3",
"dotenv": "^8.2.0",
Expand All @@ -779,7 +787,7 @@
"eslint-plugin-import": "2.22.1",
"fork-ts-checker-webpack-plugin": "6.1.1",
"glob": "7.1.6",
"https-browserify": "1.0.0",
"https-browserify": "^1.0.0",
"jsdom": "16.4.0",
"jsdom-global": "3.0.2",
"json5": "2.2.0",
Expand All @@ -791,13 +799,14 @@
"mocha-multi-reporters": "1.1.7",
"path-browserify": "1.0.1",
"prettier": "2.2.1",
"process": "^0.11.10",
"raw-loader": "4.0.2",
"react-testing-library": "7.0.1",
"remark-gfm": "^1.0.0",
"sinon": "9.0.0",
"source-map-support": "0.5.19",
"stream-browserify": "^3.0.0",
"stream-http": "3.1.1",
"stream-http": "^3.2.0",
"style-loader": "2.0.0",
"svg-inline-loader": "^0.8.2",
"temp": "0.9.4",
Expand All @@ -807,6 +816,7 @@
"tty": "1.0.1",
"ttypescript": "^1.5.12",
"typescript": "4.2.3",
"url": "^0.11.0",
"util": "0.12.3",
"vsce": "1.87.0",
"vscode-test": "^1.5.1",
Expand All @@ -831,6 +841,7 @@
"moment": "^2.22.1",
"node-emoji": "^1.8.1",
"node-fetch": "3.0.0-beta.9",
"os-browserify": "^0.3.0",
"query-string": "^6.2.0",
"react": "^16.12.0",
"react-dom": "^16.12.0",
Expand Down
47 changes: 45 additions & 2 deletions src/@types/git.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/


import { Uri, Event, Disposable, ProviderResult } from 'vscode';
export { ProviderResult } from 'vscode';

Expand All @@ -14,6 +15,11 @@ export interface InputBox {
value: string;
}

export const enum ForcePushMode {
Force,
ForceWithLease
}

export const enum RefType {
Head,
RemoteHead,
Expand Down Expand Up @@ -130,6 +136,16 @@ export interface CommitOptions {
signoff?: boolean;
signCommit?: boolean;
empty?: boolean;
noVerify?: boolean;
requireUserConfig?: boolean;
}

export interface FetchOptions {
remote?: string;
ref?: string;
all?: boolean;
prune?: boolean;
depth?: number;
}

export interface BranchQuery {
Expand Down Expand Up @@ -190,9 +206,10 @@ export interface Repository {
removeRemote(name: string): Promise<void>;
renameRemote(name: string, newName: string): Promise<void>;

fetch(options?: FetchOptions): Promise<void>;
fetch(remote?: string, ref?: string, depth?: number): Promise<void>;
pull(unshallow?: boolean): Promise<void>;
push(remoteName?: string, branchName?: string, setUpstream?: boolean): Promise<void>;
push(remoteName?: string, branchName?: string, setUpstream?: boolean, force?: ForcePushMode): Promise<void>;

blame(path: string): Promise<string>;
log(options?: LogOptions): Promise<Commit[]>;
Expand All @@ -211,13 +228,34 @@ export interface RemoteSourceProvider {
readonly icon?: string; // codicon name
readonly supportsQuery?: boolean;
getRemoteSources(query?: string): ProviderResult<RemoteSource[]>;
getBranches?(url: string): ProviderResult<string[]>;
publishRepository?(repository: Repository): Promise<void>;
}

export interface Credentials {
readonly username: string;
readonly password: string;
}

export interface CredentialsProvider {
getCredentials(host: Uri): ProviderResult<Credentials>;
}

export interface PushErrorHandler {
handlePushError(repository: Repository, remote: Remote, refspec: string, error: Error & { gitErrorCode: GitErrorCodes }): Promise<boolean>;
}

export type APIState = 'uninitialized' | 'initialized';

export interface PublishEvent {
repository: Repository;
branch?: string;
}

export interface GitAPI {
readonly state: APIState;
readonly onDidChangeState: Event<APIState>;
readonly onDidPublish: Event<PublishEvent>;
readonly git: Git;
readonly repositories: Repository[];
readonly onDidOpenRepository: Event<Repository>;
Expand All @@ -226,7 +264,11 @@ export interface GitAPI {
toGitUri(uri: Uri, ref: string): Uri;
getRepository(uri: Uri): Repository | null;
init(root: Uri): Promise<Repository | null>;
openRepository(root: Uri): Promise<Repository | null>

registerRemoteSourceProvider(provider: RemoteSourceProvider): Disposable;
registerCredentialsProvider(provider: CredentialsProvider): Disposable;
registerPushErrorHandler(handler: PushErrorHandler): Disposable;
}

export interface GitExtension {
Expand Down Expand Up @@ -264,6 +306,7 @@ export const enum GitErrorCodes {
CantOpenResource = 'CantOpenResource',
GitNotFound = 'GitNotFound',
CantCreatePipe = 'CantCreatePipe',
PermissionDenied = 'PermissionDenied',
CantAccessRemote = 'CantAccessRemote',
RepositoryNotFound = 'RepositoryNotFound',
RepositoryIsLocked = 'RepositoryIsLocked',
Expand All @@ -282,4 +325,4 @@ export const enum GitErrorCodes {
PatchDoesNotApply = 'PatchDoesNotApply',
NoPathFound = 'NoPathFound',
UnknownPath = 'UnknownPath',
}
}
61 changes: 61 additions & 0 deletions src/@types/vscode-test-web.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#!/usr/bin/env node
export declare type BrowserType = 'chromium' | 'firefox' | 'webkit';
export declare type VSCodeVersion = 'insiders' | 'stable' | 'sources';
export interface Options {
/**
* Browser to run the test against: 'chromium' | 'firefox' | 'webkit'
*/
browserType: BrowserType;
/**
* Absolute path to folder that contains one or more extensions (in subfolders).
* Extension folders include a `package.json` extension manifest.
*/
extensionDevelopmentPath?: string;
/**
* Absolute path to the extension tests runner module.
* Can be either a file path or a directory path that contains an `index.js`.
* The module is expected to have a `run` function of the following signature:
*
* ```ts
* function run(): Promise<void>;
* ```
*
* When running the extension test, the Extension Development Host will call this function
* that runs the test suite. This function should throws an error if any test fails.
*/
extensionTestsPath?: string;
/**
* The VS Code version to use. Valid versions are:
* - `'stable'` : The latest stable build
* - `'insiders'` : The latest insiders build
* - `'sources'`: From sources, served at localhost:8080 by running `yarn web` in the vscode repo
*
* Currently defaults to `insiders`, which is latest stable insiders.
*/
version?: VSCodeVersion;
/**
* Open the dev tools.
*/
devTools?: boolean;
/**
* Do not show the browser. Defaults to `true` if a extensionTestsPath is provided, `false` otherwise.
*/
headless?: boolean;
/**
* Expose browser debugging on this port number, and wait for the debugger to attach before running tests.
*/
waitForDebugger?: number;
/**
* The folder URI to open VSCode on
*/
folderUri?: string;
}
/**
* Runs the tests in a browser.
*
* @param options The options defining browser type, extension and test location.
*/
export declare function runTests(options: Options & {
extensionTestsPath: string;
}): Promise<void>;
export declare function open(options: Options): Promise<void>;
Loading
Loading