Skip to content

Commit

Permalink
Implemented GitHub OAuth authentication. (#174)
Browse files Browse the repository at this point in the history
Closes #171.
  • Loading branch information
pvginkel authored Dec 16, 2023
1 parent 4f29386 commit f9d5a46
Show file tree
Hide file tree
Showing 19 changed files with 219 additions and 333 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ jobs:
run: ./scripts/Write-Secrets.ps1
env:
GOOGLE_DRIVE_API_SECRET: ${{ secrets.GOOGLE_DRIVE_API_SECRET }}
GITHUB_OAUTH_SECRET: ${{ secrets.MY_GITHUB_OAUTH_SECRET }}

- name: Build Solution
run: dotnet build -c Release -property:Version="${{ steps.get-build-version.outputs.build-version }}" -warnaserror
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/pr-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ jobs:
run: ./scripts/Write-Secrets.ps1
env:
GOOGLE_DRIVE_API_SECRET: ${{ secrets.GOOGLE_DRIVE_API_SECRET }}
GITHUB_OAUTH_SECRET: ${{ secrets.MY_GITHUB_OAUTH_SECRET }}

- name: Build Solution
run: dotnet build -c Release -warnaserror
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ jobs:
run: ./scripts/Write-Secrets.ps1
env:
GOOGLE_DRIVE_API_SECRET: ${{ secrets.GOOGLE_DRIVE_API_SECRET }}
GITHUB_OAUTH_SECRET: ${{ secrets.MY_GITHUB_OAUTH_SECRET }}

- name: Build Solution
run: dotnet build -c Release -property:Version="${{ steps.get-build-version.outputs.build-version }}" -warnaserror
Expand Down
1 change: 1 addition & 0 deletions scripts/Write-Secrets.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ $ReplacementScriptBlock = {

switch ($SecretName) {
"GOOGLE_DRIVE_API_SECRET" { $SecretValue = $env:GOOGLE_DRIVE_API_SECRET }
"GITHUB_OAUTH_SECRET" { $SecretValue = $env:GITHUB_OAUTH_SECRET }
default { throw "Invalid secret name $SecretName" }
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ private Task<UserCredential> GetCredentials(CancellationToken cancellationToken)

private string GetClientSecret()
{
#if !DEBUG
#if DEBUG
return Environment.GetEnvironmentVariable("GOOGLE_DRIVE_API_SECRET")!;
#else
return Encoding
Expand Down
15 changes: 15 additions & 0 deletions src/Tql.DebugApp/packages.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -805,6 +805,15 @@
"resolved": "6.8.0",
"contentHash": "WBu15cdv1lqKkPKXDQOEmEzwKemwrczKYlc2jtuZgRYiZ8TG8F4QzPYiE0Q9eVIpMSk8Aky7mUephf19HjBPOw=="
},
"OAuth2": {
"type": "Transitive",
"resolved": "0.10.3",
"contentHash": "Yg5OaNfNrUq2HN0LNcxGL9plMh3XC9fja1/iTVZB96D7UwIxk0iq9irN0EbvardXlALUIIv3NKz6CVRHk+1Mxg==",
"dependencies": {
"Newtonsoft.Json": "13.0.2",
"RestSharp": "106.12.0"
}
},
"Octokit": {
"type": "Transitive",
"resolved": "9.0.0",
Expand All @@ -818,6 +827,11 @@
"Newtonsoft.Json": "13.0.1"
}
},
"RestSharp": {
"type": "Transitive",
"resolved": "106.12.0",
"contentHash": "irOsQHe5nTJB0BKxGQnTX1dsgCPl5dLTxvL7gbl98JiFPiHMN4wpFyUG/66ZpaFCsIrPKh6XwozWXlwYe9JwYQ=="
},
"runtime.debian.8-x64.runtime.native.System.Security.Cryptography.OpenSsl": {
"type": "Transitive",
"resolved": "4.3.0",
Expand Down Expand Up @@ -1991,6 +2005,7 @@
"type": "Project",
"dependencies": {
"HtmlAgilityPack": "[1.11.54, )",
"OAuth2": "[0.10.3, )",
"Octokit": "[9.0.0, )",
"Octokit.GraphQL": "[0.3.0-beta, )",
"TQLApp.Utilities": "[0.0.0, )"
Expand Down
93 changes: 0 additions & 93 deletions src/Tql.Plugins.GitHub/ConfigurationUI/DeviceCodeWindow.xaml

This file was deleted.

129 changes: 0 additions & 129 deletions src/Tql.Plugins.GitHub/ConfigurationUI/DeviceCodeWindow.xaml.cs

This file was deleted.

6 changes: 6 additions & 0 deletions src/Tql.Plugins.GitHub/Constants.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace Tql.Plugins.GitHub;

internal static class Constants
{
public static readonly TimeSpan AuthenticationTimeout = TimeSpan.FromMinutes(5);
}
45 changes: 9 additions & 36 deletions src/Tql.Plugins.GitHub/Labels.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 4 additions & 16 deletions src/Tql.Plugins.GitHub/Labels.nl.resx
Original file line number Diff line number Diff line change
Expand Up @@ -82,22 +82,6 @@
<value>Naam:</value>
<comment>Original: Name:</comment>
</data>
<data name="DeviceCodeWindow_AuthenticationWithGitHub" xml:space="preserve">
<value>Authentiseer met GitHub</value>
<comment>Original: Authenticate with GitHub</comment>
</data>
<data name="DeviceCodeWindow_HelpText" xml:space="preserve">
<value>Klik op de knop hieronder om naar de GitHub website te gaan en voor deze gebruikers code in:</value>
<comment>Original: Click the button below to go to the GitHub website and enter the user code shown below:</comment>
</data>
<data name="DeviceCodeWindow_OpenDeviceActivationPage" xml:space="preserve">
<value>Open Apparaat Activatie pagina</value>
<comment>Original: Open Device Activation page</comment>
</data>
<data name="DeviceCodeWindow_Title" xml:space="preserve">
<value>GitHub Authenticatie</value>
<comment>Original: GitHub Authentication</comment>
</data>
<data name="GistsMatch_SearchHint" xml:space="preserve">
<value>Vind gists</value>
<comment>Original: Find gists</comment>
Expand Down Expand Up @@ -254,4 +238,8 @@
<value>Vind workflow runs</value>
<comment>Original: Find workflow runs</comment>
</data>
<data name="GitHubOAuthWorkflow_AuthenticationComplete" xml:space="preserve">
<value>Authenticatie is afgerond. Je kunt nu terug naar de app.</value>
<comment>Original: Authentication completed. You can now go back to the app.</comment>
</data>
</root>
Loading

0 comments on commit f9d5a46

Please sign in to comment.