Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit ea25f2a

Browse files
committed
Initial implementation of SSO (.com only currently).
1 parent cefd4b9 commit ea25f2a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+671
-131
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,6 @@
1313
[submodule "script"]
1414
path = script
1515
url = [email protected]:github/VisualStudioBuildScripts
16+
[submodule "submodules/Rothko"]
17+
path = submodules/Rothko
18+
url = https://github.com/editor-tools/Rothko.git

GitHubVS.sln

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GitHub.InlineReviews.UnitTe
106106
EndProject
107107
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GitHub.Logging", "src\GitHub.Logging\GitHub.Logging.csproj", "{8D73575A-A89F-47CC-B153-B47DD06837F0}"
108108
EndProject
109+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Rothko", "Rothko", "{8B9A34C6-0D62-4D49-9606-1AB838923A74}"
110+
EndProject
111+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Rothko", "submodules\Rothko\src\Rothko.csproj", "{4A84E568-CA86-4510-8CD0-90D3EF9B65F9}"
112+
EndProject
109113
Global
110114
GlobalSection(SolutionConfigurationPlatforms) = preSolution
111115
Debug|Any CPU = Debug|Any CPU
@@ -415,6 +419,16 @@ Global
415419
{8D73575A-A89F-47CC-B153-B47DD06837F0}.Release|Any CPU.Build.0 = Release|Any CPU
416420
{8D73575A-A89F-47CC-B153-B47DD06837F0}.ReleaseWithoutVsix|Any CPU.ActiveCfg = Release|Any CPU
417421
{8D73575A-A89F-47CC-B153-B47DD06837F0}.ReleaseWithoutVsix|Any CPU.Build.0 = Release|Any CPU
422+
{4A84E568-CA86-4510-8CD0-90D3EF9B65F9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
423+
{4A84E568-CA86-4510-8CD0-90D3EF9B65F9}.Debug|Any CPU.Build.0 = Debug|Any CPU
424+
{4A84E568-CA86-4510-8CD0-90D3EF9B65F9}.DebugCodeAnalysis|Any CPU.ActiveCfg = Debug|Any CPU
425+
{4A84E568-CA86-4510-8CD0-90D3EF9B65F9}.DebugCodeAnalysis|Any CPU.Build.0 = Debug|Any CPU
426+
{4A84E568-CA86-4510-8CD0-90D3EF9B65F9}.DebugWithoutVsix|Any CPU.ActiveCfg = Debug|Any CPU
427+
{4A84E568-CA86-4510-8CD0-90D3EF9B65F9}.DebugWithoutVsix|Any CPU.Build.0 = Debug|Any CPU
428+
{4A84E568-CA86-4510-8CD0-90D3EF9B65F9}.Release|Any CPU.ActiveCfg = Release|Any CPU
429+
{4A84E568-CA86-4510-8CD0-90D3EF9B65F9}.Release|Any CPU.Build.0 = Release|Any CPU
430+
{4A84E568-CA86-4510-8CD0-90D3EF9B65F9}.ReleaseWithoutVsix|Any CPU.ActiveCfg = Release|Any CPU
431+
{4A84E568-CA86-4510-8CD0-90D3EF9B65F9}.ReleaseWithoutVsix|Any CPU.Build.0 = Release|Any CPU
418432
EndGlobalSection
419433
GlobalSection(SolutionProperties) = preSolution
420434
HideSolutionNode = FALSE
@@ -438,5 +452,7 @@ Global
438452
{7B835A7D-CF94-45E8-B191-96F5A4FE26A8} = {8A7DA2E7-262B-4581-807A-1C45CE79CDFD}
439453
{110B206F-8554-4B51-BF86-94DAA32F5E26} = {8A7DA2E7-262B-4581-807A-1C45CE79CDFD}
440454
{17EB676B-BB91-48B5-AA59-C67695C647C2} = {8A7DA2E7-262B-4581-807A-1C45CE79CDFD}
455+
{8B9A34C6-0D62-4D49-9606-1AB838923A74} = {1E7F7253-A6AF-43C4-A955-37BEDDA01AB8}
456+
{4A84E568-CA86-4510-8CD0-90D3EF9B65F9} = {8B9A34C6-0D62-4D49-9606-1AB838923A74}
441457
EndGlobalSection
442458
EndGlobal

script

src/DesignTimeStyleHelper/App.config

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@
4545
<assemblyIdentity name="System.Diagnostics.DiagnosticSource" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
4646
<bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0" />
4747
</dependentAssembly>
48+
<dependentAssembly>
49+
<assemblyIdentity name="Microsoft.VisualStudio.ComponentModelHost" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
50+
<bindingRedirect oldVersion="0.0.0.0-14.0.0.0" newVersion="14.0.0.0" />
51+
</dependentAssembly>
4852
</assemblyBinding>
4953
</runtime>
5054
</configuration>

src/DesignTimeStyleHelper/DesignTimeStyleHelper.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,6 @@
4848
<Reference Include="Moq">
4949
<HintPath>..\..\packages\Moq.4.2.1312.1319\lib\net40\Moq.dll</HintPath>
5050
</Reference>
51-
<Reference Include="rothko, Version=0.0.2.0, Culture=neutral, PublicKeyToken=9f664c41f503810a, processorArchitecture=MSIL">
52-
<HintPath>..\..\packages\Rothko.0.0.2-ghfvs\lib\net45\rothko.dll</HintPath>
53-
<Private>True</Private>
54-
</Reference>
5551
<Reference Include="System" />
5652
<Reference Include="System.ComponentModel.Composition" />
5753
<Reference Include="System.Data" />
@@ -157,6 +153,10 @@
157153
</None>
158154
</ItemGroup>
159155
<ItemGroup>
156+
<ProjectReference Include="..\..\submodules\Rothko\src\Rothko.csproj">
157+
<Project>{4a84e568-ca86-4510-8cd0-90d3ef9b65f9}</Project>
158+
<Name>Rothko</Name>
159+
</ProjectReference>
160160
<ProjectReference Include="..\GitHub.Api\GitHub.Api.csproj">
161161
<Project>{b389adaf-62cc-486e-85b4-2d8b078df763}</Project>
162162
<Name>GitHub.Api</Name>

src/DesignTimeStyleHelper/packages.config

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
<package id="Microsoft.VisualStudio.ComponentModelHost" version="14.0.25424" targetFramework="net461" />
44
<package id="Microsoft.VisualStudio.Shell.Immutable.10.0" version="10.0.30319" targetFramework="net461" />
55
<package id="Moq" version="4.2.1312.1319" targetFramework="net45" userInstalled="true" />
6-
<package id="Rothko" version="0.0.2-ghfvs" targetFramework="net461" />
76
<package id="Rx-Core" version="2.2.5-custom" targetFramework="net45" userInstalled="true" />
87
<package id="Rx-Interfaces" version="2.2.5-custom" targetFramework="net45" userInstalled="true" />
98
<package id="Rx-Linq" version="2.2.5-custom" targetFramework="net45" userInstalled="true" />

src/GitHub.Api/ApiClientConfiguration.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,8 @@
33
using System.Linq;
44
using System.Net;
55
using System.Net.NetworkInformation;
6-
using System.Reflection;
76
using System.Security.Cryptography;
87
using System.Text;
9-
using GitHub.Primitives;
108

119
namespace GitHub.Api
1210
{
@@ -33,6 +31,11 @@ static ApiClientConfiguration()
3331
/// </summary>
3432
public static string ClientSecret { get; private set; }
3533

34+
/// <summary>
35+
/// Gets the scopes required by the application.
36+
/// </summary>
37+
public static string[] Scopes { get; } = new[] { "user", "repo", "gist", "write:public_key" };
38+
3639
/// <summary>
3740
/// Gets a note that will be stored with the OAUTH token.
3841
/// </summary>

src/GitHub.Api/GitHub.Api.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
<Compile Include="ApiClientConfiguration_User.cs" Condition="$(Buildtype) != 'Internal'" />
6565
<Compile Include="IKeychain.cs" />
6666
<Compile Include="ILoginManager.cs" />
67+
<Compile Include="IOAuthCallbackListener.cs" />
6768
<Compile Include="ITwoFactorChallengeHandler.cs" />
6869
<Compile Include="LoginManager.cs" />
6970
<Compile Include="KeychainCredentialStore.cs" />

src/GitHub.Api/ILoginManager.cs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
using System.Runtime.InteropServices;
1+
using System;
2+
using System.Runtime.InteropServices;
3+
using System.Threading;
24
using System.Threading.Tasks;
35
using GitHub.Primitives;
46
using GitHub.VisualStudio;
@@ -25,6 +27,25 @@ public interface ILoginManager
2527
/// </exception>
2628
Task<User> Login(HostAddress hostAddress, IGitHubClient client, string userName, string password);
2729

30+
/// <summary>
31+
/// Attempts to log into a GitHub server via OAuth in the browser.
32+
/// </summary>
33+
/// <param name="hostAddress">The address of the server.</param>
34+
/// <param name="client">An octokit client configured to access the server.</param>
35+
/// <param name="oauthClient">An octokit OAuth client configured to access the server.</param>
36+
/// <param name="openBrowser">A callback that should open a browser at the requested URL.</param>
37+
/// <param name="cancel">A cancellation token used to cancel the operation.</param>
38+
/// <returns>The logged in user.</returns>
39+
/// <exception cref="AuthorizationException">
40+
/// The login authorization failed.
41+
/// </exception>
42+
Task<User> LoginViaOAuth(
43+
HostAddress hostAddress,
44+
IGitHubClient client,
45+
IOauthClient oauthClient,
46+
Action<Uri> openBrowser,
47+
CancellationToken cancel);
48+
2849
/// <summary>
2950
/// Attempts to log into a GitHub server using existing credentials.
3051
/// </summary>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
using System;
2+
using System.Threading;
3+
using System.Threading.Tasks;
4+
5+
namespace GitHub.Api
6+
{
7+
/// <summary>
8+
/// Listens for a callback from the OAuth endpoint signalling successful login.
9+
/// </summary>
10+
public interface IOAuthCallbackListener
11+
{
12+
/// <summary>
13+
/// Listens for a callback with a `state` matching <paramref name="id"/>.
14+
/// </summary>
15+
/// <param name="id">The ID of the operation.</param>
16+
/// <param name="cancel">A cancellation token.</param>
17+
/// <returns>The temporary code included in the callback.</returns>
18+
Task<string> Listen(string id, CancellationToken cancel);
19+
}
20+
}

0 commit comments

Comments
 (0)