Skip to content

Commit caf8fa7

Browse files
committed
Attempt at Gitea support
1 parent 9b3bf45 commit caf8fa7

13 files changed

+672
-1
lines changed

Git-Credential-Manager.sln

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ EndProject
7070
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Git-Credential-Manager.UI.Avalonia", "src\shared\Git-Credential-Manager.UI.Avalonia\Git-Credential-Manager.UI.Avalonia.csproj", "{35659127-8859-4DB9-8DD6-A08C1952632E}"
7171
EndProject
7272
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Git-Credential-Manager.UI.Windows", "src\windows\Git-Credential-Manager.UI.Windows\Git-Credential-Manager.UI.Windows.csproj", "{01BF56EC-AAC1-4BCA-8204-EE51D968DF5C}"
73+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Gitea", "src\shared\Gitea\Gitea.csproj", "{FEF135C0-F03B-4E19-8AD7-20DFC4DC76E7}"
7374
EndProject
7475
Global
7576
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -415,6 +416,23 @@ Global
415416
{570897DC-A85C-4598-B793-9A00CF710119}.MacRelease|Any CPU.Build.0 = Release|Any CPU
416417
{570897DC-A85C-4598-B793-9A00CF710119}.WindowsRelease|Any CPU.ActiveCfg = Release|Any CPU
417418
{570897DC-A85C-4598-B793-9A00CF710119}.WindowsRelease|Any CPU.Build.0 = Release|Any CPU
419+
{FEF135C0-F03B-4E19-8AD7-20DFC4DC76E7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
420+
{FEF135C0-F03B-4E19-8AD7-20DFC4DC76E7}.Debug|Any CPU.Build.0 = Debug|Any CPU
421+
{FEF135C0-F03B-4E19-8AD7-20DFC4DC76E7}.MacDebug|Any CPU.ActiveCfg = Debug|Any CPU
422+
{FEF135C0-F03B-4E19-8AD7-20DFC4DC76E7}.MacDebug|Any CPU.Build.0 = Debug|Any CPU
423+
{FEF135C0-F03B-4E19-8AD7-20DFC4DC76E7}.Release|Any CPU.ActiveCfg = Release|Any CPU
424+
{FEF135C0-F03B-4E19-8AD7-20DFC4DC76E7}.Release|Any CPU.Build.0 = Release|Any CPU
425+
{FEF135C0-F03B-4E19-8AD7-20DFC4DC76E7}.WindowsDebug|Any CPU.ActiveCfg = Debug|Any CPU
426+
{FEF135C0-F03B-4E19-8AD7-20DFC4DC76E7}.WindowsDebug|Any CPU.Build.0 = Debug|Any CPU
427+
{FEF135C0-F03B-4E19-8AD7-20DFC4DC76E7}.LinuxDebug|Any CPU.ActiveCfg = Debug|Any CPU
428+
{FEF135C0-F03B-4E19-8AD7-20DFC4DC76E7}.LinuxDebug|Any CPU.Build.0 = Debug|Any CPU
429+
{FEF135C0-F03B-4E19-8AD7-20DFC4DC76E7}.LinuxRelease|Any CPU.ActiveCfg = Release|Any CPU
430+
{FEF135C0-F03B-4E19-8AD7-20DFC4DC76E7}.LinuxRelease|Any CPU.Build.0 = Release|Any CPU
431+
{FEF135C0-F03B-4E19-8AD7-20DFC4DC76E7}.MacRelease|Any CPU.ActiveCfg = Release|Any CPU
432+
{FEF135C0-F03B-4E19-8AD7-20DFC4DC76E7}.MacRelease|Any CPU.Build.0 = Release|Any CPU
433+
{FEF135C0-F03B-4E19-8AD7-20DFC4DC76E7}.WindowsRelease|Any CPU.ActiveCfg = Release|Any CPU
434+
{FEF135C0-F03B-4E19-8AD7-20DFC4DC76E7}.WindowsRelease|Any CPU.Build.0 = Release|Any CPU
435+
{FEF135C0-F03B-4E19-8AD7-20DFC4DC76E7} = {D5277A0E-997E-453A-8CB9-4EFCC8B16A29}
418436
{1AF9F7C5-FA2E-48F1-B216-4D5E9A27F393}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
419437
{1AF9F7C5-FA2E-48F1-B216-4D5E9A27F393}.Debug|Any CPU.Build.0 = Debug|Any CPU
420438
{1AF9F7C5-FA2E-48F1-B216-4D5E9A27F393}.MacDebug|Any CPU.ActiveCfg = Debug|Any CPU

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Compared to Git's [built-in credential helpers][git-tools-credential-storage]
1212
provides single-factor authentication support working on any HTTP-enabled Git
1313
repository, GCM provides multi-factor authentication support for
1414
[Azure DevOps][azure-devops], Azure DevOps Server (formerly Team Foundation
15-
Server), GitHub, Bitbucket, and GitLab.
15+
Server), GitHub, Bitbucket, GitLab and Gitea.
1616

