Skip to content

Commit 7ad55fb

Browse files
authored
Merge pull request #409 from microsoft/main
Cut new release
2 parents 27fbadc + 7fe5379 commit 7ad55fb

File tree

26 files changed

+622
-126
lines changed

26 files changed

+622
-126
lines changed

.github/ISSUE_TEMPLATE/auth-problem.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ assignees: ''
88

99
**Which version of GCM Core are you using?**
1010

11-
From a terminal, run `git-credential-manager-core version` and paste the output.
11+
From a terminal, run `git-credential-manager-core --version` and paste the output.
1212

1313
<!-- Ex:
1414
Git Credential Manager version 2.0.8-beta+e1f8492d04 (macOS, .NET Core 4.6.27129.04)

.github/ISSUE_TEMPLATE/experimental.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ assignees: ''
88

99
**Which version of GCM Core are you using?**
1010

11-
From a terminal, run `git-credential-manager-core version` and paste the output.
11+
From a terminal, run `git-credential-manager-core --version` and paste the output.
1212

1313
<!-- Ex:
1414
Git Credential Manager version 2.0.8-beta+e1f8492d04 (macOS, .NET Core 4.6.27129.04)

.github/configure_repoclient.py

Lines changed: 0 additions & 35 deletions
This file was deleted.

.github/fetch_release.py

Lines changed: 0 additions & 49 deletions
This file was deleted.

.github/workflows/release-apt-get.yml

Lines changed: 59 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,47 +6,90 @@ on:
66
workflow_dispatch:
77
inputs:
88
release:
9-
description: 'Release Tag'
9+
description: 'Release Id'
1010
required: true
1111
default: 'latest'
1212

1313
jobs:
1414
release:
1515
runs-on: ubuntu-latest
1616
steps:
17-
- name: setup python
18-
uses: actions/setup-python@v2
19-
with:
20-
python-version: 3.8
21-
2217
- uses: actions/checkout@v2
2318

2419
- uses: azure/login@v1
2520
with:
2621
creds: ${{ secrets.AZURE_CREDENTIALS }}
2722

28-
- name: 'Download Repo Client'
23+
- name: "Download Repo Client"
2924
env:
3025
AZ_SUB: ${{ secrets.AZURE_SUBSCRIPTION }}
3126
run: |
3227
az storage blob download --subscription "$AZ_SUB" --account-name gitcitoolstore -c tools -n azure-repoapi-client_2.0.1_amd64.deb -f repoclient.deb --auth-mode login
3328
3429
- name: "Install Repo Client"
35-
env:
36-
APT_REPO_ID: ${{ secrets.APT_REPO_ID }}
37-
AZURE_AAD_ID: ${{ secrets.AZURE_AAD_ID }}
38-
AAD_CLIENT_SECRET: ${{ secrets.AAD_CLIENT_SECRET }}
3930
run: |
4031
sudo apt-get install python3-adal --yes
4132
sudo dpkg -i repoclient.deb
42-
python .github/configure_repoclient.py
4333
rm repoclient.deb
4434
35+
- name: "Configure Repo Client"
36+
uses: actions/github-script@v3
37+
env:
38+
AZURE_AAD_ID: ${{ secrets.AZURE_AAD_ID }}
39+
AAD_CLIENT_SECRET: ${{ secrets.AAD_CLIENT_SECRET }}
40+
with:
41+
script: |
42+
for (const key of ['AZURE_AAD_ID', 'AAD_CLIENT_SECRET']) {
43+
if (!process.env[key]) throw new Error(`Required env var ${key} is missing!`)
44+
}
45+
const config = {
46+
AADResource: 'https://microsoft.onmicrosoft.com/945999e9-da09-4b5b-878f-b66c414602c0',
47+
AADTenant: '72f988bf-86f1-41af-91ab-2d7cd011db47',
48+
AADAuthorityUrl: 'https://login.microsoftonline.com',
49+
server: 'azure-apt-cat.cloudapp.net',
50+
port: '443',
51+
AADClientId: process.env.AZURE_AAD_ID,
52+
AADClientSecret: process.env.AAD_CLIENT_SECRET,
53+
repositoryId: ''
54+
}
55+
const fs = require('fs')
56+
fs.writeFileSync('config.json', JSON.stringify(config, null, 2))
57+
58+
- name: "Get Release Asset"
59+
id: get-asset
60+
env:
61+
RELEASE: ${{ github.event.inputs.release }}
62+
uses: actions/github-script@v3
63+
with:
64+
github-token: ${{secrets.GITHUB_TOKEN}}
65+
script: |
66+
const { data } = await github.repos.getRelease({
67+
owner: context.repo.owner,
68+
repo: context.repo.repo,
69+
release_id: process.env.RELEASE || 'latest'
70+
})
71+
const assets = data.assets.filter(asset => asset.name.endsWith('.deb'))
72+
if (assets.length !== 1) {
73+
throw new Error(`Unexpected number of .deb assets: ${assets.length}`)
74+
}
75+
const fs = require('fs')
76+
const buffer = await github.repos.getReleaseAsset({
77+
headers: {
78+
accept: 'application/octet-stream'
79+
},
80+
owner: context.repo.owner,
81+
repo: context.repo.repo,
82+
asset_id: assets[0].id
83+
})
84+
console.log(buffer)
85+
fs.writeFileSync(assets[0].name, Buffer.from(buffer.data))
86+
core.setOutput('name', assets[0].name)
87+
4588
- name: "Publish to apt feed"
4689
env:
4790
RELEASE: ${{ github.event.inputs.release }}
4891
run: |
49-
pip install requests
50-
python .github/fetch_release.py
51-
wget "$(cat asset_url.txt)"
52-
repoclient -v v3 -c config.json package add --check --wait 300 "$(cat asset_name.txt)"
92+
for id in ${{ secrets.BIONIC_REPO_ID }} ${{ secrets.HIRSUTE_REPO_ID }}
93+
do
94+
repoclient -v v3 -c config.json package add --check --wait 300 "${{steps.get-asset.outputs.name}}" -r $id
95+
done

