diff options
| author | ivarlovlie <git@ivarlovlie.no> | 2022-01-23 22:28:55 +0100 |
|---|---|---|
| committer | ivarlovlie <git@ivarlovlie.no> | 2022-01-23 22:28:55 +0100 |
| commit | 253c8479b9ae0ba6853a70728d3f6e904e1ac2ba (patch) | |
| tree | a8d18e650d327221e60bee84879caaabf4f92acf /src/server/Api | |
| parent | d268ddf7fbb6ef025564c1a6f1d935a1267185df (diff) | |
| download | bookmark-thing-253c8479b9ae0ba6853a70728d3f6e904e1ac2ba.tar.xz bookmark-thing-253c8479b9ae0ba6853a70728d3f6e904e1ac2ba.zip | |
feat: WIP: Add option to login in with github
Diffstat (limited to 'src/server/Api')
| -rw-r--r-- | src/server/Api/Internal/Account/CreateGithubSessionRoute.cs | 17 | ||||
| -rw-r--r-- | src/server/Api/Internal/OAuthCallbackRoute.cs | 18 |
2 files changed, 35 insertions, 0 deletions
diff --git a/src/server/Api/Internal/Account/CreateGithubSessionRoute.cs b/src/server/Api/Internal/Account/CreateGithubSessionRoute.cs new file mode 100644 index 0000000..21cfead --- /dev/null +++ b/src/server/Api/Internal/Account/CreateGithubSessionRoute.cs @@ -0,0 +1,17 @@ +using AspNet.Security.OAuth.GitHub; + +namespace IOL.BookmarkThing.Server.Api.Internal.Account; + +public class CreateGithubSessionRoute : RouteBaseInternalSync.WithoutRequest.WithActionResult +{ + [AllowAnonymous] + [ApiVersionNeutral] + [ApiExplorerSettings(IgnoreApi = true)] + [HttpGet("~/v{version:apiVersion}/account/create-github-session")] + public override ActionResult Handle() { + return Challenge(new AuthenticationProperties { + RedirectUri = "/oauth-cb", + }, + GitHubAuthenticationDefaults.AuthenticationScheme); + } +} diff --git a/src/server/Api/Internal/OAuthCallbackRoute.cs b/src/server/Api/Internal/OAuthCallbackRoute.cs new file mode 100644 index 0000000..156ff11 --- /dev/null +++ b/src/server/Api/Internal/OAuthCallbackRoute.cs @@ -0,0 +1,18 @@ +namespace IOL.BookmarkThing.Server.Api.Internal; + +public class OAuthCallbackRoute : RouteBaseInternalSync.WithoutRequest.WithActionResult +{ + private readonly IConfiguration _configuration; + + public OAuthCallbackRoute(IConfiguration configuration) { + _configuration = configuration; + } + + [AllowAnonymous] + [ApiVersionNeutral] + [ApiExplorerSettings(IgnoreApi = true)] + [HttpGet("~/oauth-cb")] + public override ActionResult Handle() { + return Redirect(_configuration.GetValue<string>("FRONTEND_CANONICAL_URL")); + } +} |
