From e7a6f54ff9f692da7669eddd7d6849d6a373b0a2 Mon Sep 17 00:00:00 2001 From: Ethan Knowlton Date: Tue, 14 Nov 2023 03:46:03 -0500 Subject: [PATCH 1/4] chore(jwt): cleaning up JWT tests and checks --- cmd/echoip/main.go | 2 +- http/jwt_test.go | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cmd/echoip/main.go b/cmd/echoip/main.go index 195e518..9d3790c 100644 --- a/cmd/echoip/main.go +++ b/cmd/echoip/main.go @@ -108,7 +108,7 @@ func main() { serverCache = &cache.Null{} } - if len(runConfig.Jwt.PublicKey) != 0 { + if runConfig.Jwt.Enabled && len(runConfig.Jwt.PublicKey) != 0 { log.Printf("Loading public key from %s", runConfig.Jwt.PublicKey) pubKey, err := os.ReadFile(runConfig.Jwt.PublicKey) diff --git a/http/jwt_test.go b/http/jwt_test.go index 1d287ea..c96e32e 100644 --- a/http/jwt_test.go +++ b/http/jwt_test.go @@ -7,11 +7,11 @@ import ( "github.com/stretchr/testify/assert" ) -const ecdsaPublicKey = `-----BEGIN PUBLIC KEY----- +const EcdsaPublicKey = `-----BEGIN PUBLIC KEY----- MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEEVs/o5+uQbTjL3chynL4wXgUg2R9 q9UU8I5mEovUf86QZ7kOBIjJwqnzD1omageEHWwHdBO6B+dFabmdT9POxg== -----END PUBLIC KEY-----` -const ecdsaToken = `eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiYWRtaW4iOnRydWUsImlhdCI6MTUxNjIzOTAyMn0.tyh-VfuzIxCyGYDlkBA7DfyjrqmSHu6pQ2hoZuFqUSLPNY2N0mpHb3nk5K17HWP_3cYHBw7AhHale5wky6-sVA` +const EcdsaToken = `eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiYWRtaW4iOnRydWUsImlhdCI6MTUxNjIzOTAyMn0.tyh-VfuzIxCyGYDlkBA7DfyjrqmSHu6pQ2hoZuFqUSLPNY2N0mpHb3nk5K17HWP_3cYHBw7AhHale5wky6-sVA` const rsaPublicKey = `-----BEGIN PUBLIC KEY----- MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAu1SU1LfVLPHCozMxH2Mo @@ -32,9 +32,9 @@ func TestGetTokenKeyWithECDSAKey(t *testing.T) { Debug: true, Jwt: config.Jwt{ SigningMethod: "ES256", - PublicKeyData: []byte(ecdsaPublicKey), + PublicKeyData: []byte(EcdsaPublicKey), }, - }, ecdsaToken) + }, EcdsaToken) assert.Nil(t, err) } From 823983800e52c7842136f5078e8f02016d0be0fe Mon Sep 17 00:00:00 2001 From: Ethan Knowlton Date: Tue, 14 Nov 2023 03:46:55 -0500 Subject: [PATCH 2/4] chore(ci): finish configuring creating releases in CI --- .github/release.yml | 16 ++++++++ .github/workflows/release-please.yaml | 55 +++++++++++++++++++++++++++ .github/workflows/release.yaml | 32 ---------------- .github/workflows/test.yaml | 7 +++- 4 files changed, 76 insertions(+), 34 deletions(-) create mode 100644 .github/release.yml create mode 100644 .github/workflows/release-please.yaml delete mode 100644 .github/workflows/release.yaml diff --git a/.github/release.yml b/.github/release.yml new file mode 100644 index 0000000..f2ed4b0 --- /dev/null +++ b/.github/release.yml @@ -0,0 +1,16 @@ +changelog: + exclude: + labels: + - ignore-for-release + + categories: + - title: Breaking Changes 🛠 + labels: + - major + - breaking-change + - title: New Features 🎉 + labels: + - minor + - feature + - title: Other + diff --git a/.github/workflows/release-please.yaml b/.github/workflows/release-please.yaml new file mode 100644 index 0000000..154c6a0 --- /dev/null +++ b/.github/workflows/release-please.yaml @@ -0,0 +1,55 @@ +name: Release Please + +on: + pull_request: + types: + - closed + +permissions: + contents: write + pull-requests: write + +jobs: + test: + if: | + github.event.pull_request.merged == true && + github.ref_name == "master" && + contains(github.event.pull_request.head.name, "release") + uses: ./.github/workflows/test.yaml + + release-please: + if: | + github.event.pull_request.merged == true && + github.ref_name == "master" && + contains(github.event.pull_request.head.name, "release") + runs-on: ubuntu-latest + needs: [test] + steps: + - uses: actions/checkout@v2 + + - name: Setup Go + uses: actions/setup-go@v4 + with: + go-version: "1.18.x" + + - name: Build EchoIP binary + run: go build -o ./echoip ./cmd/echoip/main.go + + - name: Upload Release Artifact + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + zip -r echoip-linux-amd64.zip echoip html LICENSE + + - uses: google-github-actions/release-please-action@v3 + with: + bootstrap-sha: "ef1f4b388c24e977ec63d6943ac8f0b0c5f51b58" + last-release-sha: "32a92399085082121675553e23d722605752519e" + release-type: "go" + release-as: "1.1.0" + command: "release-pr" + extra-files: | + echoip-linux-amd64-${{ github.ref_name }}.zip + echoip + html + LICENSE diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml deleted file mode 100644 index d63e53f..0000000 --- a/.github/workflows/release.yaml +++ /dev/null @@ -1,32 +0,0 @@ -name: Release - -on: - push: - tags: - - "*" - -jobs: - release: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - - name: Setup Go - uses: actions/setup-go@v4 - with: - go-version: "1.18.x" - - - name: Build EchoIP binary - run: go build -o ./echoip ./cmd/echoip/main.go - - - name: Upload Release Artifact - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - zip -r echoip-linux-amd64-${{ github.ref_name }}.zip echoip html LICENSE - - - name: Create Release - uses: ncipollo/release-action@v1 - with: - artifacts: echoip-linux-amd64-${{ github.ref_name }}.zip - bodyFile: "CHANGELOG.md" diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 1637865..312feb8 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -1,10 +1,13 @@ name: Test -on: [push] +on: + push: + branches: + - "*" + - "!master" jobs: test: - runs-on: ubuntu-latest steps: From 082dedcac78c8f0b30ef6375fbdf30b53c860d5c Mon Sep 17 00:00:00 2001 From: Ethan Knowlton Date: Tue, 14 Nov 2023 03:48:41 -0500 Subject: [PATCH 3/4] chore(other): cleaning up change log, added config file flag to systemd file --- CHANGELOG.md | 10 +++------- etc/systemd/system/echoip.service | 2 +- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b960b92..d25b3c8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,18 +1,14 @@ # Changelog -## 1.2.0 (2023-10-06) +## 1.1.0 (2023-11-14) ### Features +- RSA JWT Signature Validation +- ECDSA JWT Signature Validation - JWT Authentication - -## 1.1.0 (2023-10-06) - -### Features - - Environment Variable Configuration [712e216](https://github.com/levelsoftware/echoip/commit/712e2166d51fdb85229f52caa380743245f31dfa) - ## 1.0.0 (2023-10-06) ### Features diff --git a/etc/systemd/system/echoip.service b/etc/systemd/system/echoip.service index f766165..b0372b9 100644 --- a/etc/systemd/system/echoip.service +++ b/etc/systemd/system/echoip.service @@ -6,7 +6,7 @@ After=network.target Type=simple User=web -ExecStart=/usr/local/bin/echoip +ExecStart=/usr/local/bin/echoip -c /etc/echoip/config.toml Restart=always RestartSec=5s StandardOutput=syslog From cf59e4401a4ad5419734ec7d91b1c7da09b2fa83 Mon Sep 17 00:00:00 2001 From: Ethan Knowlton Date: Tue, 14 Nov 2023 03:49:13 -0500 Subject: [PATCH 4/4] feat(ipstack): added currency module to IP Stack response for parser --- iputil/ipstack/ipstack.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/iputil/ipstack/ipstack.go b/iputil/ipstack/ipstack.go index f506366..19fc087 100644 --- a/iputil/ipstack/ipstack.go +++ b/iputil/ipstack/ipstack.go @@ -48,6 +48,7 @@ func (ips *IPStack) Parse(ip net.IP, hostname string) (parser.Response, error) { ips.ParseTimezoneResponse(&parserResponse) ips.ParseLocationResponse(&parserResponse) ips.ParseConnectionResponse(&parserResponse) + ips.ParseCurrencyResponse(&parserResponse) return parserResponse, nil } @@ -116,6 +117,18 @@ func (ips *IPStack) ParseConnectionResponse(parserResponse *parser.Response) { } } +func (ips *IPStack) ParseCurrencyResponse(parserResponse *parser.Response) { + if ips.response.Currency != nil { + parserResponse.Currency = parser.Currency{ + Code: parserResponse.Currency.Code, + Name: parserResponse.Currency.Name, + Plural: parserResponse.Currency.Plural, + Symbol: parserResponse.Currency.Symbol, + SymbolNative: parserResponse.Currency.SymbolNative, + } + } +} + func (ips *IPStack) IsEmpty() bool { return false }