Skip to content

Commit 001fc84

Browse files
committed
cleanup code
1 parent 6e161e4 commit 001fc84

File tree

6 files changed

+8
-31
lines changed

6 files changed

+8
-31
lines changed

config.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,7 @@ import (
88
"github.com/aws/aws-sdk-go/aws"
99
)
1010

11-
var (
12-
storage *Storage
13-
envConfig EnvConfig
14-
)
11+
var envConfig EnvConfig
1512

1613
// EnvConfig holds environment specific configurations and is populated on init
1714
type EnvConfig struct {

server/main.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,7 @@ func newRouter() *mux.Router {
9696

9797
// Assign the handlers to run when endpoints are called.
9898
for _, route := range routes {
99-
// Create a handler function.
100-
var handler http.Handler
101-
handler = route.HandlerFunc
102-
103-
router.Methods(route.Method).Path(route.Pattern).Name(route.Name).Handler(handler)
99+
router.Methods(route.Method).Path(route.Pattern).Name(route.Name).Handler(route.HandlerFunc)
104100
}
105101

106102
router.NotFoundHandler = router.NewRoute().HandlerFunc(notFound).GetHandler()

testutils.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ func initDb(storage *Storage) error {
5555

5656
// attempt to delete tables in case already exists
5757
tables := map[string]string{"WebAuthn": "uuid", "ApiKey": "value"}
58-
for name, _ := range tables {
58+
for name := range tables {
5959
deleteTable := &dynamodb.DeleteTableInput{
6060
TableName: aws.String(name),
6161
}
@@ -126,7 +126,9 @@ type ClientData struct {
126126
}
127127

128128
// GenerateAuthenticationSig appends the clientData to the authData and uses the privateKey's public Key to sign it
129-
// via a sha256 hashing algorithm.
129+
//
130+
// via a sha256 hashing algorithm.
131+
//
130132
// It returns the base64 encoded version of the marshaled version of the corresponding dsa signature {r:bigInt, s:bigInt}
131133
// It does not use any kind of randomized data in this process
132134
func GenerateAuthenticationSig(authData, clientData []byte, privateKey *ecdsa.PrivateKey) string {

u2fserver/main.go

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,9 @@ import (
88

99
"github.com/gorilla/mux"
1010

11-
mfa "github.com/silinternational/serverless-mfa-api-go"
1211
u2fsim "github.com/silinternational/serverless-mfa-api-go/u2fsimulator"
1312
)
1413

15-
var envConfig mfa.EnvConfig
16-
1714
func main() {
1815
log.SetOutput(os.Stdout)
1916
log.Println("U2f Simulator Server starting...")
@@ -51,11 +48,7 @@ func newRouter() *mux.Router {
5148

5249
// Assign the handlers to run when endpoints are called.
5350
for _, route := range routes {
54-
// Create a handler function.
55-
var handler http.Handler
56-
handler = route.HandlerFunc
57-
58-
router.Methods(route.Method).Path(route.Pattern).Name(route.Name).Handler(handler)
51+
router.Methods(route.Method).Path(route.Pattern).Name(route.Name).Handler(route.HandlerFunc)
5952
}
6053

6154
router.NotFoundHandler = router.NewRoute().HandlerFunc(notFound).GetHandler()

user.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ func (u *DynamoUser) DeleteCredential(credIDHash string) (int, error) {
153153
}
154154

155155
if len(u.Credentials) == 0 {
156-
err := fmt.Errorf("error in DeleteCredential. No webauthn credentials available.")
156+
err := fmt.Errorf("error in DeleteCredential: no webauthn credentials available")
157157
return http.StatusNotFound, err
158158
}
159159

webauthn_test.go

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77
"encoding/json"
88
"fmt"
99
"io/ioutil"
10-
"math/big"
1110
"net/http"
1211
"net/http/httptest"
1312
"strings"
@@ -732,16 +731,6 @@ func Test_GetSignatureForLogin(t *testing.T) {
732731
panic("error marshalling client data: " + err.Error())
733732
}
734733

735-
xyStr := "4843956129390645175905258525279791420276294952604174799584408071708240463528636134250956749795798585127919587881956611106672985015071877198253568414405109"
736-
737-
bigXY, ok := new(big.Int).SetString(xyStr, 16)
738-
if !ok {
739-
panic("Failed making bigint")
740-
}
741-
742-
xyData := []byte{4}
743-
xyData = append(xyData, bigXY.Bytes()...)
744-
745734
keyHandle := "virtKey11"
746735
_, authDataBytes1, privateKey := u2fsim.GetAuthDataAndPrivateKey(localAppID, keyHandle)
747736
signature := GenerateAuthenticationSig(authDataBytes1, clientData, privateKey)

0 commit comments

Comments
 (0)