Skip to content

Commit

Permalink
Merge branch 'master' into pr-email-change
Browse files Browse the repository at this point in the history
  • Loading branch information
kangmingtay committed Aug 3, 2021
2 parents 9706330 + 81bfcc4 commit dd06c6c
Show file tree
Hide file tree
Showing 23 changed files with 55 additions and 50 deletions.
2 changes: 1 addition & 1 deletion api/admin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (
"testing"
"time"

jwt "github.com/dgrijalva/jwt-go"
"github.com/gofrs/uuid"
jwt "github.com/golang-jwt/jwt"
"github.com/netlify/gotrue/conf"
"github.com/netlify/gotrue/models"
"github.com/stretchr/testify/assert"
Expand Down
4 changes: 2 additions & 2 deletions api/audit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import (
"testing"
"time"

jwt "github.com/dgrijalva/jwt-go"
"github.com/gofrs/uuid"
jwt "github.com/golang-jwt/jwt"
"github.com/netlify/gotrue/conf"
"github.com/netlify/gotrue/models"
"github.com/gofrs/uuid"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
Expand Down
2 changes: 1 addition & 1 deletion api/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"net/http"
"time"

jwt "github.com/dgrijalva/jwt-go"
jwt "github.com/golang-jwt/jwt"
"github.com/netlify/gotrue/models"
)

Expand Down
2 changes: 1 addition & 1 deletion api/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package api
import (
"context"

jwt "github.com/dgrijalva/jwt-go"
"github.com/gofrs/uuid"
jwt "github.com/golang-jwt/jwt"
"github.com/netlify/gotrue/conf"
"github.com/netlify/gotrue/models"
)
Expand Down
2 changes: 1 addition & 1 deletion api/external.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (
"strings"
"time"

jwt "github.com/dgrijalva/jwt-go"
"github.com/gofrs/uuid"
jwt "github.com/golang-jwt/jwt"
"github.com/markbates/goth/gothic"
"github.com/netlify/gotrue/api/provider"
"github.com/netlify/gotrue/models"
Expand Down
2 changes: 1 addition & 1 deletion api/external_azure_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"net/http/httptest"
"net/url"

jwt "github.com/dgrijalva/jwt-go"
jwt "github.com/golang-jwt/jwt"
)

func (ts *ExternalTestSuite) TestSignupExternalAzure() {
Expand Down
2 changes: 1 addition & 1 deletion api/external_bitbucket_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"net/http/httptest"
"net/url"

jwt "github.com/dgrijalva/jwt-go"
jwt "github.com/golang-jwt/jwt"
)

func (ts *ExternalTestSuite) TestSignupExternalBitbucket() {
Expand Down
2 changes: 1 addition & 1 deletion api/external_discord_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"net/http/httptest"
"net/url"

jwt "github.com/dgrijalva/jwt-go"
jwt "github.com/golang-jwt/jwt"
)

func (ts *ExternalTestSuite) TestSignupExternalDiscord() {
Expand Down
2 changes: 1 addition & 1 deletion api/external_facebook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"net/http/httptest"
"net/url"

jwt "github.com/dgrijalva/jwt-go"
jwt "github.com/golang-jwt/jwt"
)

func (ts *ExternalTestSuite) TestSignupExternalFacebook() {
Expand Down
2 changes: 1 addition & 1 deletion api/external_github_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"net/http/httptest"
"net/url"

jwt "github.com/dgrijalva/jwt-go"
jwt "github.com/golang-jwt/jwt"
)

func (ts *ExternalTestSuite) TestSignupExternalGithub() {
Expand Down
2 changes: 1 addition & 1 deletion api/external_gitlab_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"net/http/httptest"
"net/url"

jwt "github.com/dgrijalva/jwt-go"
jwt "github.com/golang-jwt/jwt"
)

func (ts *ExternalTestSuite) TestSignupExternalGitlab() {
Expand Down
2 changes: 1 addition & 1 deletion api/external_google_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"net/http/httptest"
"net/url"

jwt "github.com/dgrijalva/jwt-go"
jwt "github.com/golang-jwt/jwt"
)

func (ts *ExternalTestSuite) TestSignupExternalGoogle() {
Expand Down
3 changes: 1 addition & 2 deletions api/external_twitch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"net/http/httptest"
"net/url"

jwt "github.com/dgrijalva/jwt-go"
jwt "github.com/golang-jwt/jwt"
)

func (ts *ExternalTestSuite) TestSignupExternalTwitch() {
Expand Down Expand Up @@ -95,7 +95,6 @@ func (ts *ExternalTestSuite) TestSignupExternalTwitchDisableSignupErrorWhenEmpty
server := TwitchTestSignupSetup(ts, &tokenCount, &userCount, code, TwitchUser)
defer server.Close()


u := performAuthorization(ts, "twitch", code, "")

assertAuthorizationFailure(ts, u, "Error getting user email from external provider", "server_error", "twitch@example.com")
Expand Down
2 changes: 1 addition & 1 deletion api/hooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import (
"net/url"
"time"

jwt "github.com/dgrijalva/jwt-go"
"github.com/gofrs/uuid"
jwt "github.com/golang-jwt/jwt"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"

Expand Down
2 changes: 1 addition & 1 deletion api/invite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (
"testing"
"time"

jwt "github.com/dgrijalva/jwt-go"
"github.com/gofrs/uuid"
jwt "github.com/golang-jwt/jwt"
"github.com/netlify/gotrue/conf"
"github.com/netlify/gotrue/models"
"github.com/stretchr/testify/assert"
Expand Down
2 changes: 1 addition & 1 deletion api/middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import (
"io/ioutil"
"net/http"

jwt "github.com/dgrijalva/jwt-go"
"github.com/didip/tollbooth/v5"
"github.com/didip/tollbooth/v5/limiter"
"github.com/gofrs/uuid"
jwt "github.com/golang-jwt/jwt"
"github.com/netlify/gotrue/models"
)

Expand Down
2 changes: 1 addition & 1 deletion api/provider/apple.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"fmt"
"net/http"

"github.com/dgrijalva/jwt-go"
"github.com/golang-jwt/jwt"
"github.com/lestrrat-go/jwx/jwk"
"github.com/netlify/gotrue/conf"
"golang.org/x/oauth2"
Expand Down
6 changes: 6 additions & 0 deletions api/signup.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ func (a *API) Signup(w http.ResponseWriter, r *http.Request) error {
} else {
mailer := a.Mailer(ctx)
referrer := a.getReferrer(r)
if terr = models.NewAuditLogEntry(tx, instanceID, user, models.UserConfirmationRequestedAction, nil); terr != nil {
return terr
}
if terr = sendConfirmation(tx, user, mailer, config.SMTP.MaxFrequency, referrer); terr != nil {
if errors.Is(terr, MaxFrequencyLimitError) {
now := time.Now()
Expand All @@ -141,6 +144,9 @@ func (a *API) Signup(w http.ResponseWriter, r *http.Request) error {
return internalServerError("Database error updating user").WithInternalError(terr)
}
} else {
if terr = models.NewAuditLogEntry(tx, instanceID, user, models.UserConfirmationRequestedAction, nil); terr != nil {
return terr
}
if terr = a.sendPhoneConfirmation(tx, ctx, user, params.Phone); terr != nil {
return badRequestError("Error sending confirmation sms: %v", terr)
}
Expand Down
2 changes: 1 addition & 1 deletion api/signup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (
"testing"
"time"

jwt "github.com/dgrijalva/jwt-go"
"github.com/gofrs/uuid"
jwt "github.com/golang-jwt/jwt"
"github.com/netlify/gotrue/conf"
"github.com/netlify/gotrue/models"
"github.com/stretchr/testify/assert"
Expand Down
2 changes: 1 addition & 1 deletion api/token.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"net/http"
"time"

jwt "github.com/dgrijalva/jwt-go"
jwt "github.com/golang-jwt/jwt"
"github.com/netlify/gotrue/conf"
"github.com/netlify/gotrue/metering"
"github.com/netlify/gotrue/models"
Expand Down
7 changes: 3 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ require (
github.com/Masterminds/semver/v3 v3.1.1 // indirect
github.com/badoux/checkmail v0.0.0-20170203135005-d0a759655d62
github.com/beevik/etree v1.1.0
github.com/dgrijalva/jwt-go v3.2.0+incompatible
github.com/didip/tollbooth/v5 v5.1.1
github.com/fatih/color v1.10.0 // indirect
github.com/go-chi/chi v4.0.2+incompatible
Expand All @@ -19,6 +18,7 @@ require (
github.com/gobuffalo/pop/v5 v5.3.3
github.com/gobuffalo/validate/v3 v3.3.0 // indirect
github.com/gofrs/uuid v4.0.0+incompatible
github.com/golang-jwt/jwt v3.2.1+incompatible
github.com/imdario/mergo v0.0.0-20160216103600-3e95a51e0639
github.com/jackc/pgproto3/v2 v2.0.7 // indirect
github.com/jmoiron/sqlx v1.3.1 // indirect
Expand All @@ -27,13 +27,12 @@ require (
github.com/lestrrat-go/jwx v0.9.0
github.com/lib/pq v1.9.0 // indirect
github.com/markbates/goth v1.67.1
github.com/microcosm-cc/bluemonday v1.0.4 // indirect
github.com/microcosm-cc/bluemonday v1.0.5 // indirect
github.com/mrjones/oauth v0.0.0-20190623134757-126b35219450
github.com/netlify/mailme v1.1.1
github.com/opentracing/opentracing-go v1.1.0
github.com/patrickmn/go-cache v2.1.0+incompatible // indirect
github.com/pkg/errors v0.9.1
github.com/pquerna/otp v1.3.0 // indirect
github.com/rogpeppe/go-internal v1.7.0 // indirect
github.com/rs/cors v1.6.0
github.com/russellhaering/gosaml2 v0.6.0
Expand All @@ -52,7 +51,7 @@ require (
golang.org/x/text v0.3.5 // indirect
golang.org/x/time v0.0.0-20200416051211-89c76fbcd5d1 // indirect
gopkg.in/DataDog/dd-trace-go.v1 v1.12.1
gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df // indirect
gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df
gopkg.in/yaml.v1 v1.0.0-20140924161607-9f9df34309c0 // indirect
)

Expand Down
9 changes: 4 additions & 5 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@ github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kB
github.com/bitly/go-simplejson v0.5.0/go.mod h1:cXHtHw4XUPsvGaxgjIAn8PhEWG9NfngEKAMDJEczWVA=
github.com/bketelsen/crypt v0.0.3-0.20200106085610-5cbc8cc4026c/go.mod h1:MKsuJmJgSg28kpZDP6UIiPt0e0Oz0kqKNGyRaWEPv84=
github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869/go.mod h1:Ekp36dRnpXw/yCqJaO+ZrUyxD+3VXMFFr56k5XYrpB4=
github.com/boombuler/barcode v1.0.1-0.20190219062509-6c824513bacc h1:biVzkmvwrH8WK8raXaxBx6fRVTlJILwEwQGL1I/ByEI=
github.com/boombuler/barcode v1.0.1-0.20190219062509-6c824513bacc/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl3JlRe0mD8=
github.com/bugsnag/bugsnag-go v1.5.3/go.mod h1:2oa8nejYd4cQ/b0hMIopN0lCRxU0bueqREvZLWFrtK8=
github.com/bugsnag/panicwrap v1.2.0/go.mod h1:D/8v3kj0zr8ZAKg1AQ6crr+5VwKN5eIywRkfhyM/+dE=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
Expand Down Expand Up @@ -94,7 +92,6 @@ github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7Do
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM=
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no=
github.com/didip/tollbooth/v5 v5.1.1 h1:QpKFg56jsbNuQ6FFj++Z1gn2fbBsvAc1ZPLUaDOYW5k=
Expand Down Expand Up @@ -176,6 +173,8 @@ github.com/gofrs/uuid v4.0.0+incompatible h1:1SD/1F5pU8p29ybwgQSwpQk+mwdRrXCYuPh
github.com/gofrs/uuid v4.0.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4=
github.com/golang-jwt/jwt v3.2.1+incompatible h1:73Z+4BJcrTC+KczS6WvTPvRGOp1WmfEP4Q1lOd9Z/+c=
github.com/golang-jwt/jwt v3.2.1+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I=
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
Expand Down Expand Up @@ -416,6 +415,8 @@ github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5
github.com/microcosm-cc/bluemonday v1.0.2/go.mod h1:iVP4YcDBq+n/5fb23BhYFvIMq/leAFZyRl6bYmGDlGc=
github.com/microcosm-cc/bluemonday v1.0.4 h1:p0L+CTpo/PLFdkoPcJemLXG+fpMD7pYOoDEq1axMbGg=
github.com/microcosm-cc/bluemonday v1.0.4/go.mod h1:8iwZnFn2CDDNZ0r6UXhF4xawGvzaqzCRa1n3/lO3W2w=
github.com/microcosm-cc/bluemonday v1.0.5 h1:cF59UCKMmmUgqN1baLvqU/B1ZsMori+duLVTLpgiG3w=
github.com/microcosm-cc/bluemonday v1.0.5/go.mod h1:8iwZnFn2CDDNZ0r6UXhF4xawGvzaqzCRa1n3/lO3W2w=
github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg=
github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc=
github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
Expand Down Expand Up @@ -462,8 +463,6 @@ github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI=
github.com/pquerna/otp v1.3.0 h1:oJV/SkzR33anKXwQU3Of42rL4wbrffP4uvUf1SvS5Xs=
github.com/pquerna/otp v1.3.0/go.mod h1:dkJfzwRKNiegxyNb54X/3fLwhCynbMspSyWKnvi1AEg=
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
github.com/prometheus/client_golang v0.9.2/go.mod h1:OsXs2jCmiKlQ1lTBmv21f2mNfw4xf/QclQDMrYNZzcM=
github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDft0ttaMvbicHlPoso=
Expand Down
42 changes: 22 additions & 20 deletions models/audit_log_entry.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,17 @@ type AuditAction string
type auditLogType string

const (
LoginAction AuditAction = "login"
LogoutAction AuditAction = "logout"
InviteAcceptedAction AuditAction = "invite_accepted"
UserSignedUpAction AuditAction = "user_signedup"
UserInvitedAction AuditAction = "user_invited"
UserDeletedAction AuditAction = "user_deleted"
UserModifiedAction AuditAction = "user_modified"
UserRecoveryRequestedAction AuditAction = "user_recovery_requested"
TokenRevokedAction AuditAction = "token_revoked"
TokenRefreshedAction AuditAction = "token_refreshed"
LoginAction AuditAction = "login"
LogoutAction AuditAction = "logout"
InviteAcceptedAction AuditAction = "invite_accepted"
UserSignedUpAction AuditAction = "user_signedup"
UserInvitedAction AuditAction = "user_invited"
UserDeletedAction AuditAction = "user_deleted"
UserModifiedAction AuditAction = "user_modified"
UserRecoveryRequestedAction AuditAction = "user_recovery_requested"
UserConfirmationRequestedAction AuditAction = "user_confirmation_requested"
TokenRevokedAction AuditAction = "token_revoked"
TokenRefreshedAction AuditAction = "token_refreshed"

account auditLogType = "account"
team auditLogType = "team"
Expand All @@ -32,16 +33,17 @@ const (
)

var actionLogTypeMap = map[AuditAction]auditLogType{
LoginAction: account,
LogoutAction: account,
InviteAcceptedAction: account,
UserSignedUpAction: team,
UserInvitedAction: team,
UserDeletedAction: team,
TokenRevokedAction: token,
TokenRefreshedAction: token,
UserModifiedAction: user,
UserRecoveryRequestedAction: user,
LoginAction: account,
LogoutAction: account,
InviteAcceptedAction: account,
UserSignedUpAction: team,
UserInvitedAction: team,
UserDeletedAction: team,
TokenRevokedAction: token,
TokenRefreshedAction: token,
UserModifiedAction: user,
UserRecoveryRequestedAction: user,
UserConfirmationRequestedAction: user,
}

// AuditLogEntry is the database model for audit log entries.
Expand Down

0 comments on commit dd06c6c

Please sign in to comment.