Permalink
Browse files

Merge pull request #188 from coinread/master

upgrade to new pop, go module and bug fixes
  • Loading branch information...
bcomnes committed Oct 18, 2018
2 parents c9327d4 + d7772d7 commit 49e0866b91fa6b28b098163765d513621c171c98
View
@@ -2,8 +2,10 @@
language: go
go:
- 1.8
- 1.9
- 1.11.1
env:
- GO111MODULE=on
services:
- docker
View
4 CONTRIBUTING.md 100644 → 100755
@@ -5,9 +5,11 @@ please read the [code of conduct](CODE_OF_CONDUCT.md).
## Setup
> Install Go and Glide https://github.com/Masterminds/glide
> Install Go 1.11.1
> Install Docker to run tests
GoTrue uses the Go Modules support built into Go 1.11 to build. The easiest is to clone GoTrue in a directory outside of GOPATH, as in the following example:
```sh
$ git clone https://github.com/netlify/gotrue
$ cd gotrue
View
@@ -1,15 +1,25 @@
FROM golang:1.9.2
FROM golang:alpine as build
ENV GO111MODULE=on
ENV CGO_ENABLED=0
ENV GOOS=linux
RUN apk add --no-cache make git
WORKDIR /go/src/github.com/netlify/gotrue
COPY . /go/src/github.com/netlify/gotrue/
COPY . /go/src/github.com/netlify/gotrue
RUN make deps build
RUN go build -a -installsuffix cgo -o gotrue
FROM alpine:3.7
RUN adduser -D -u 1000 netlify
RUN apk add --no-cache ca-certificates
RUN adduser -D -u 1000 netlify && mkdir /lib64 && ln -s /lib/libc.musl-x86_64.so.1 /lib64/ld-linux-x86-64.so.2
COPY --from=0 /go/src/github.com/netlify/gotrue/gotrue /usr/local/bin/gotrue
COPY --from=0 /go/src/github.com/netlify/gotrue/migrations /usr/local/etc/gotrue/migrations/
RUN chown netlify:netlify /usr/local/bin/gotrue && chown -R netlify:netlify /usr/local/etc/gotrue
COPY --from=build /go/src/github.com/netlify/gotrue/gotrue /usr/local/bin/gotrue
COPY --from=build /go/src/github.com/netlify/gotrue/migrations /usr/local/etc/gotrue/migrations/
USER netlify
ENV GOTRUE_DB_MIGRATIONS_PATH /usr/local/etc/gotrue/migrations
CMD ["gotrue"]
USER netlify
CMD ["gotrue"]
View
@@ -11,8 +11,8 @@ build: ## Build the binary.
deps: ## Install dependencies.
@go get -u github.com/gobuffalo/pop/soda
@go get -u github.com/golang/lint/golint
@go get -u github.com/Masterminds/glide && glide install
@go get -u golang.org/x/lint/golint
@go mod download
image: ## Build the Docker image.
docker build .
View
@@ -8,7 +8,7 @@ import (
"github.com/go-chi/chi"
"github.com/netlify/gotrue/models"
"github.com/netlify/gotrue/storage"
uuid "github.com/satori/go.uuid"
"github.com/gobuffalo/uuid"
)
type adminUserParams struct {
View
@@ -12,7 +12,7 @@ import (
jwt "github.com/dgrijalva/jwt-go"
"github.com/netlify/gotrue/conf"
"github.com/netlify/gotrue/models"
uuid "github.com/satori/go.uuid"
"github.com/gobuffalo/uuid"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
View
@@ -12,7 +12,7 @@ import (
"github.com/netlify/gotrue/storage"
"github.com/netlify/netlify-commons/graceful"
"github.com/rs/cors"
uuid "github.com/satori/go.uuid"
"github.com/gobuffalo/uuid"
"github.com/sebest/xff"
"github.com/sirupsen/logrus"
)
View
@@ -10,7 +10,7 @@ import (
"github.com/netlify/gotrue/models"
"github.com/netlify/gotrue/storage"
"github.com/netlify/gotrue/storage/test"
"github.com/satori/go.uuid"
"github.com/gobuffalo/uuid"
"github.com/stretchr/testify/require"
)
View
@@ -11,7 +11,7 @@ import (
jwt "github.com/dgrijalva/jwt-go"
"github.com/netlify/gotrue/conf"
"github.com/netlify/gotrue/models"
uuid "github.com/satori/go.uuid"
"github.com/gobuffalo/uuid"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
View
@@ -6,7 +6,7 @@ import (
jwt "github.com/dgrijalva/jwt-go"
"github.com/netlify/gotrue/conf"
"github.com/netlify/gotrue/models"
uuid "github.com/satori/go.uuid"
"github.com/gobuffalo/uuid"
)
type contextKey string
View
@@ -8,7 +8,7 @@ import (
"runtime/debug"
)
var oauthErrorMap map[int]string = map[int]string{
var oauthErrorMap = map[int]string{
http.StatusBadRequest: "invalid_request",
http.StatusUnauthorized: "unauthorized_client",
http.StatusForbidden: "access_denied",
@@ -39,7 +39,7 @@ func (e *OAuthError) WithInternalError(err error) *OAuthError {
// WithInternalMessage adds internal message information to the error
func (e *OAuthError) WithInternalMessage(fmtString string, args ...interface{}) *OAuthError {
e.InternalMessage = fmt.Sprintf(fmtString, args)
e.InternalMessage = fmt.Sprintf(fmtString, args...)
return e
}
@@ -111,7 +111,7 @@ func (e *HTTPError) WithInternalError(err error) *HTTPError {
// WithInternalMessage adds internal message information to the error
func (e *HTTPError) WithInternalMessage(fmtString string, args ...interface{}) *HTTPError {
e.InternalMessage = fmt.Sprintf(fmtString, args)
e.InternalMessage = fmt.Sprintf(fmtString, args...)
return e
}
View
@@ -13,7 +13,7 @@ import (
"github.com/netlify/gotrue/api/provider"
"github.com/netlify/gotrue/models"
"github.com/netlify/gotrue/storage"
uuid "github.com/satori/go.uuid"
"github.com/gobuffalo/uuid"
"github.com/sirupsen/logrus"
)
@@ -96,7 +96,7 @@ func (a *API) internalExternalProviderCallback(w http.ResponseWriter, r *http.Re
}
userData = samlUserData
} else {
oAuthUserData, err := a.oAuthCallback(r, ctx, providerType)
oAuthUserData, err := a.oAuthCallback(ctx, r, providerType)
if err != nil {
return err
}
@@ -135,7 +135,7 @@ func (a *API) internalExternalProviderCallback(w http.ResponseWriter, r *http.Re
}
}
user, terr = a.signupNewUser(tx, ctx, params)
user, terr = a.signupNewUser(ctx, tx, params)
if terr != nil {
return terr
}
View
@@ -20,7 +20,7 @@ func (a *API) loadOAuthState(w http.ResponseWriter, r *http.Request) (context.Co
return a.loadExternalState(ctx, state)
}
func (a *API) oAuthCallback(r *http.Request, ctx context.Context, providerType string) (*provider.UserProvidedData, error) {
func (a *API) oAuthCallback(ctx context.Context, r *http.Request, providerType string) (*provider.UserProvidedData, error) {
rq := r.URL.Query()
extError := rq.Get("error")
@@ -20,7 +20,7 @@ import (
"github.com/netlify/gotrue/models"
"github.com/russellhaering/gosaml2/types"
dsig "github.com/russellhaering/goxmldsig"
uuid "github.com/satori/go.uuid"
"github.com/gobuffalo/uuid"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
)
View
@@ -10,7 +10,7 @@ import (
jwt "github.com/dgrijalva/jwt-go"
"github.com/netlify/gotrue/conf"
"github.com/netlify/gotrue/models"
uuid "github.com/satori/go.uuid"
"github.com/gobuffalo/uuid"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
)
View
@@ -11,7 +11,7 @@ import (
"github.com/netlify/gotrue/models"
"github.com/netlify/gotrue/storage"
"github.com/pkg/errors"
"github.com/satori/go.uuid"
"github.com/gobuffalo/uuid"
)
func addRequestID(globalConfig *conf.GlobalConfiguration) middlewareHandler {
View
@@ -12,7 +12,7 @@ import (
"github.com/netlify/gotrue/conf"
"github.com/netlify/gotrue/models"
"github.com/netlify/gotrue/storage/test"
uuid "github.com/satori/go.uuid"
"github.com/gobuffalo/uuid"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
View
@@ -15,7 +15,7 @@ import (
jwt "github.com/dgrijalva/jwt-go"
"github.com/pkg/errors"
uuid "github.com/satori/go.uuid"
"github.com/gobuffalo/uuid"
"github.com/sirupsen/logrus"
"github.com/netlify/gotrue/conf"
@@ -34,7 +34,7 @@ const (
LoginEvent = "login"
)
var defaultTimeout time.Duration = time.Second * 5
var defaultTimeout = time.Second * 5
type webhookClaims struct {
jwt.StandardClaims
@@ -103,7 +103,7 @@ func (w *Webhook) trigger() (io.ReadCloser, error) {
// timed out - try again?
if i == w.Retries-1 {
closeBody(rsp)
return nil, httpError(http.StatusGatewayTimeout, "Failed to perform webhook in time frame (%d seconds)", timeout.Seconds())
return nil, httpError(http.StatusGatewayTimeout, "Failed to perform webhook in time frame (%v seconds)", timeout.Seconds())
}
hooklog.Info("Request timed out")
continue
View
@@ -9,7 +9,7 @@ import (
"github.com/netlify/gotrue/conf"
"github.com/netlify/gotrue/models"
"github.com/pkg/errors"
"github.com/satori/go.uuid"
"github.com/gobuffalo/uuid"
)
func (a *API) loadInstance(w http.ResponseWriter, r *http.Request) (context.Context, error) {
View
@@ -7,7 +7,7 @@ import (
"net/http/httptest"
"testing"
"github.com/satori/go.uuid"
"github.com/gobuffalo/uuid"
"github.com/netlify/gotrue/conf"
"github.com/netlify/gotrue/models"
View
@@ -47,7 +47,7 @@ func (a *API) Invite(w http.ResponseWriter, r *http.Request) error {
Aud: aud,
Provider: "email",
}
user, err = a.signupNewUser(tx, ctx, &signupParams)
user, err = a.signupNewUser(ctx, tx, &signupParams)
if err != nil {
return err
}
View
@@ -13,7 +13,7 @@ import (
jwt "github.com/dgrijalva/jwt-go"
"github.com/netlify/gotrue/conf"
"github.com/netlify/gotrue/models"
uuid "github.com/satori/go.uuid"
"github.com/gobuffalo/uuid"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
View
@@ -9,7 +9,7 @@ import (
jwt "github.com/dgrijalva/jwt-go"
"github.com/netlify/gotrue/models"
uuid "github.com/satori/go.uuid"
"github.com/gobuffalo/uuid"
)
const (
View
@@ -24,7 +24,7 @@ import (
saml2 "github.com/russellhaering/gosaml2"
"github.com/russellhaering/gosaml2/types"
dsig "github.com/russellhaering/goxmldsig"
uuid "github.com/satori/go.uuid"
"github.com/gobuffalo/uuid"
"golang.org/x/oauth2"
)
View
@@ -10,7 +10,7 @@ import (
"github.com/netlify/gotrue/conf"
"github.com/netlify/gotrue/models"
uuid "github.com/satori/go.uuid"
"github.com/gobuffalo/uuid"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
View
@@ -60,7 +60,7 @@ func (a *API) Signup(w http.ResponseWriter, r *http.Request) error {
}
} else {
params.Provider = "email"
user, terr = a.signupNewUser(tx, ctx, params)
user, terr = a.signupNewUser(ctx, tx, params)
if terr != nil {
return terr
}
@@ -93,7 +93,7 @@ func (a *API) Signup(w http.ResponseWriter, r *http.Request) error {
return sendJSON(w, http.StatusOK, user)
}
func (a *API) signupNewUser(conn *storage.Connection, ctx context.Context, params *SignupParams) (*models.User, error) {
func (a *API) signupNewUser(ctx context.Context, conn *storage.Connection, params *SignupParams) (*models.User, error) {
instanceID := getInstanceID(ctx)
config := a.getConfig(ctx)
View
@@ -12,7 +12,7 @@ import (
jwt "github.com/dgrijalva/jwt-go"
"github.com/netlify/gotrue/conf"
"github.com/netlify/gotrue/models"
uuid "github.com/satori/go.uuid"
"github.com/gobuffalo/uuid"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
View
@@ -12,6 +12,7 @@ import (
"github.com/netlify/gotrue/storage"
)
// GoTrueClaims is a struct thats used for JWT claims
type GoTrueClaims struct {
jwt.StandardClaims
Email string `json:"email"`
@@ -88,7 +89,7 @@ func (a *API) ResourceOwnerPasswordGrant(ctx context.Context, w http.ResponseWri
if cookie != "" && config.Cookie.Duration > 0 {
if terr = a.setCookieToken(config, token.Token, cookie == useSessionCookie, w); terr != nil {
return internalServerError("Failed to set JWT cookie", terr)
return internalServerError("Failed to set JWT cookie. %s", terr)
}
}
return nil
@@ -145,7 +146,7 @@ func (a *API) RefreshTokenGrant(ctx context.Context, w http.ResponseWriter, r *h
if cookie != "" && config.Cookie.Duration > 0 {
if terr = a.setCookieToken(config, tokenString, cookie == useSessionCookie, w); terr != nil {
return internalServerError("Failed to set JWT cookie", terr)
return internalServerError("Failed to set JWT cookie. %s", terr)
}
}
return nil
View
@@ -6,7 +6,7 @@ import (
"github.com/netlify/gotrue/models"
"github.com/netlify/gotrue/storage"
uuid "github.com/satori/go.uuid"
"github.com/gobuffalo/uuid"
)
// UserUpdateParams parameters for updating a user
View
@@ -11,7 +11,7 @@ import (
"github.com/netlify/gotrue/conf"
"github.com/netlify/gotrue/models"
uuid "github.com/satori/go.uuid"
"github.com/gobuffalo/uuid"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
View
@@ -65,7 +65,7 @@ func (a *API) Verify(w http.ResponseWriter, r *http.Request) error {
if cookie != "" && config.Cookie.Duration > 0 {
if terr = a.setCookieToken(config, token.Token, cookie == useSessionCookie, w); terr != nil {
return internalServerError("Failed to set JWT cookie", terr)
return internalServerError("Failed to set JWT cookie. %s", terr)
}
}
return nil
Oops, something went wrong.

0 comments on commit 49e0866

Please sign in to comment.