Skip to content

Commit 5b4ec2e

Browse files
committed
Merge branch 'develop' into feature/cleanup-update
2 parents c25c1dc + a59d36a commit 5b4ec2e

32 files changed

+598
-405
lines changed

.dockerignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
# Whitelist required files
55
!.env.encrypted
6-
!codeship/*
6+
!scripts/*
77
!lambda/*
88
!server/*
99
!u2fsimulator/*

.github/CODEOWNERS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
* @silinternational/developers
2+
*.tf @silinternational/tf-devs
3+
*.go @silinternational/go-devs
4+
go.* @silinternational/go-devs
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
name: Test, Deploy, Publish
2+
3+
on:
4+
push:
5+
branches: [ '**' ]
6+
tags: [ 'v*' ]
7+
paths-ignore:
8+
- 'terraform/**'
9+
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.ref }}
12+
cancel-in-progress: false
13+
14+
jobs:
15+
tests:
16+
name: Tests
17+
runs-on: ubuntu-latest
18+
env:
19+
AWS_REGION: ${{ vars.AWS_REGION }}
20+
STG_AWS_ACCESS_KEY_ID: ${{ vars.STG_AWS_ACCESS_KEY_ID }}
21+
STG_AWS_SECRET_ACCESS_KEY: ${{ secrets.STG_AWS_SECRET_ACCESS_KEY }}
22+
PRD_AWS_ACCESS_KEY_ID: ${{ vars.PRD_AWS_ACCESS_KEY_ID }}
23+
PRD_AWS_SECRET_ACCESS_KEY: ${{ secrets.PRD_AWS_SECRET_ACCESS_KEY }}
24+
steps:
25+
- name: Checkout code
26+
uses: actions/checkout@v4
27+
- name: Test
28+
run: docker compose -f actions-services.yml run --rm test ./scripts/test.sh
29+
30+
lint:
31+
name: Lint and Vulnerability Scan
32+
runs-on: ubuntu-latest
33+
timeout-minutes: ${{ fromJSON(vars.DEFAULT_JOB_TIMEOUT_MINUTES) }}
34+
steps:
35+
- uses: actions/checkout@v4
36+
- uses: actions/setup-go@v5
37+
with:
38+
go-version-file: 'go.mod'
39+
check-latest: true
40+
- name: golangci-lint
41+
uses: golangci/golangci-lint-action@v6
42+
with:
43+
version: latest
44+
- name: govulncheck
45+
run: |
46+
go install golang.org/x/vuln/cmd/govulncheck@latest
47+
govulncheck ./...
48+
49+
deploy:
50+
name: Deploy to AWS Lambda
51+
needs: [ 'tests', 'lint' ]
52+
if: github.ref_name == 'main' || github.ref_name == 'develop'
53+
runs-on: ubuntu-latest
54+
concurrency:
55+
group: deploy-${{ github.ref }}-${{ matrix.region }}
56+
cancel-in-progress: false
57+
strategy:
58+
matrix:
59+
region: [ us-east-1, us-west-2 ]
60+
env:
61+
AWS_REGION: ${{ vars.AWS_REGION }}
62+
STG_AWS_ACCESS_KEY_ID: ${{ vars.STG_AWS_ACCESS_KEY_ID }}
63+
STG_AWS_SECRET_ACCESS_KEY: ${{ secrets.STG_AWS_SECRET_ACCESS_KEY }}
64+
STG_LAMBDA_ROLE: ${{ vars.STG_LAMBDA_ROLE }}
65+
STG_API_KEY_TABLE: ${{ vars.STG_API_KEY_TABLE }}
66+
STG_WEBAUTHN_TABLE: ${{ vars.STG_WEBAUTHN_TABLE }}
67+
PRD_AWS_ACCESS_KEY_ID: ${{ vars.PRD_AWS_ACCESS_KEY_ID }}
68+
PRD_AWS_SECRET_ACCESS_KEY: ${{ secrets.PRD_AWS_SECRET_ACCESS_KEY }}
69+
PRD_LAMBDA_ROLE: ${{ vars.PRD_LAMBDA_ROLE }}
70+
PRD_API_KEY_TABLE: ${{ vars.PRD_API_KEY_TABLE }}
71+
PRD_WEBAUTHN_TABLE: ${{ vars.PRD_WEBAUTHN_TABLE }}
72+
73+
steps:
74+
- name: Checkout code
75+
uses: actions/checkout@v4
76+
- name: Deploy
77+
run: docker compose -f actions-services.yml run --rm app ./scripts/deploy.sh ${{ matrix.region }}
78+
79+
build-and-publish:
80+
name: Build and Publish
81+
needs: [ 'tests', 'lint' ]
82+
runs-on: ubuntu-latest
83+
steps:
84+
- name: Checkout code
85+
uses: actions/checkout@v4
86+
87+
- name: Log in to Docker Hub
88+
uses: docker/login-action@v3
89+
with:
90+
username: ${{ secrets.DOCKERHUB_USERNAME }}
91+
password: ${{ secrets.DOCKERHUB_TOKEN }}
92+
93+
- name: Log in to GitHub Container Registry
94+
uses: docker/login-action@v3
95+
with:
96+
registry: ghcr.io
97+
username: ${{ github.actor}}
98+
password: ${{ secrets.GITHUB_TOKEN}}
99+
100+
- name: Extract metadata (tags, labels) for Docker
101+
id: meta
102+
uses: docker/metadata-action@v5
103+
with:
104+
images: |
105+
${{ vars.IMAGE_NAME }}
106+
ghcr.io/${{ github.repository }}
107+
tags: |
108+
type=ref,event=branch
109+
type=semver,pattern={{version}}
110+
type=semver,pattern={{major.minor}}
111+
type=semver,pattern={{major}}
112+
113+
- name: Build and push Docker image
114+
uses: docker/build-push-action@v5
115+
with:
116+
context: .
117+
push: true
118+
tags: ${{ steps.meta.outputs.tags }}
119+
labels: ${{ steps.meta.outputs.labels }}

.gitignore

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,8 @@ bootstrap
88
dockercfg
99

1010
# credentials and other env files
11-
aws.env
1211
*.aes
13-
local.env
14-
.env
12+
*.env
1513
.cert/
1614

1715
# dev tools metadata

.golangci.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
run:
2+
timeout: 2m
3+
linters:
4+
disable-all: true
5+
enable:
6+
# - errcheck
7+
# - gosimple
8+
# - govet
9+
# - ineffassign
10+
# - staticcheck
11+
# - unused
12+
- bodyclose
13+
- gocheckcompilerdirectives
14+
- godox
15+
# - gofmt
16+
# - goimports
17+
# - gosec
18+
# - whitespace
19+
# - usestdlibvars

Dockerfile

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
1-
FROM golang:1.22
1+
FROM golang:1.23
22

3-
RUN curl -o- -L https://slss.io/install | VERSION=3.38.0 bash && \
3+
RUN curl -o- -L --proto "=https" https://slss.io/install | VERSION=3.38.0 bash && \
44
mv $HOME/.serverless/bin/serverless /usr/local/bin && \
55
ln -s /usr/local/bin/serverless /usr/local/bin/sls
66

77
WORKDIR /src
88

9-
RUN curl -sSfL https://raw.githubusercontent.com/cosmtrek/air/master/install.sh | sh -s -- -b $(go env GOPATH)/bin
9+
RUN curl -sSfL --proto "=https" https://raw.githubusercontent.com/cosmtrek/air/master/install.sh | \
10+
sh -s -- -b $(go env GOPATH)/bin
1011

1112
COPY ./ .
1213
RUN go get ./...
1314

1415
EXPOSE 8080
1516

16-
CMD ["air"]
17+
CMD ["air"]

Makefile

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,21 @@ demo: proxy ui app dbinit
22
./local_data.sh
33

44
proxy:
5-
docker-compose up -d proxy
5+
docker compose up -d proxy
66

77
ui:
8-
docker-compose up -d ui
8+
docker compose up -d ui
99

1010
app:
11-
docker-compose kill app
12-
docker-compose rm -f app
13-
docker-compose up -d app
11+
docker compose kill app
12+
docker compose rm -f app
13+
docker compose up -d app
1414

1515
test: clean dbinit
16-
docker-compose run --rm app go test ./...
16+
docker compose run --rm app go test ./...
1717

1818
db:
19-
docker-compose up -d dynamo
19+
docker compose up -d dynamo
2020

2121
dbinit: db wait createwebauthntable createapikeytable
2222

@@ -55,5 +55,5 @@ showwebauth:
5555
--region localhost
5656

5757
clean:
58-
docker-compose kill
59-
docker-compose rm -f
58+
docker compose kill
59+
docker compose rm -f

README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ to the WebAuthn library and fit the structures it was expecting without causing
2020
### Required Headers
2121
1. `x-mfa-apikey` - The API Key
2222
2. `x-mfa-apisecret` - The API Key Secret
23-
3. `x-mfa-RPDisplayName` - The Relay Party Display Name, ex: `ACME Inc.`
24-
4. `x-mfa-RPID` - The Relay Party ID, ex: `domain.com` (should only be the top level domain, no subdomain, protocol,
23+
3. `x-mfa-RPDisplayName` - The Relying Party Display Name, ex: `ACME Inc.`
24+
4. `x-mfa-RPID` - The Relying Party ID, ex: `domain.com` (should only be the top level domain, no subdomain, protocol,
2525
or path)
2626
5. `x-mfa-RPOrigin` - The browser Origin for the request, ex: `https://sub.domain.com` (include appropriate subdomain
2727
and protocol, no path or port)
@@ -30,6 +30,11 @@ to do with WebAuthn, but is the primary key for finding the right records in Dyn
3030
7. `x-mfa-Username` - The user's username of your service
3131
8. `x-mfa-UserDisplayName` - The user's display name
3232

33+
### Optional headers
34+
35+
1. `x-mfa-Usericon` -
36+
2. `x-mfa-Rpicon` -
37+
3338
### Begin Registration
3439
`POST /webauthn/register`
3540

actions-services.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
services:
2+
test:
3+
build: .
4+
environment:
5+
AWS_ENDPOINT: http://dynamo:8000
6+
API_KEY_TABLE: ApiKey
7+
WEBAUTHN_TABLE: WebAuthn
8+
LAMBDA_ROLE: placeholder
9+
AWS_REGION: localhost
10+
GITHUB_REF_NAME: $GITHUB_REF_NAME
11+
STG_AWS_ACCESS_KEY_ID: $STG_AWS_ACCESS_KEY_ID
12+
STG_AWS_SECRET_ACCESS_KEY: $STG_AWS_SECRET_ACCESS_KEY
13+
PRD_AWS_ACCESS_KEY_ID: $PRD_AWS_ACCESS_KEY_ID
14+
PRD_AWS_SECRET_ACCESS_KEY: $PRD_AWS_SECRET_ACCESS_KEY
15+
depends_on:
16+
- dynamo
17+
18+
app:
19+
build: .
20+
working_dir: /src
21+
environment:
22+
AWS_REGION: $AWS_REGION
23+
GITHUB_REF_NAME: $GITHUB_REF_NAME
24+
STG_AWS_ACCESS_KEY_ID: $STG_AWS_ACCESS_KEY_ID
25+
STG_AWS_SECRET_ACCESS_KEY: $STG_AWS_SECRET_ACCESS_KEY
26+
STG_LAMBDA_ROLE: $STG_LAMBDA_ROLE
27+
STG_API_KEY_TABLE: $STG_API_KEY_TABLE
28+
STG_WEBAUTHN_TABLE: $STG_WEBAUTHN_TABLE
29+
PRD_AWS_ACCESS_KEY_ID: $PRD_AWS_ACCESS_KEY_ID
30+
PRD_AWS_SECRET_ACCESS_KEY: $PRD_AWS_SECRET_ACCESS_KEY
31+
PRD_LAMBDA_ROLE: $PRD_LAMBDA_ROLE
32+
PRD_API_KEY_TABLE: $PRD_API_KEY_TABLE
33+
PRD_WEBAUTHN_TABLE: $PRD_WEBAUTHN_TABLE
34+
35+
dynamo:
36+
image: amazon/dynamodb-local
37+
environment:
38+
AWS_ACCESS_KEY_ID: abc123
39+
AWS_SECRET_ACCESS_KEY: abc123
40+
AWS_DEFAULT_REGION: us-east-1
41+
command: "-jar DynamoDBLocal.jar -sharedDb"

apikey.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ import (
1717
const ApiKeyTablePK = "value"
1818

1919
type ApiKey struct {
20-
Key string `json:"value"`
21-
Secret string `json:"-"`
22-
HashedSecret string `json:"hashedApiSecret"`
23-
Email string `json:"email"`
24-
CreatedAt int `json:"createdAt"`
25-
ActivatedAt int `json:"activatedAt"`
26-
Store *Storage `json:"-"`
20+
Key string `dynamodbav:"value" json:"value"`
21+
Secret string `dynamodbav:"-" json:"-"`
22+
HashedSecret string `dynamodbav:"hashedApiSecret" json:"hashedApiSecret"`
23+
Email string `dynamodbav:"email" json:"email"`
24+
CreatedAt int `dynamodbav:"createdAt" json:"createdAt"`
25+
ActivatedAt int `dynamodbav:"activatedAt" json:"activatedAt"`
26+
Store *Storage `dynamodbav:"-" json:"-"`
2727
}
2828

2929
func (k *ApiKey) Load() error {

aws.env.encrypted

Lines changed: 0 additions & 2 deletions
This file was deleted.

codeship-services.yml

Lines changed: 0 additions & 29 deletions
This file was deleted.

codeship-steps.yml

Lines changed: 0 additions & 26 deletions
This file was deleted.

0 commit comments

Comments
 (0)