.github/workflows/release-winget.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,11 @@ jobs:
2121
Publisher: Microsoft Corporation
2222
Moniker: git-credential-manager-core
2323
PackageUrl: https://aka.ms/gcmcore
24-
Tags: [ gcm, gcmcore, git, credential ]
24+
Tags:
25+
- gcm
26+
- gcmcore
27+
- git
28+
- credential
2529
License: Copyright (C) Microsoft Corporation
2630
ShortDescription: Secure, cross-platform Git credential storage with authentication to GitHub, Azure Repos, and other popular Git hosting services.
2731
Installers:

README.md

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,35 @@ sudo /usr/local/share/gcm-core/uninstall.sh
8686

8787
---
8888

89-
### Linux Debian package (.deb)
89+
<!-- this explicit anchor should stay stable so that external docs can link here -->
90+
<a name="linux-install-instructions"></a>
91+
### Linux
92+
93+
#### Debian package (.deb)
94+
95+
`apt-get` support is available for Ubuntu Bionic Beaver (18.04) and Hirsute
96+
Hippo (21.04). Take the following steps to set up and install based on the
97+
version you are running:
98+
99+
#### Ubuntu 18.04 (Bionic)
100+
101+
```shell
102+
curl -sSL https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
103+
sudo apt-add-repository https://packages.microsoft.com/ubuntu/18.04/prod
104+
sudo apt-get update
105+
sudo apt-get install gcmcore
106+
```
107+
108+
#### Ubuntu 21.04 (Hirsute)
109+
110+
```shell
111+
curl -sSL https://packages.microsoft.com/config/ubuntu/21.04/prod.list | sudo tee /etc/apt/sources.list.d/microsoft-prod.list
112+
curl -sSL https://packages.microsoft.com/keys/microsoft.asc | sudo tee /etc/apt/trusted.gpg.d/microsoft.asc
113+
sudo apt-get update
114+
sudo apt-get install gcmcore
115+
```
116+
117+
#### Other Ubuntu/Debian distributions
90118

