-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
77 changed files
with
9,424 additions
and
421 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -140,23 +140,40 @@ jobs: | |
run: cmake --preset ${{matrix.preset}} | ||
|
||
- name: CMake Build | ||
run: cmake --build --preset ${{matrix.preset}} | ||
run: cmake --build --preset ${{matrix.preset}} | ||
|
||
# - name: CMake Test | ||
# id: cmake-test | ||
# run: ctest --test-dir ./out/build/${{matrix.preset}}/OdbDesignTests --output-log ${{github.workspace}}/testlog.txt --output-junit ${{github.workspace}}/testlog.xml -V | ||
# # let the report step fail the job if it finds failed tests | ||
# continue-on-error: true | ||
- name: Checkout OdbDesign Test Data Repository | ||
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | ||
with: | ||
repository: 'nam20485/OdbDesignTestData' | ||
path: 'OdbDesignTestData' | ||
ref: 'main' | ||
token: ${{ secrets.ODBDESIGN_TESTDATA_ACCESS_TOKEN }} | ||
|
||
- name : Export ODB_TEST_DATA_DIR | ||
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 | ||
with: | ||
script: core.exportVariable('ODB_TEST_DATA_DIR', "${{github.workspace}}/OdbDesignTestData/TEST_DATA" || ''); | ||
|
||
# # report test results | ||
# - name: Report Test Results | ||
# uses: dorny/[email protected] | ||
# if: ${{steps.cmake-test.outcome}} == 'success' || ${{steps.cmake-test.outcome}} == 'failure' | ||
# with: | ||
# name: ${{ matrix.os }}_test-results | ||
# path: ${{github.workspace}}/testlog.xml | ||
# reporter: java-junit | ||
# fail-on-error: true | ||
- name: CMake Test | ||
id: cmake-test | ||
env: | ||
ODB_TEST_DATA_DIR: ${{github.workspace}}/OdbDesignTestData/TEST_DATA | ||
run: ctest --test-dir ./out/build/${{matrix.preset}}/OdbDesignTests --output-log ${{github.workspace}}/testlog.txt --output-junit ${{github.workspace}}/testlog.xml --output-on-failure | ||
# let the report step fail the job if it finds failed tests... | ||
continue-on-error: true | ||
|
||
# report test results | ||
- name: Report Test Results | ||
uses: dorny/[email protected] | ||
if: steps.cmake-test.outcome == 'success' || steps.cmake-test.outcome == 'failure' | ||
with: | ||
name: ${{ matrix.os }}_test-results | ||
path: ${{github.workspace}}/testlog.xml | ||
reporter: java-junit | ||
path-replace-backslashes: true | ||
# fail job based on report results | ||
fail-on-error: true | ||
|
||
# | ||
# Artifacts | ||
|
@@ -190,7 +207,7 @@ jobs: | |
Compress-Archive -Path "${{env.ARTIFACTS_DIR_WIN}}\*.dll","${{env.ARTIFACTS_DIR_WIN}}\*.exe" -DestinationPath "${{env.ARTIFACTS_DIR_WIN}}\artifacts-${{matrix.os}}.zip" -Verbose -Force | ||
- name: Upload Artifacts | ||
uses: actions/upload-artifact@1eb3cb2b3e0f29609092a73eb033bb759a334595 # v4.1.0 | ||
uses: actions/upload-artifact@694cdabd8bdb0f10b2cea11669e1bf5453eed0a6 # v4.2.0 | ||
with: | ||
name: ${{ matrix.os }}-artifacts | ||
path: ${{ env.ARTIFACTS_DIR }}/artifacts-${{matrix.os}}.zip | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#include "BasicRequestAuthentication.h" | ||
#include <string> | ||
|
||
namespace Odb::Lib::App | ||
{ | ||
crow::response BasicRequestAuthentication::AuthenticateRequest(const crow::request& req) | ||
{ | ||
const auto& authHeader = req.get_header_value("Authorization"); | ||
if (authHeader.empty()) return crow::response(401, "Unauthorized"); | ||
|
||
auto authValue = authHeader.substr(6); | ||
if (authValue.empty()) return crow::response(401, "Unauthorized"); | ||
|
||
auto authValueDecoded = crow::utility::base64decode(authValue, authValue.size()); | ||
if (authValueDecoded.empty()) return crow::response(401, "Unauthorized"); | ||
|
||
auto seperatorPos = authValueDecoded.find(':'); | ||
if (seperatorPos == std::string::npos) return crow::response(401, "Unauthorized"); | ||
|
||
auto username = authValueDecoded.substr(0, seperatorPos); | ||
auto password = authValueDecoded.substr(seperatorPos + 1); | ||
|
||
//if (! VerifyCredentials(username, password)) return crow::response(403, "Invalid username or password"); | ||
auto resp = VerifyCredentials(username, password); | ||
return resp; | ||
} | ||
|
||
crow::response BasicRequestAuthentication::VerifyCredentials(const std::string& username, const std::string& password) | ||
{ | ||
// 500 - Internal Server Error | ||
auto validUsername = std::getenv(USERNAME_ENV_NAME); | ||
Check warning on line 31 in OdbDesignLib/App/BasicRequestAuthentication.cpp GitHub Actions / CMake-Multi-Platform-Build (windows-2022, x64-release)
Check warning on line 31 in OdbDesignLib/App/BasicRequestAuthentication.cpp GitHub Actions / CMake-Multi-Platform-Build (windows-2022, x64-release)
|
||
if (validUsername == nullptr) return crow::response(500, "Server failed retrieving credentials"); | ||
|
||
auto validPassword = std::getenv(PASSWORD_ENV_NAME); | ||
Check warning on line 34 in OdbDesignLib/App/BasicRequestAuthentication.cpp GitHub Actions / CMake-Multi-Platform-Build (windows-2022, x64-release)
Check warning on line 34 in OdbDesignLib/App/BasicRequestAuthentication.cpp GitHub Actions / CMake-Multi-Platform-Build (windows-2022, x64-release)
|
||
if (validPassword == nullptr) return crow::response(500, "Server failed retrieving credentials"); | ||
|
||
// 403 - Forbidden | ||
if (username != validUsername || | ||
password != validPassword) | ||
{ | ||
return crow::response(403, "Invalid username or password"); | ||
} | ||
|
||
// 200 Authorized! | ||
return crow::response(200, "Authorized"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#pragma once | ||
|
||
#include "IRequestAuthentication.h" | ||
#include "../odbdesign_export.h" | ||
|
||
namespace Odb::Lib::App | ||
{ | ||
class ODBDESIGN_EXPORT BasicRequestAuthentication : public IRequestAuthentication | ||
{ | ||
public: | ||
//BasicRequestAuthentication() | ||
//{ | ||
//} | ||
|
||
// Inherited via IRequestAuthentication | ||
crow::response AuthenticateRequest(const crow::request& req) override; | ||
|
||
private: | ||
|
||
crow::response VerifyCredentials(const std::string& username, const std::string& password); | ||
|
||
const inline static char USERNAME_ENV_NAME[] = "ODBDESIGN_SERVER_REQUEST_USERNAME"; | ||
const inline static char PASSWORD_ENV_NAME[] = "ODBDESIGN_SERVER_REQUEST_PASSWORD"; | ||
|
||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#include "IRequestAuthentication.h" | ||
|
||
namespace Odb::Lib::App | ||
{ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#pragma once | ||
|
||
#include "../odbdesign_export.h" | ||
#include "crow_win.h" | ||
|
||
namespace Odb::Lib::App | ||
{ | ||
class ODBDESIGN_EXPORT IRequestAuthentication | ||
{ | ||
public: | ||
virtual crow::response AuthenticateRequest(const crow::request& req) = 0; | ||
|
||
protected: | ||
// pure virtual interface | ||
IRequestAuthentication() = default; | ||
|
||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.