-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add two new endpoints and other generic fixes/changes (#16)
Changes: * Fixes correct marshaling of AuthSignRequest before it's sent to BankID The twofer API expect UserVisibleData and UserNonVisibleData to be sent in clear-text, but it must be sent to BankID as Base64 encoded data. However The fields were previously only Base64 encoded when validating the max length but is now also Base64 encoded before the fields are sent to BankID. * Switch docker image to be built from scratch * Update GO and dependency versions to resolve a number of CVE's * Increase graceful shutdown period A BankID auth order is only valid for 30 seconds, unless the QR-code is scanned, then the order is valid for 180 seconds. Fixes: * Fixes 'superfluous response.WriteHeader' console message * Refactor BankID loops waiting for status changes * Exit process if we're unable to start the webserver * Avoid error message in tests when server have been gracefully shut down * Avoid error message when server have been gracefully shut down * Simplify shutdown process New: * Add prestophook command Add a new `twoferd prestophook` command that can be used in a K8S manifest to handle graceful shutdown scenarios, where the service may need more than 30 seconds to shutdown. * Add two new (v2) auth and sign endpoints that have a slightly different API * Add public sse package * Add public NDJSON package Add NDJSON as a new default stream encoder for v2 endpoints Set STREAM_ENCODER environment variable to "SSE", to use SSE as stream encoder.
- Loading branch information
Showing
26 changed files
with
1,697 additions
and
163 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 |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package api | ||
|
||
type ( | ||
BankIdV6Response struct { | ||
OrderRef string `json:"orderRef"` | ||
ErrorCode string `json:"errorCode,omitempty"` | ||
ErrorText string `json:"errorText,omitempty"` | ||
URI string `json:"uri,omitempty"` | ||
QR string `json:"qr,omitempty"` | ||
Status string `json:"status,omitempty"` | ||
HintCode string `json:"hintCode,omitempty"` | ||
CompletionData *BankIdV6CompletionData `json:"completionData,omitempty"` | ||
} | ||
BankIdV6CompletionData struct { | ||
User BankIdV6User `json:"user,omitempty"` | ||
Device BankIdV6Device `json:"device,omitempty"` | ||
BankIdIssueDate string `json:"bankIdIssueDate,omitempty"` | ||
StepUp BankIdV6StepUp `json:"stepUp,omitempty"` | ||
Signature string `json:"signature,omitempty"` | ||
OcspResponse string `json:"ocspResponse,omitempty"` | ||
} | ||
BankIdV6User struct { | ||
PersonalNumber string `json:"personalNumber,omitempty"` | ||
Name string `json:"name,omitempty"` | ||
GivenName string `json:"givenName,omitempty"` | ||
SurName string `json:"surName,omitempty"` | ||
} | ||
BankIdV6Device struct { | ||
IpAddress string `json:"ipAddress,omitempty"` | ||
UHI string `json:"uhi,omitempty"` | ||
} | ||
BankIdV6StepUp struct { | ||
MRTD bool `json:"mrtd,omitempty"` | ||
} | ||
) | ||
|
||
const ( | ||
StatusPending = "pending" | ||
StatusComplete = "complete" | ||
StatusFailed = "failed" | ||
StatusError = "error" | ||
) |
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
FROM golang:1.20.3 | ||
FROM golang:1.21.9 | ||
|
||
RUN apt-get update && apt-get install -y inotify-hookable | ||
|
||
|
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 |
---|---|---|
@@ -1,52 +1,39 @@ | ||
module github.com/modfin/twofer | ||
|
||
go 1.19 | ||
go 1.21 | ||
|
||
require ( | ||
github.com/caarlos0/env/v6 v6.10.1 | ||
github.com/davecgh/go-spew v1.1.1 | ||
github.com/go-webauthn/webauthn v0.8.2 | ||
github.com/golang/protobuf v1.5.3 | ||
github.com/gorilla/mux v1.8.0 | ||
github.com/labstack/echo/v4 v4.10.2 | ||
github.com/mdp/qrterminal/v3 v3.0.0 | ||
github.com/google/uuid v1.3.0 | ||
github.com/labstack/echo/v4 v4.12.0 | ||
github.com/pquerna/otp v1.4.0 | ||
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e | ||
github.com/stretchr/testify v1.8.2 | ||
github.com/urfave/cli/v2 v2.20.2 | ||
golang.org/x/crypto v0.8.0 | ||
golang.org/x/net v0.9.0 | ||
golang.org/x/oauth2 v0.7.0 | ||
google.golang.org/grpc v1.52.0-dev | ||
github.com/stretchr/testify v1.8.4 | ||
golang.org/x/crypto v0.22.0 | ||
golang.org/x/net v0.24.0 | ||
) | ||
|
||
require ( | ||
github.com/boombuler/barcode v1.0.1-0.20190219062509-6c824513bacc // indirect | ||
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect | ||
github.com/davecgh/go-spew v1.1.1 // indirect | ||
github.com/fxamacker/cbor/v2 v2.4.0 // indirect | ||
github.com/go-webauthn/revoke v0.1.9 // indirect | ||
github.com/golang-jwt/jwt v3.2.2+incompatible // indirect | ||
github.com/golang-jwt/jwt/v4 v4.5.0 // indirect | ||
github.com/google/go-cmp v0.5.9 // indirect | ||
github.com/google/go-tpm v0.3.3 // indirect | ||
github.com/google/uuid v1.3.0 // indirect | ||
github.com/kr/pretty v0.3.1 // indirect | ||
github.com/labstack/gommon v0.4.0 // indirect | ||
github.com/labstack/gommon v0.4.2 // indirect | ||
github.com/mattn/go-colorable v0.1.13 // indirect | ||
github.com/mattn/go-isatty v0.0.18 // indirect | ||
github.com/mattn/go-isatty v0.0.20 // indirect | ||
github.com/mitchellh/mapstructure v1.5.0 // indirect | ||
github.com/pmezard/go-difflib v1.0.0 // indirect | ||
github.com/russross/blackfriday/v2 v2.1.0 // indirect | ||
github.com/valyala/bytebufferpool v1.0.0 // indirect | ||
github.com/valyala/fasttemplate v1.2.2 // indirect | ||
github.com/x448/float16 v0.8.4 // indirect | ||
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect | ||
golang.org/x/sys v0.7.0 // indirect | ||
golang.org/x/text v0.9.0 // indirect | ||
golang.org/x/time v0.3.0 // indirect | ||
google.golang.org/genproto v0.0.0-20220822174746-9e6da59bd2fc // indirect | ||
google.golang.org/protobuf v1.30.0 // indirect | ||
golang.org/x/sys v0.19.0 // indirect | ||
golang.org/x/text v0.14.0 // indirect | ||
golang.org/x/time v0.5.0 // indirect | ||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect | ||
gopkg.in/yaml.v3 v3.0.1 // indirect | ||
rsc.io/qr v0.2.0 // indirect | ||
) |
Oops, something went wrong.