From 34972d965a8ec3dd56a05ef6c0c00808698d7f71 Mon Sep 17 00:00:00 2001 From: Nathan Miller Date: Sun, 18 Feb 2024 19:57:30 -0800 Subject: [PATCH 01/15] Create CODE_OF_CONDUCT.md --- CODE_OF_CONDUCT.md | 128 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 128 insertions(+) create mode 100644 CODE_OF_CONDUCT.md diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 00000000..295c93c3 --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,128 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +We as members, contributors, and leaders pledge to make participation in our +community a harassment-free experience for everyone, regardless of age, body +size, visible or invisible disability, ethnicity, sex characteristics, gender +identity and expression, level of experience, education, socio-economic status, +nationality, personal appearance, race, religion, or sexual identity +and orientation. + +We pledge to act and interact in ways that contribute to an open, welcoming, +diverse, inclusive, and healthy community. + +## Our Standards + +Examples of behavior that contributes to a positive environment for our +community include: + +* Demonstrating empathy and kindness toward other people +* Being respectful of differing opinions, viewpoints, and experiences +* Giving and gracefully accepting constructive feedback +* Accepting responsibility and apologizing to those affected by our mistakes, + and learning from the experience +* Focusing on what is best not just for us as individuals, but for the + overall community + +Examples of unacceptable behavior include: + +* The use of sexualized language or imagery, and sexual attention or + advances of any kind +* Trolling, insulting or derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or email + address, without their explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Enforcement Responsibilities + +Community leaders are responsible for clarifying and enforcing our standards of +acceptable behavior and will take appropriate and fair corrective action in +response to any behavior that they deem inappropriate, threatening, offensive, +or harmful. + +Community leaders have the right and responsibility to remove, edit, or reject +comments, commits, code, wiki edits, issues, and other contributions that are +not aligned to this Code of Conduct, and will communicate reasons for moderation +decisions when appropriate. + +## Scope + +This Code of Conduct applies within all community spaces, and also applies when +an individual is officially representing the community in public spaces. +Examples of representing our community include using an official e-mail address, +posting via an official social media account, or acting as an appointed +representative at an online or offline event. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported to the community leaders responsible for enforcement at +nmiller217@gmail.com. +All complaints will be reviewed and investigated promptly and fairly. + +All community leaders are obligated to respect the privacy and security of the +reporter of any incident. + +## Enforcement Guidelines + +Community leaders will follow these Community Impact Guidelines in determining +the consequences for any action they deem in violation of this Code of Conduct: + +### 1. Correction + +**Community Impact**: Use of inappropriate language or other behavior deemed +unprofessional or unwelcome in the community. + +**Consequence**: A private, written warning from community leaders, providing +clarity around the nature of the violation and an explanation of why the +behavior was inappropriate. A public apology may be requested. + +### 2. Warning + +**Community Impact**: A violation through a single incident or series +of actions. + +**Consequence**: A warning with consequences for continued behavior. No +interaction with the people involved, including unsolicited interaction with +those enforcing the Code of Conduct, for a specified period of time. This +includes avoiding interactions in community spaces as well as external channels +like social media. Violating these terms may lead to a temporary or +permanent ban. + +### 3. Temporary Ban + +**Community Impact**: A serious violation of community standards, including +sustained inappropriate behavior. + +**Consequence**: A temporary ban from any sort of interaction or public +communication with the community for a specified period of time. No public or +private interaction with the people involved, including unsolicited interaction +with those enforcing the Code of Conduct, is allowed during this period. +Violating these terms may lead to a permanent ban. + +### 4. Permanent Ban + +**Community Impact**: Demonstrating a pattern of violation of community +standards, including sustained inappropriate behavior, harassment of an +individual, or aggression toward or disparagement of classes of individuals. + +**Consequence**: A permanent ban from any sort of public interaction within +the community. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], +version 2.0, available at +https://www.contributor-covenant.org/version/2/0/code_of_conduct.html. + +Community Impact Guidelines were inspired by [Mozilla's code of conduct +enforcement ladder](https://github.com/mozilla/diversity). + +[homepage]: https://www.contributor-covenant.org + +For answers to common questions about this code of conduct, see the FAQ at +https://www.contributor-covenant.org/faq. Translations are available at +https://www.contributor-covenant.org/translations. From 74103f49539e0cf691f6dc0d03077dc74f885c16 Mon Sep 17 00:00:00 2001 From: Nathan Miller Date: Sun, 18 Feb 2024 19:59:10 -0800 Subject: [PATCH 02/15] Update issue templates --- .github/ISSUE_TEMPLATE/bug_report.md | 38 +++++++++++++++++++++++ .github/ISSUE_TEMPLATE/feature_request.md | 20 ++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/bug_report.md create mode 100644 .github/ISSUE_TEMPLATE/feature_request.md diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 00000000..dd84ea78 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,38 @@ +--- +name: Bug report +about: Create a report to help us improve +title: '' +labels: '' +assignees: '' + +--- + +**Describe the bug** +A clear and concise description of what the bug is. + +**To Reproduce** +Steps to reproduce the behavior: +1. Go to '...' +2. Click on '....' +3. Scroll down to '....' +4. See error + +**Expected behavior** +A clear and concise description of what you expected to happen. + +**Screenshots** +If applicable, add screenshots to help explain your problem. + +**Desktop (please complete the following information):** + - OS: [e.g. iOS] + - Browser [e.g. chrome, safari] + - Version [e.g. 22] + +**Smartphone (please complete the following information):** + - Device: [e.g. iPhone6] + - OS: [e.g. iOS8.1] + - Browser [e.g. stock browser, safari] + - Version [e.g. 22] + +**Additional context** +Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 00000000..bbcbbe7d --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,20 @@ +--- +name: Feature request +about: Suggest an idea for this project +title: '' +labels: '' +assignees: '' + +--- + +**Is your feature request related to a problem? Please describe.** +A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] + +**Describe the solution you'd like** +A clear and concise description of what you want to happen. + +**Describe alternatives you've considered** +A clear and concise description of any alternative solutions or features you've considered. + +**Additional context** +Add any other context or screenshots about the feature request here. From 9a7e43d82e3d2f115e4ae034403e366ed1dd02a5 Mon Sep 17 00:00:00 2001 From: Nathan Miller Date: Sun, 18 Feb 2024 20:06:15 -0800 Subject: [PATCH 03/15] add link to CONTRIBUTING.md --- docs/README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/README.md b/docs/README.md index b3dd382e..59de4cce 100644 --- a/docs/README.md +++ b/docs/README.md @@ -199,6 +199,8 @@ The project is happy to accept pull requests if you would like to contribute. Pl All contributed code must be covered by accompanying test cases. Please make sure your changes are covered by test cases before submitting a pull request. +See [docs/CONTRIBUTING.md](CONTRIBUTING.md) for more details. + ## License This project is free and open source under the MIT [license](https://github.com/nam20485/OdbDesign/blob/c0c8b6e4b93e1c7d4d5e65c7ad25157c883f8bfb/LICENSE). From ff77e34e3b63f97fed7f57b9a5f44172d52ea320 Mon Sep 17 00:00:00 2001 From: Nathan Miller Date: Sun, 18 Feb 2024 20:06:58 -0800 Subject: [PATCH 04/15] add content to CONTRIBUTING.md --- docs/CONTRIBUTING.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/CONTRIBUTING.md b/docs/CONTRIBUTING.md index e69de29b..cfe027f6 100644 --- a/docs/CONTRIBUTING.md +++ b/docs/CONTRIBUTING.md @@ -0,0 +1,5 @@ +# Contributing + +The project is happy to accept pull requests if you would like to contribute. Please open an issue to discuss your proposed changes before submitting a pull request. Pull requests are accepted against the `development` branch. Please make sure your pull request is up to date with the latest changes in the `development` branch before submitting it. + +All contributed code must be covered by accompanying test cases. Please make sure your changes are covered by test cases before submitting a pull request. \ No newline at end of file From 604aa5daa0790179d1253cc373a8fadd485112e0 Mon Sep 17 00:00:00 2001 From: Nathan Miller Date: Sun, 18 Feb 2024 20:07:12 -0800 Subject: [PATCH 05/15] fix misspelling --- docs/SECURITY.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/SECURITY.md b/docs/SECURITY.md index 5a9b7486..98d37f4e 100644 --- a/docs/SECURITY.md +++ b/docs/SECURITY.md @@ -12,7 +12,7 @@ Security vulnerabilities can be reported privately using the [_Report a Vulnerability_](https://github.com/nam20485/OdbDesign/security) button under the _Security_ tab of this GitHub repository. Full instructions can be found [here](https://docs.github.com/en/code-security/security-advisories/guidance-on-reporting-and-writing-information-about-vulnerabilities/privately-reporting-a-security-vulnerability#privately-reporting-a-security-vulnerability). -If you would like to report a vulnerability publicy, you can create a regular GitHub issue describing it under the Issues tab. +If you would like to report a vulnerability publicly, you can create a regular GitHub issue describing it under the Issues tab. If you have any questions or the reporting button is not working, please email the [maintainer](mailto:nmiller217@gmail.com). From 3e7b06e4e02eb153557bc1c3bd0a0ba79080dacb Mon Sep 17 00:00:00 2001 From: Nathan Miller Date: Sun, 18 Feb 2024 20:08:19 -0800 Subject: [PATCH 06/15] fix markdown lint warning --- docs/CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/CONTRIBUTING.md b/docs/CONTRIBUTING.md index cfe027f6..bcb16753 100644 --- a/docs/CONTRIBUTING.md +++ b/docs/CONTRIBUTING.md @@ -2,4 +2,4 @@ The project is happy to accept pull requests if you would like to contribute. Please open an issue to discuss your proposed changes before submitting a pull request. Pull requests are accepted against the `development` branch. Please make sure your pull request is up to date with the latest changes in the `development` branch before submitting it. -All contributed code must be covered by accompanying test cases. Please make sure your changes are covered by test cases before submitting a pull request. \ No newline at end of file +All contributed code must be covered by accompanying test cases. Please make sure your changes are covered by test cases before submitting a pull request. From 037e9779da1e865db11c8efbca2cbfdbba481dd6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 19 Feb 2024 06:17:23 +0000 Subject: [PATCH 07/15] Bump docker/scout-action from 1.4.1 to 1.5.0 Bumps [docker/scout-action](https://github.com/docker/scout-action) from 1.4.1 to 1.5.0. - [Release notes](https://github.com/docker/scout-action/releases) - [Commits](https://github.com/docker/scout-action/compare/4a5494eb7c2b3d712b805ee65ad57a0371d50874...67eb1afe777307506aaecb9acd9a0e0389cb99ae) --- updated-dependencies: - dependency-name: docker/scout-action dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .github/workflows/docker-scout-scan.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker-scout-scan.yml b/.github/workflows/docker-scout-scan.yml index a4c0c122..1e7d8da0 100644 --- a/.github/workflows/docker-scout-scan.yml +++ b/.github/workflows/docker-scout-scan.yml @@ -133,7 +133,7 @@ jobs: - name: Analyze for critical and high CVEs id: docker-scout-cves # if: ${{ github.event_name != 'pull_request_target' }} - uses: docker/scout-action@4a5494eb7c2b3d712b805ee65ad57a0371d50874 # v1.4.1 + uses: docker/scout-action@67eb1afe777307506aaecb9acd9a0e0389cb99ae # v1.5.0 with: command: cves,recommendations image: ${{ steps.meta.outputs.tags }} @@ -150,7 +150,7 @@ jobs: - name: Docker Scout Compare to Latest id: docker-scout if: ${{ github.event_name == 'pull_request' }} - uses: docker/scout-action@4a5494eb7c2b3d712b805ee65ad57a0371d50874 # v1.4.1 + uses: docker/scout-action@67eb1afe777307506aaecb9acd9a0e0389cb99ae # v1.5.0 with: command: compare image: ${{ steps.meta.outputs.tags }} From b25f6c416546db855684b10480a0466a0554495c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 19 Feb 2024 06:17:41 +0000 Subject: [PATCH 08/15] Bump dawidd6/action-download-artifact from 3.0.0 to 3.1.1 Bumps [dawidd6/action-download-artifact](https://github.com/dawidd6/action-download-artifact) from 3.0.0 to 3.1.1. - [Release notes](https://github.com/dawidd6/action-download-artifact/releases) - [Commits](https://github.com/dawidd6/action-download-artifact/compare/e7466d1a7587ed14867642c2ca74b5bcc1e19a2d...72aaadce3bc708349fc665eee3785cbb1b6e51d0) --- updated-dependencies: - dependency-name: dawidd6/action-download-artifact dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .github/workflows/create-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml index 5f196ca9..485bf930 100644 --- a/.github/workflows/create-release.yml +++ b/.github/workflows/create-release.yml @@ -47,7 +47,7 @@ jobs: uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - name: Download Artifacts - uses: dawidd6/action-download-artifact@e7466d1a7587ed14867642c2ca74b5bcc1e19a2d # v3.0.0 + uses: dawidd6/action-download-artifact@72aaadce3bc708349fc665eee3785cbb1b6e51d0 # v3.1.1 with: workflow: cmake-multi-platform.yml workflow_conclusion: success From b06f26ff3dcf8cff0efc64fa989e4eea6cecb578 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 19 Feb 2024 16:31:52 +0000 Subject: [PATCH 09/15] Bump actions/jekyll-build-pages from 1.0.11 to 1.0.12 Bumps [actions/jekyll-build-pages](https://github.com/actions/jekyll-build-pages) from 1.0.11 to 1.0.12. - [Release notes](https://github.com/actions/jekyll-build-pages/releases) - [Commits](https://github.com/actions/jekyll-build-pages/compare/3ef60073fe85b3ccba7e900c2ebf9d7542dc7a8f...b178f9334b208360999a0a57b523613563698c66) --- updated-dependencies: - dependency-name: actions/jekyll-build-pages dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .github/workflows/jekyll-gh-pages.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/jekyll-gh-pages.yml b/.github/workflows/jekyll-gh-pages.yml index e9c34da5..e62cefca 100644 --- a/.github/workflows/jekyll-gh-pages.yml +++ b/.github/workflows/jekyll-gh-pages.yml @@ -38,7 +38,7 @@ jobs: uses: actions/configure-pages@1f0c5cde4bc74cd7e1254d0cb4de8d49e9068c7d # v4.0.0 - name: Build with Jekyll - uses: actions/jekyll-build-pages@3ef60073fe85b3ccba7e900c2ebf9d7542dc7a8f # v1.0.11 + uses: actions/jekyll-build-pages@b178f9334b208360999a0a57b523613563698c66 # v1.0.12 with: source: ./docs destination: ./_site From 26c6a08269c5530cc8dd0b9712ea670ccfe64e39 Mon Sep 17 00:00:00 2001 From: Nathan Miller Date: Mon, 19 Feb 2024 08:39:33 -0800 Subject: [PATCH 10/15] add labels to match annotations --- .github/workflows/docker-publish.yml | 6 +++++- Dockerfile | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 6ffb0f1e..bb802d3e 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -103,7 +103,11 @@ jobs: org.opencontainers.image.revision=${{ github.sha }} org.opencontainers.image.created=${{ env.CURRENT_DATETIME }} org.opencontainers.image.title=OdbDesign Server - + labels: | + org.opencontainers.image.version=${{ github.ref_name }}-${{github.run_number}} + org.opencontainers.image.revision=${{ github.sha }} + org.opencontainers.image.created=${{ env.CURRENT_DATETIME }} + # Build and push Docker image with Buildx (don't push on PR) # https://github.com/docker/build-push-action - name: Build and push Docker image diff --git a/Dockerfile b/Dockerfile index 3290020b..70093daa 100644 --- a/Dockerfile +++ b/Dockerfile @@ -72,7 +72,11 @@ FROM --platform=$BUILDPLATFORM debian:bookworm-20240211-slim@sha256:d02c76d82364 LABEL org.opencontainers.image.source=https://github.com/nam20485/OdbDesign \ org.opencontainers.image.authors=https://github.com/nam20485 \ org.opencontainers.image.description="A free open source cross-platform C++ library for parsing ODB++ Design archives and accessing their data. Exposed via a REST API and packaged inside of a Docker image. The OdbDesign Docker image runs the OdbDesignServer REST API server executable, listening on port 8888." \ - org.opencontainers.image.licenses=MIT + org.opencontainers.image.licenses=MIT \ + org.opencontainers.image.url=https://nam20485.github.io/OdbDesign \ + org.opencontainers.image.documentation=https://github.com/nam20485/OdbDesign?tab=readme-ov-file \ + org.opencontainers.image.title="OdbDesign Server" + EXPOSE 8888 RUN mkdir --parents /OdbDesign/bin From 43a93de9a5eec1dcc58dbe6a9dddebc51991b01c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 19 Feb 2024 16:48:32 +0000 Subject: [PATCH 11/15] Bump github/codeql-action from 3.24.1 to 3.24.3 Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.24.1 to 3.24.3. - [Release notes](https://github.com/github/codeql-action/releases) - [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md) - [Commits](https://github.com/github/codeql-action/compare/e675ced7a7522a761fc9c8eb26682c8b27c42b2b...379614612a29c9e28f31f39a59013eb8012a51f0) --- updated-dependencies: - dependency-name: github/codeql-action dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .github/workflows/codeql.yml | 4 ++-- .github/workflows/docker-scout-scan.yml | 2 +- .github/workflows/scorecard.yml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 61185f57..b4c0d1ef 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -52,7 +52,7 @@ jobs: # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@e675ced7a7522a761fc9c8eb26682c8b27c42b2b # v3.24.1 + uses: github/codeql-action/init@379614612a29c9e28f31f39a59013eb8012a51f0 # v3.24.3 with: languages: ${{ matrix.language }} config-file: ${{ github.workspace }}/.github/codeql-config.yml @@ -83,6 +83,6 @@ jobs: run: cmake --build --preset linux-release - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@e675ced7a7522a761fc9c8eb26682c8b27c42b2b # v3.24.1 + uses: github/codeql-action/analyze@379614612a29c9e28f31f39a59013eb8012a51f0 # v3.24.3 with: category: "/language:${{matrix.language}}" diff --git a/.github/workflows/docker-scout-scan.yml b/.github/workflows/docker-scout-scan.yml index a4c0c122..79a2199f 100644 --- a/.github/workflows/docker-scout-scan.yml +++ b/.github/workflows/docker-scout-scan.yml @@ -143,7 +143,7 @@ jobs: - name: Upload SARIF result id: upload-sarif - uses: github/codeql-action/upload-sarif@e675ced7a7522a761fc9c8eb26682c8b27c42b2b # v3.24.1 + uses: github/codeql-action/upload-sarif@379614612a29c9e28f31f39a59013eb8012a51f0 # v3.24.3 with: sarif_file: sarif.output.json diff --git a/.github/workflows/scorecard.yml b/.github/workflows/scorecard.yml index f2ced069..e99065c0 100644 --- a/.github/workflows/scorecard.yml +++ b/.github/workflows/scorecard.yml @@ -75,6 +75,6 @@ jobs: # Upload the results to GitHub's code scanning dashboard. - name: "Upload to code-scanning" - uses: github/codeql-action/upload-sarif@e675ced7a7522a761fc9c8eb26682c8b27c42b2b # v3.24.1 + uses: github/codeql-action/upload-sarif@379614612a29c9e28f31f39a59013eb8012a51f0 # v3.24.3 with: sarif_file: results.sarif From a8bac13861bbb72875d0aa2da220eacacbbd177d Mon Sep 17 00:00:00 2001 From: Nathan Miller Date: Mon, 19 Feb 2024 11:29:18 -0800 Subject: [PATCH 12/15] rename and change IRequestAuthentication class from pure virtual interface to a abstract base class --- OdbDesignLib/App/IRequestAuthentication.cpp | 6 ---- .../App/RequestAuthenticationBase.cpp | 31 +++++++++++++++++++ ...tication.h => RequestAuthenticationBase.h} | 10 ++++-- 3 files changed, 38 insertions(+), 9 deletions(-) delete mode 100644 OdbDesignLib/App/IRequestAuthentication.cpp create mode 100644 OdbDesignLib/App/RequestAuthenticationBase.cpp rename OdbDesignLib/App/{IRequestAuthentication.h => RequestAuthenticationBase.h} (52%) diff --git a/OdbDesignLib/App/IRequestAuthentication.cpp b/OdbDesignLib/App/IRequestAuthentication.cpp deleted file mode 100644 index f7a40168..00000000 --- a/OdbDesignLib/App/IRequestAuthentication.cpp +++ /dev/null @@ -1,6 +0,0 @@ -#include "IRequestAuthentication.h" - -namespace Odb::Lib::App -{ - -} \ No newline at end of file diff --git a/OdbDesignLib/App/RequestAuthenticationBase.cpp b/OdbDesignLib/App/RequestAuthenticationBase.cpp new file mode 100644 index 00000000..6fbcd5c3 --- /dev/null +++ b/OdbDesignLib/App/RequestAuthenticationBase.cpp @@ -0,0 +1,31 @@ +#include "RequestAuthenticationBase.h" +#include "macros.h" + +using namespace Utils; + +namespace Odb::Lib::App +{ + RequestAuthenticationBase::RequestAuthenticationBase(bool disableAuthentication) + : m_disableAuthentication(disableAuthentication) + { + } + + crow::response RequestAuthenticationBase::AuthenticateRequest(const crow::request& req) + { + // if running debug build AND in Local environment, bypass authentication + if (IsDebug() && IsLocal()) + { + // 200 Authorized! + return crow::response(200, "Authorized"); + } + else if (m_disableAuthentication) + { + // 200 Authorized! + return crow::response(200, "Authorized"); + } + else + { + return crow::response(401, "Unauthorized"); + } + } +} \ No newline at end of file diff --git a/OdbDesignLib/App/IRequestAuthentication.h b/OdbDesignLib/App/RequestAuthenticationBase.h similarity index 52% rename from OdbDesignLib/App/IRequestAuthentication.h rename to OdbDesignLib/App/RequestAuthenticationBase.h index bf7bc5a5..04aeda12 100644 --- a/OdbDesignLib/App/IRequestAuthentication.h +++ b/OdbDesignLib/App/RequestAuthenticationBase.h @@ -5,14 +5,18 @@ namespace Odb::Lib::App { - class ODBDESIGN_EXPORT IRequestAuthentication + class ODBDESIGN_EXPORT RequestAuthenticationBase { public: - virtual crow::response AuthenticateRequest(const crow::request& req) = 0; + virtual crow::response AuthenticateRequest(const crow::request& req); protected: + RequestAuthenticationBase(bool disableAuthentication); + // pure virtual interface - IRequestAuthentication() = default; + RequestAuthenticationBase() = default; + + bool m_disableAuthentication = false; }; } From bd528123aac007e78c4573ca99ec6269627fba84 Mon Sep 17 00:00:00 2001 From: Nathan Miller Date: Mon, 19 Feb 2024 11:29:46 -0800 Subject: [PATCH 13/15] add --disable-authentication argument --- OdbDesignLib/App/OdbDesignArgs.cpp | 6 ++++++ OdbDesignLib/App/OdbDesignArgs.h | 2 ++ 2 files changed, 8 insertions(+) diff --git a/OdbDesignLib/App/OdbDesignArgs.cpp b/OdbDesignLib/App/OdbDesignArgs.cpp index e49c44f3..e44513d6 100644 --- a/OdbDesignLib/App/OdbDesignArgs.cpp +++ b/OdbDesignLib/App/OdbDesignArgs.cpp @@ -48,6 +48,11 @@ namespace Odb::Lib::App return boolArg("load-all", DEFAULT_LOAD_ALL); } + bool OdbDesignArgs::disableAuthentication() const + { + return boolArg("disable-authentication", DEFAULT_DISABLE_AUTH); + } + std::string OdbDesignArgs::getUsageString() const { std::stringstream ss; @@ -60,6 +65,7 @@ namespace Odb::Lib::App ss << " --templates-dir Directory containing template files (default: " << DEFAULT_TEMPLATES_DIR << ")\n"; ss << " --load-design Design to load on startup (default: " << DEFAULT_LOAD_DESIGN << ")\n"; ss << " --load-all Load all designs on startup (default: " << (DEFAULT_LOAD_ALL ? "true" : "false") << ")\n"; + ss << " --disable-authentication Disable authentication (default: " << (DEFAULT_DISABLE_AUTH ? "true" : "false") << ")\n"; ss << " --help Print this help message\n"; return ss.str(); } diff --git a/OdbDesignLib/App/OdbDesignArgs.h b/OdbDesignLib/App/OdbDesignArgs.h index ea0400be..93b0973b 100644 --- a/OdbDesignLib/App/OdbDesignArgs.h +++ b/OdbDesignLib/App/OdbDesignArgs.h @@ -18,6 +18,7 @@ namespace Odb::Lib::App bool help() const; std::string loadDesign() const; bool loadAll() const; + bool disableAuthentication() const; protected: // Inherited via CommandLineArgs @@ -32,6 +33,7 @@ namespace Odb::Lib::App constexpr static const bool DEFAULT_HELP = false; constexpr static const char* DEFAULT_LOAD_DESIGN = ""; constexpr static const bool DEFAULT_LOAD_ALL = false; + constexpr static const bool DEFAULT_DISABLE_AUTH = false; }; } From 3b8cbab3b726aadf40a747ec3122eb81c6b21ad5 Mon Sep 17 00:00:00 2001 From: Nathan Miller Date: Mon, 19 Feb 2024 11:30:46 -0800 Subject: [PATCH 14/15] implement support for disabling authentication via CLI argument --- .../App/BasicRequestAuthentication.cpp | 38 ++++++++++--------- OdbDesignLib/App/BasicRequestAuthentication.h | 13 ++++--- OdbDesignLib/App/IOdbServerApp.h | 6 +-- OdbDesignLib/App/OdbServerAppBase.cpp | 4 +- OdbDesignLib/App/OdbServerAppBase.h | 8 ++-- OdbDesignLib/CMakeLists.txt | 2 +- OdbDesignServer/OdbDesignServerApp.cpp | 3 +- 7 files changed, 39 insertions(+), 35 deletions(-) diff --git a/OdbDesignLib/App/BasicRequestAuthentication.cpp b/OdbDesignLib/App/BasicRequestAuthentication.cpp index a5cd632c..3e2d4abd 100644 --- a/OdbDesignLib/App/BasicRequestAuthentication.cpp +++ b/OdbDesignLib/App/BasicRequestAuthentication.cpp @@ -6,32 +6,34 @@ using namespace Utils; namespace Odb::Lib::App { + BasicRequestAuthentication::BasicRequestAuthentication(bool disableAuthentication) + : RequestAuthenticationBase(disableAuthentication) + { + } + crow::response BasicRequestAuthentication::AuthenticateRequest(const crow::request& req) { - // if running debug build AND in Local environment, bypass authentication - if (IsDebug() && IsLocal()) + auto resp = RequestAuthenticationBase::AuthenticateRequest(req); + if (resp.code != crow::status::OK) { - // 200 Authorized! - return crow::response(200, "Authorized"); - } + const auto& authHeader = req.get_header_value(AUTHORIZATION_HEADER_NAME); + if (authHeader.empty()) return crow::response(401, "Unauthorized"); - 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 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 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 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); + 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); + //if (! VerifyCredentials(username, password)) return crow::response(403, "Invalid username or password"); + resp = VerifyCredentials(username, password); + } return resp; } diff --git a/OdbDesignLib/App/BasicRequestAuthentication.h b/OdbDesignLib/App/BasicRequestAuthentication.h index 63f94d07..54e6bffd 100644 --- a/OdbDesignLib/App/BasicRequestAuthentication.h +++ b/OdbDesignLib/App/BasicRequestAuthentication.h @@ -1,26 +1,27 @@ #pragma once -#include "IRequestAuthentication.h" +#include "RequestAuthenticationBase.h" #include "../odbdesign_export.h" namespace Odb::Lib::App { - class ODBDESIGN_EXPORT BasicRequestAuthentication : public IRequestAuthentication + class ODBDESIGN_EXPORT BasicRequestAuthentication : public RequestAuthenticationBase { public: - //BasicRequestAuthentication() - //{ - //} + BasicRequestAuthentication(bool disableAuthentication); - // Inherited via IRequestAuthentication + // Inherited via RequestAuthenticationBase crow::response AuthenticateRequest(const crow::request& req) override; private: + const inline static char AUTHORIZATION_HEADER_NAME[] = "Authorization"; + 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"; + }; } diff --git a/OdbDesignLib/App/IOdbServerApp.h b/OdbDesignLib/App/IOdbServerApp.h index 79c1afa8..7356141f 100644 --- a/OdbDesignLib/App/IOdbServerApp.h +++ b/OdbDesignLib/App/IOdbServerApp.h @@ -2,7 +2,7 @@ #include "IOdbApp.h" #include "../odbdesign_export.h" -#include "IRequestAuthentication.h" +#include "RequestAuthenticationBase.h" namespace Odb::Lib::App { @@ -12,8 +12,8 @@ namespace Odb::Lib::App virtual ~IOdbServerApp() {} virtual CrowApp& crow_app() = 0; - virtual IRequestAuthentication& request_auth() = 0; - virtual void request_auth(std::unique_ptr requestAuthentication) = 0; + virtual RequestAuthenticationBase& request_auth() = 0; + virtual void request_auth(std::unique_ptr requestAuthentication) = 0; protected: IOdbServerApp() = default; diff --git a/OdbDesignLib/App/OdbServerAppBase.cpp b/OdbDesignLib/App/OdbServerAppBase.cpp index 8a2a80ec..6dd7c0d8 100644 --- a/OdbDesignLib/App/OdbServerAppBase.cpp +++ b/OdbDesignLib/App/OdbServerAppBase.cpp @@ -99,12 +99,12 @@ namespace Odb::Lib::App return m_crowApp; } - IRequestAuthentication& OdbServerAppBase::request_auth() + RequestAuthenticationBase& OdbServerAppBase::request_auth() { return *m_pRequestAuthentication; } - void OdbServerAppBase::request_auth(std::unique_ptr pRequestAuthentication) + void OdbServerAppBase::request_auth(std::unique_ptr pRequestAuthentication) { m_pRequestAuthentication = std::move(pRequestAuthentication); } diff --git a/OdbDesignLib/App/OdbServerAppBase.h b/OdbDesignLib/App/OdbServerAppBase.h index 9db46ab7..41be69e8 100644 --- a/OdbDesignLib/App/OdbServerAppBase.h +++ b/OdbDesignLib/App/OdbServerAppBase.h @@ -4,7 +4,7 @@ #include "OdbAppBase.h" #include "RouteController.h" #include "../odbdesign_export.h" -#include "IRequestAuthentication.h" +#include "RequestAuthenticationBase.h" #include "BasicRequestAuthentication.h" namespace Odb::Lib::App @@ -16,8 +16,8 @@ namespace Odb::Lib::App CrowApp& crow_app() override; - IRequestAuthentication& request_auth() override; - void request_auth(std::unique_ptr pRequestAuthentication) override; + RequestAuthenticationBase& request_auth() override; + void request_auth(std::unique_ptr pRequestAuthentication) override; Utils::ExitCode Run() override; @@ -35,7 +35,7 @@ namespace Odb::Lib::App private: CrowApp m_crowApp; //crow::SimpleApp m_crowApp; - std::unique_ptr m_pRequestAuthentication; + std::unique_ptr m_pRequestAuthentication; void register_routes(); diff --git a/OdbDesignLib/CMakeLists.txt b/OdbDesignLib/CMakeLists.txt index b5b2789f..4eaa8e1c 100644 --- a/OdbDesignLib/CMakeLists.txt +++ b/OdbDesignLib/CMakeLists.txt @@ -37,7 +37,7 @@ add_library(OdbDesign SHARED "ProtoBuf/via.pb.h" "ProtoBuf/via.pb.cc" "ProtoBuf/package.pb.h" "ProtoBuf/package.pb.cc" "FileModel/parse_error.h" "FileModel/parse_info.h" "FileModel/parse_info.cpp" "FileModel/parse_error.cpp" "FileModel/invalid_odb_error.h" "FileModel/invalid_odb_error.cpp" "ProtoBuf/common.pb.h" "ProtoBuf/common.pb.cc" "ProtoBuf/componentsfile.pb.h" "ProtoBuf/componentsfile.pb.cc" "FileModel/Design/PropertyRecord.h" "FileModel/Design/PropertyRecord.cpp" "FileModel/Design/FeaturesFile.h" "FileModel/Design/FeaturesFile.cpp" "FileModel/Design/ContourPolygon.h" "FileModel/Design/ContourPolygon.cpp" "FileModel/Design/SymbolName.h" "FileModel/Design/SymbolName.cpp" "FileModel/Design/SymbolsDirectory.h" "FileModel/Design/SymbolsDirectory.cpp" "FileModel/Design/StepHdrFile.h" "FileModel/Design/StepHdrFile.cpp" "FileModel/Design/AttributeLookupTable.h" "FileModel/Design/AttributeLookupTable.cpp" - "App/IRequestAuthentication.h" "App/IRequestAuthentication.cpp" "App/BasicRequestAuthentication.h" "App/BasicRequestAuthentication.cpp") + "App/RequestAuthenticationBase.h" "App/RequestAuthenticationBase.cpp" "App/BasicRequestAuthentication.h" "App/BasicRequestAuthentication.cpp") # disable warning C4250: inheritance by dominance target_compile_options(OdbDesign PUBLIC diff --git a/OdbDesignServer/OdbDesignServerApp.cpp b/OdbDesignServer/OdbDesignServerApp.cpp index 55bba60a..f39240fd 100644 --- a/OdbDesignServer/OdbDesignServerApp.cpp +++ b/OdbDesignServer/OdbDesignServerApp.cpp @@ -64,7 +64,8 @@ namespace Odb::App::Server } // add authentication - auto basicRequestAuth = std::make_unique(BasicRequestAuthentication()); + bool disableAuth = args().disableAuthentication(); + auto basicRequestAuth = std::make_unique(BasicRequestAuthentication(disableAuth)); request_auth(std::move(basicRequestAuth)); return true; From 391fd37dd035a5a45460530f72faa6d56e7fd06d Mon Sep 17 00:00:00 2001 From: Nathan Miller Date: Mon, 19 Feb 2024 11:42:47 -0800 Subject: [PATCH 15/15] use yaml folding block for multiline json string key value --- .github/workflows/docker-publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index bb802d3e..3bf94bfb 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -147,7 +147,7 @@ jobs: with: repository: ${{ github.repository }} event-type: trigger_deploy_release_event - client-payload: | + client-payload: > '{ "ref_name": "${{ github.ref_name }}", "run_number": "${{ github.run_number }}",