1717
Git Credential Manager (GCM) replaces the .NET Framework-based
1818
[Git Credential Manager for Windows][gcm-for-windows] (GCM), and the Java-based
@@ -36,6 +36,7 @@ Multi-factor authentication support for Azure DevOps|✓|✓|✓
3636
Two-factor authentication support for GitHub|✓|✓|✓
3737
Two-factor authentication support for Bitbucket|✓|✓|✓
3838
Two-factor authentication support for GitLab|✓|✓|✓
39+
Two-factor authentication support for Gitea|✓|✓|✓
3940
Windows Integrated Authentication (NTLM/Kerberos) support|✓|_N/A_|_N/A_
4041
Basic HTTP authentication support|✓|✓|✓
4142
Proxy support|✓|✓|✓
@@ -283,6 +284,7 @@ See detailed information [here][gcm-http-proxy].
283284
- [Host provider specification][gcm-host-provider]
284285
- [Azure Repos OAuth tokens][gcm-azure-tokens]
285286
- [GitLab support][gcm-gitlab]
287+
- [Gitea support][gcm-gitea]
286288

287289
## Experimental Features
288290

@@ -322,6 +324,7 @@ When using GitHub logos, please be sure to follow the
322324
[gcm-for-mac-and-linux]: https://github.com/microsoft/Git-Credential-Manager-for-Mac-and-Linux
323325
[gcm-for-windows]: https://github.com/microsoft/Git-Credential-Manager-for-Windows
324326
[gcm-gitlab]: docs/gitlab.md
327+
[gcm-gitea]: docs/gitea.md
325328
[gcm-host-provider]: docs/hostprovider.md
326329
[gcm-http-proxy]: docs/netconfig.md#http-proxy
327330
[gcm-license]: LICENSE

docs/configuration.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ ID|Provider
8787
`github`|GitHub
8888
`bitbucket`|Bitbucket
8989
`gitlab`|GitLab _(supports OAuth in browser, personal access token and Basic Authentication)_
90+
`gitea`|Gitea _(supports OAuth in browser, personal access token and Basic Authentication)_
9091
`generic`|Generic (any other provider not listed above)
9192

9293
Automatic provider selection is based on the remote URL.
@@ -350,6 +351,31 @@ git config --global credential.namespace "my-namespace"
350351

351352
---
352353

354+
### credential.giteaAuthModes
355+
356+
Override the available authentication modes presented during Gitea
357+
authentication. If this option is not set, then the available authentication
358+
modes will be automatically detected.
359+
360+
**Note:** This setting supports multiple values separated by commas.
361+
362+
Value|Authentication Mode
363+
-|-
364+
_(unset)_|Automatically detect modes
365+
`browser`|OAuth authentication via a web browser _(requires a GUI)_
366+
`basic`|Basic authentication using username and password
367+
`pat`|Personal Access Token (pat)-based authentication
368+
369+
#### Example
370+
371+
```shell
372+
git config --global credential.giteaAuthModes "browser"
373+
```
374+
375+
**Also see: [GCM_GITEA_AUTHMODES][gcm-gitea-authmodes]**
376+
377+
---
378+
353379
### credential.credentialStore
354380

