aboutsummaryrefslogtreecommitdiff
path: root/zenserver/auth/authservice.cpp
diff options
context:
space:
mode:
authorStefan Boberg <[email protected]>2023-05-02 10:01:47 +0200
committerGitHub <[email protected]>2023-05-02 10:01:47 +0200
commit075d17f8ada47e990fe94606c3d21df409223465 (patch)
treee50549b766a2f3c354798a54ff73404217b4c9af /zenserver/auth/authservice.cpp
parentfix: bundle shouldn't append content zip to zen (diff)
downloadzen-075d17f8ada47e990fe94606c3d21df409223465.tar.xz
zen-075d17f8ada47e990fe94606c3d21df409223465.zip
moved source directories into `/src` (#264)
* moved source directories into `/src` * updated bundle.lua for new `src` path * moved some docs, icon * removed old test trees
Diffstat (limited to 'zenserver/auth/authservice.cpp')
-rw-r--r--zenserver/auth/authservice.cpp91
1 files changed, 0 insertions, 91 deletions
diff --git a/zenserver/auth/authservice.cpp b/zenserver/auth/authservice.cpp
deleted file mode 100644
index 1cc679540..000000000
--- a/zenserver/auth/authservice.cpp
+++ /dev/null
@@ -1,91 +0,0 @@
-// Copyright Epic Games, Inc. All Rights Reserved.
-
-#include <auth/authservice.h>
-
-#include <auth/authmgr.h>
-
-#include <zencore/compactbinarybuilder.h>
-#include <zencore/string.h>
-
-ZEN_THIRD_PARTY_INCLUDES_START
-#include <json11.hpp>
-ZEN_THIRD_PARTY_INCLUDES_END
-
-namespace zen {
-
-using namespace std::literals;
-
-HttpAuthService::HttpAuthService(AuthMgr& AuthMgr) : m_AuthMgr(AuthMgr)
-{
- m_Router.RegisterRoute(
- "oidc/refreshtoken",
- [this](HttpRouterRequest& RouterRequest) {
- HttpServerRequest& ServerRequest = RouterRequest.ServerRequest();
-
- const HttpContentType ContentType = ServerRequest.RequestContentType();
-
- if ((ContentType == HttpContentType::kUnknownContentType || ContentType == HttpContentType::kJSON) == false)
- {
- return ServerRequest.WriteResponse(HttpResponseCode::BadRequest);
- }
-
- const IoBuffer Body = ServerRequest.ReadPayload();
-
- std::string JsonText(reinterpret_cast<const char*>(Body.GetData()), Body.GetSize());
- std::string JsonError;
- json11::Json TokenInfo = json11::Json::parse(JsonText, JsonError);
-
- if (!JsonError.empty())
- {
- CbObjectWriter Response;
- Response << "Result"sv << false;
- Response << "Error"sv << JsonError;
-
- return ServerRequest.WriteResponse(HttpResponseCode::BadRequest, Response.Save());
- }
-
- const std::string RefreshToken = TokenInfo["RefreshToken"].string_value();
- std::string ProviderName = TokenInfo["ProviderName"].string_value();
-
- if (ProviderName.empty())
- {
- ProviderName = "Default"sv;
- }
-
- const bool Ok =
- m_AuthMgr.AddOpenIdToken(AuthMgr::AddOpenIdTokenParams{.ProviderName = ProviderName, .RefreshToken = RefreshToken});
-
- if (Ok)
- {
- ServerRequest.WriteResponse(Ok ? HttpResponseCode::OK : HttpResponseCode::BadRequest);
- }
- else
- {
- CbObjectWriter Response;
- Response << "Result"sv << false;
- Response << "Error"sv
- << "Invalid token"sv;
-
- ServerRequest.WriteResponse(HttpResponseCode::BadRequest, Response.Save());
- }
- },
- HttpVerb::kPost);
-}
-
-HttpAuthService::~HttpAuthService()
-{
-}
-
-const char*
-HttpAuthService::BaseUri() const
-{
- return "/auth/";
-}
-
-void
-HttpAuthService::HandleRequest(zen::HttpServerRequest& Request)
-{
- m_Router.HandleRequest(Request);
-}
-
-} // namespace zen