91119
Download the latest [.deb package](https://github.com/microsoft/Git-Credential-Manager-Core/releases/latest), and run the following:
92120

@@ -97,9 +125,7 @@ git-credential-manager-core configure
97125

98126
Note that Linux distributions [require additional configuration](https://aka.ms/gcmcore-linuxcredstores) to use GCM Core.
99127

100-
---
101-
102-
### Linux tarball (.tar.gz)
128+
#### Other distributions
103129

104130
Download the latest [tarball](https://github.com/microsoft/Git-Credential-Manager-Core/releases/latest), and run the following:
105131

@@ -144,8 +170,11 @@ To uninstall, open Control Panel and navigate to the Programs and Features scree
144170

145171
## How to use
146172

147-
Git Credential Manager Core is called implicitly by Git, when so configured. It is not intended to be called directly by the user.
148-
For example, when pushing (`git push`) to [Azure DevOps](https://dev.azure.com), a window is automatically opened and an OAuth2 flow is started to get your personal access token.
173+
Once it's installed and configured, Git Credential Manager Core is called implicitly by Git.
174+
You don't have to do anything special, and GCM Core isn't intended to be called directly by the user.
175+
For example, when pushing (`git push`) to [Azure DevOps](https://dev.azure.com), [Bitbucket](https://bitbucket.org), or [GitHub](https://github.com), a window will automatically open and walk you through the sign-in process.
176+
(This process will look slightly different for each Git host, and even in some cases, whether you've connected to an on-premises or cloud-hosted Git host.)
177+
Later Git commands in the same repository will re-use existing credentials or tokens that GCM Core has stored for as long as they're valid.
149178

150179
Read full command line usage [here](docs/usage.md).
151180

@@ -160,6 +189,7 @@ See detailed information [here](https://aka.ms/gcmcore-httpproxy).
160189
- [Command-line usage](docs/usage.md)
161190
- [Configuration options](docs/configuration.md)
162191
- [Environment variables](docs/environment.md)
192+
- [Enterprise configuration](docs/enterprise-config.md)
163193
- [Network and HTTP configuration](docs/netconfig.md)
164194
- [Architectural overview](docs/architecture.md)
165195
- [Host provider specification](docs/hostprovider.md)

docs/bitbucket-development.md

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# Bitbucket Authentication, 2FA and OAuth
2+
3+
By default for authenticating against private Git repositories Bitbucket supports SSH and username/password Basic Auth over HTTPS.
4+
Username/password Basic Auth over HTTPS is also available for REST API access.
5+
Additionally Bitbucket supports App-specific passwords which can be used via Basic Auth as username/app-specific-password.
6+
7+
To enhance security Bitbucket offers optional Two-Factor Authentication (2FA). When 2FA is enabled username/password Basic Auth access to the REST APIs and to Git repositories is suspended.
8+
At that point users are left with the choice of username/apps-specific-password Basic Auth for REST APIs and Git interactions, OAuth for REST APIs and Git/Hg interactions or SSH for Git/HG interactions and one of the previous choices for REST APIs.
9+
SSH and REST API access are beyond the scope of this document.
10+
Read about [Bitbucket's 2FA implementation](https://confluence.atlassian.com/bitbucket/two-step-verification-777023203.html).
11+
12+
App-specific passwords are not particularly user friendly as once created Bitbucket hides their value, even from the owner.
13+
They are intended for use within application that talk to Bitbucket where application can remember and use the app-specific-password.
14+
[Additional information](https://confluence.atlassian.com/display/BITBUCKET/App+passwords).
15+
16+
OAuth is the intended authentication method for user interactions with HTTPS remote URL for Git repositories when 2FA is active.
17+
Essentially once a client application has an OAuth access token it can be used in place of a user's password.
18+
Read more about information [Bitbucket's OAuth implementation](https://confluence.atlassian.com/bitbucket/oauth-on-bitbucket-cloud-238027431.html).
19+
20+
Bitbucket's OAuth implementation follows the standard specifications for OAuth 2.0, which is out of scope for this document.
21+
However it implements a comparatively rare part of OAuth 2.0 Refresh Tokens.
22+
Bitbucket's Access Token's expire after 1 hour if not revoked, as opposed to GitHub's that expire after 1 year.
23+
When GitHub's Access Tokens expire the user must anticipate in the standard OAuth authentication flow to get a new Access Token. Since this occurs, in theory, once per year this is not too onerous.
24+
Since Bitbucket's Access Tokens expire every hour it is too much to expect a user to go through the OAuth authentication flow every hour.
25+
Bitbucket implements refresh Tokens.
26+
Refresh Tokens are issued to the client application at the same time as Access Tokens.
27+
They can only be used to request a new Access Token, and then only if they have not been revoked.
28+
As such the support for Bitbucket and the use of its OAuth in the Git Credentials Manager differs significantly from how VSTS and GitHub are implemented.
29+
This is explained in more detail below.
30+
31+
## Multiple User Accounts
32+
33+
Unlike the GitHub implementation within the Git Credential Manager, the Bitbucket implementation stores 'secrets', passwords, app-specific passwords, or OAuth tokens, with usernames in the [Windows Credential Manager](https://msdn.microsoft.com/en-us/library/windows/desktop/aa374792(v=vs.85).aspx) vault.
34+
35+
Depending on the circumstances this means either saving an explicit username in to the Windows Credential Manager/Vault or including the username in the URL used as the identifying key of entries in the Windows Credential Manager vault, i.e. using a key such as `git:https://[email protected]/` rather than `git:https://bitbucket.org`.
36+
This means that the Bitbucket implementation in the GCM can support multiple accounts, and usernames, for a single user against Bitbucket, e.g. a personal account and a work account.
37+
38+
## Authentication User Experience
39+
40+
When the GCM is triggered by Git, the GCM will check the `host` parameter passed to it.
41+
If it contains `bitbucket.org` it will trigger the Bitbucket related processes.
42+
43+
### Basic Authentication
44+
45+
If the GCM needs to prompt the user for credentials they will always be shown an initial dialog where they can enter a username and password. If the `username` parameter was passed into the GCM it is used to pre-populate the username field, although it can be overridden.
46+
When username and password credentials are submitted the GCM will use them to attempt to retrieve a token, for Basic Authentication this token is in effect the password the user just entered.
47+
The GCM retrieves this `token` by checking the password can be used to successfully retrieve the User profile via the Bitbucket REST API.
48+
49+
If the username and password credentials sent as Basic Authentication credentials works, then the password is identified as the token. The credentials, the username and the password/token, are then stored and the values returned to Git.
50+
51+
If the request for the User profile via the REST API fails with a 401 return code it indicates the username/password combination is invalid, nothing is stored and nothing is returned to Git.
52+
53+
However if the request fails with a 403 (Forbidden) return code, this indicates that the username and password are valid but 2FA is enabled on the Bitbucket Account.
54+
When this occurs the user it prompted to complete the OAuth authentication process.
55+
56+
### OAuth
57+
58+
OAuth authentication prompts the User with a new dialog where they can trigger OAuth authentication.
59+
This involves opening a browser request to `_https://bitbucket.org/site/oauth2/authorize?response_type=code&client_id={consumerkey}&state=authenticated&scope={scopes}&redirect_uri=http://localhost:34106/_`.
60+
This will trigger a flow on Bitbucket where the user must login, potentially including a 2FA prompt, and authorize the GCM to access Bitbucket with the specified scopes.
61+
The GCM will spawn a temporary, local webserver, listening on port 34106, to handle the OAuth redirect/callback.
62+
Assuming the user successfully logins into Bitbucket and authorizes the GCM this callback will include the Access and Refresh Tokens.
63+
64+
The Access and Refresh Tokens will be stored against the username and the username/Access Token credentials returned to Git.
65+
66+
# On-Premise Bitbucket
67+
68+
On-premise Bitbucket, more correctly known as Bitbucket Server or Bitbucket DC, has a number of differences compared to the cloud instance of Bitbucket, https://bitbucket.org.
69+
70+
As far as GCMC is concerned the main difference it doesn't support OAuth so only Basic Authentication is available.
71+
72+
It is possible to test with Bitbucket Server by running it locally using the following command from the Atlassian SDK:
73+
74+
❯ atlas-run-standalone --product bitbucket
75+
76+
See https://developer.atlassian.com/server/framework/atlassian-sdk/atlas-run-standalone/.
77+
78+
This will download and run a standalone instance of Bitbucket Server which can be accessed using the credentials `admin`/`admin` at
79+
80+
https://localhost:7990/bitbucket

docs/configuration.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@
33
[Git Credential Manager Core](usage.md) works out of the box for most users.
44

55
Git Credential Manager Core (GCM Core) can be configured using Git's configuration files, and follows all of the same rules Git does when consuming the files.
6+
67
Global configuration settings override system configuration settings, and local configuration settings override global settings; and because the configuration details exist within Git's configuration files you can use Git's `git config` utility to set, unset, and alter the setting values. All of GCM Core's configuration settings begin with the term `credential`.
78

89
GCM Core honors several levels of settings, in addition to the standard local \> global \> system tiering Git uses.
910
URL-specific settings or overrides can be applied to any value in the `credential` namespace with the syntax below.
1011

11-
Additionally, GCM Core respects several GCM-specific [environment variables](environment.md) **which take precedence over configuration options.**
12+
Additionally, GCM Core respects several GCM-specific [environment variables](environment.md) **which take precedence over configuration options**. System administrators may also configure [default values](enterprise-config.md) for many settings used by GCM Core.
1213

1314
GCM Core will only be used by Git if it is installed and configured. Use `git config --global credential.helper manager-core` to assign GCM Core as your credential helper. Use `git config credential.helper` to see the current configuration.
1415

0 commit comments

Comments
 (0)