355381
Select the type of credential store to use on supported platforms.
@@ -611,6 +637,7 @@ git config --global credential.azreposCredentialType oauth
611637
[gcm-dpapi-store-path]: environment.md#GCM_DPAPI_STORE_PATH
612638
[gcm-github-authmodes]: environment.md#GCM_GITHUB_AUTHMODES
613639
[gcm-gitlab-authmodes]:environment.md#GCM_GITLAB_AUTHMODES
640+
[gcm-gitea-authmodes]:environment.md#GCM_GITEA_AUTHMODES
614641
[gcm-gui-prompt]: environment.md#GCM_GUI_PROMPT
615642
[gcm-http-proxy]: environment.md#GCM_HTTP_PROXY-deprecated
616643
[gcm-interactive]: environment.md#GCM_INTERACTIVE

docs/environment.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ ID|Provider
183183
`azure-repos`|Azure Repos
184184
`github`|GitHub
185185
`gitlab`|GitLab _(supports OAuth in browser, personal access token and Basic Authentication)_
186+
`gitea`|Gitea _(supports OAuth in browser, personal access token and Basic Authentication)_
186187
`generic`|Generic (any other provider not listed above)
187188

188189
Automatic provider selection is based on the remote URL.
@@ -498,6 +499,37 @@ export GCM_GITLAB_AUTHMODES="browser"
498499

499500
---
500501

502+
### GCM_GITEA_AUTHMODES
503+
504+
Override the available authentication modes presented during Gitea
505+
authentication. If this option is not set, then the available authentication
506+
modes will be automatically detected.
507+
508+
**Note:** This setting supports multiple values separated by commas.
509+
510+
Value|Authentication Mode
511+
-|-
512+
_(unset)_|Automatically detect modes
513+
`browser`|OAuth authentication via a web browser _(requires a GUI)_
514+
`basic`|Basic authentication using username and password
515+
`pat`|Personal Access Token (pat)-based authentication
516+
517+
#### Windows
518+
519+
```batch
520+
SET GCM_GITEA_AUTHMODES="browser"
521+
```
522+
523+
#### macOS/Linux
524+
525+
```bash
526+
export GCM_GITEA_AUTHMODES="browser"
527+
```
528+
529+
**Also see: [credential.giteaAuthModes][credential-giteaauthmodes]**
530+
531+
---
532+
501533
### GCM_NAMESPACE
502534

503535
Use a custom namespace prefix for credentials read and written in the OS
@@ -752,6 +784,7 @@ export GCM_AZREPOS_CREDENTIALTYPE="oauth"
752784
[credential-dpapi-store-path]: configuration.md#credentialdpapistorepath
753785
[credential-githubauthmodes]: configuration.md#credentialgitHubAuthModes
754786
[credential-gitlabauthmodes]: configuration.md#credentialgitLabAuthModes
787+
[credential-giteaauthmodes]: configuration.md#credentialgiteaAuthModes
755788
[credential-guiprompt]: configuration.md#credentialguiprompt
756789
[credential-httpproxy]: configuration.md#credentialhttpProxy-deprecated
757790
[credential-interactive]: configuration.md#credentialinteractive

docs/gitea.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Gitea support
2+
3+
GCM requires Gitea v1.17.3 or later.
4+
5+
## Config for a custom instance
6+
7+
1. In Settings / Applications, create an OAuth application, unchecking the
8+
*Confidential* option (if this option is missing, the version of Gitea is too
9+
old)
10+
1. Copy the application ID and configure
11+
`git config --global credential.https://gitea.example.com.GiteaDevClientId <APPLICATION_ID>`
12+
1. Copy the application secret and configure
13+
`git config --global credential.https://gitea.example.com.GiteaDevClientSecret
14+
<APPLICATION_SECRET>`
15+
1. Configure authentication modes to include 'browser'
16+
`git config --global credential.https://gitea.example.com.GiteaAuthModes browser`
17+
1. For good measure, configure
18+
`git config --global credential.https://gitea.example.com.provider gitea`.
19+
This may be necessary to recognise the domain as a Gitea instance.
20+
1. Verify the config is as expected
21+
`git config --global --get-urlmatch credential https://gitea.example.com`
22+
23+
## Clearing config
24+
25+
### Clearing config
26+
27+
```console
28+
git config --global --unset-all credential.https://gitea.example.com.GiteaDevClientId
29+
git config --global --unset-all credential.https://gitea.example.com.GiteaDevClientSecret
30+
git config --global --unset-all credential.https://gitea.example.com.provider
31+
```
32+
33+
## Preferences
34+
35+
```console
36+
Select an authentication method for 'https://gitea.com/':
37+
1. Web browser (default)
38+
2. Personal access token
39+
3. Username/password
40+
option (enter for default):
41+
```
42+
43+
If you have a preferred authentication mode, you can specify
44+
[credential.giteaAuthModes][config-gitea-auth-modes]:
45+
46+
```console
47+
git config --global credential.giteaauthmodes browser
48+
```

src/shared/Git-Credential-Manager/Git-Credential-Manager.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
<ProjectReference Include="..\Atlassian.Bitbucket\Atlassian.Bitbucket.csproj" />
1919
<ProjectReference Include="..\GitHub\GitHub.csproj" />
2020
<ProjectReference Include="..\GitLab\GitLab.csproj" />
21+
<ProjectReference Include="..\Gitea\Gitea.csproj" />
2122
<ProjectReference Include="..\Microsoft.AzureRepos\Microsoft.AzureRepos.csproj" />
2223
<ProjectReference Include="..\Core\Core.csproj" />
2324
</ItemGroup>

src/shared/Git-Credential-Manager/Program.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using Atlassian.Bitbucket;
33
using GitHub;
44
using GitLab;
5+
using Gitea;
56
using Microsoft.AzureRepos;
67
using GitCredentialManager.Authentication;
78

@@ -37,6 +38,7 @@ public static void Main(string[] args)
3738
app.RegisterProvider(new BitbucketHostProvider(context), HostProviderPriority.Normal);
3839
app.RegisterProvider(new GitHubHostProvider(context), HostProviderPriority.Normal);
3940
app.RegisterProvider(new GitLabHostProvider(context), HostProviderPriority.Normal);
41+
app.RegisterProvider(new GiteaHostProvider(context), HostProviderPriority.Normal);
4042
app.RegisterProvider(new GenericHostProvider(context), HostProviderPriority.Low);
4143

4244
int exitCode = app.RunAsync(args)

src/shared/Gitea/Gitea.csproj

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFrameworks>netstandard2.0</TargetFrameworks>
5+
<TargetFrameworks Condition="'$(OSPlatform)'=='windows'">netstandard2.0;net472</TargetFrameworks>
6+
<AssemblyName>Gitea</AssemblyName>
7+
<RootNamespace>Gitea</RootNamespace>
8+
<IsTestProject>false</IsTestProject>
9+
<LangVersion>latest</LangVersion>
10+
</PropertyGroup>
11+
12+
<ItemGroup>
13+
<ProjectReference Include="..\Core\Core.csproj" />
14+
</ItemGroup>
15+
16+
<ItemGroup Condition="'$(TargetFramework)' == 'net472'">
17+
<Reference Include="System.Net.Http" />
18+
</ItemGroup>
19+
20+
</Project>

0 commit comments

Comments
 (0)