Skip to content
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,5 @@ coverage.txt
*.swp
/example/client/client
/example/server/server

.idea/
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
language: go
sudo: false
go_import_path: github.com/go-oauth2/oauth2/v4
go_import_path: github.com/NFTGalaxy/oauth2/v4
go:
- 1.13
before_install:
Expand Down
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
### Download and install

```bash
go get -u -v github.com/go-oauth2/oauth2/v4/...
go get -u -v github.com/NFTGalaxy/oauth2/v4/...
```

### Create file `server.go`
Expand All @@ -43,11 +43,11 @@ import (
"log"
"net/http"

"github.com/go-oauth2/oauth2/v4/errors"
"github.com/go-oauth2/oauth2/v4/manage"
"github.com/go-oauth2/oauth2/v4/models"
"github.com/go-oauth2/oauth2/v4/server"
"github.com/go-oauth2/oauth2/v4/store"
"github.com/NFTGalaxy/oauth2/v4/errors"
"github.com/NFTGalaxy/oauth2/v4/manage"
"github.com/NFTGalaxy/oauth2/v4/models"
"github.com/NFTGalaxy/oauth2/v4/server"
"github.com/NFTGalaxy/oauth2/v4/store"
)

func main() {
Expand Down Expand Up @@ -138,7 +138,7 @@ Simulation examples of authorization code model, please check [example](/example
```go

import (
"github.com/go-oauth2/oauth2/v4/generates"
"github.com/NFTGalaxy/oauth2/v4/generates"
"github.com/dgrijalva/jwt-go"
)

Expand Down Expand Up @@ -189,9 +189,9 @@ Copyright (c) 2016 Lyric
[build-status-image]: https://travis-ci.org/go-oauth2/oauth2.svg?branch=master
[codecov-url]: https://codecov.io/gh/go-oauth2/oauth2
[codecov-image]: https://codecov.io/gh/go-oauth2/oauth2/branch/master/graph/badge.svg
[reportcard-url]: https://goreportcard.com/report/github.com/go-oauth2/oauth2/v4
[reportcard-image]: https://goreportcard.com/badge/github.com/go-oauth2/oauth2/v4
[godoc-url]: https://godoc.org/github.com/go-oauth2/oauth2/v4
[godoc-image]: https://godoc.org/github.com/go-oauth2/oauth2/v4?status.svg
[reportcard-url]: https://goreportcard.com/report/github.com/NFTGalaxy/oauth2/v4
[reportcard-image]: https://goreportcard.com/badge/github.com/NFTGalaxy/oauth2/v4
[godoc-url]: https://godoc.org/github.com/NFTGalaxy/oauth2/v4
[godoc-image]: https://godoc.org/github.com/NFTGalaxy/oauth2/v4?status.svg
[license-url]: http://opensource.org/licenses/MIT
[license-image]: https://img.shields.io/npm/l/express.svg
2 changes: 1 addition & 1 deletion const_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package oauth2_test
import (
"testing"

"github.com/go-oauth2/oauth2/v4"
"github.com/NFTGalaxy/oauth2/v4"
)

func TestValidatePlain(t *testing.T) {
Expand Down
6 changes: 3 additions & 3 deletions doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
// package main
// import (
// "net/http"
// "github.com/go-oauth2/oauth2/v4/manage"
// "github.com/go-oauth2/oauth2/v4/server"
// "github.com/go-oauth2/oauth2/v4/store"
// "github.com/NFTGalaxy/oauth2/v4/manage"
// "github.com/NFTGalaxy/oauth2/v4/server"
// "github.com/NFTGalaxy/oauth2/v4/store"
// )
// func main() {
// manager := manage.NewDefaultManager()
Expand Down
1 change: 1 addition & 0 deletions errors/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ var New = errors.New

// known errors
var (
ErrUnauthorizedUser = errors.New("unauthorized user")
ErrInvalidRedirectURI = errors.New("invalid redirect uri")
ErrInvalidAuthorizeCode = errors.New("invalid authorize code")
ErrInvalidAccessToken = errors.New("invalid access token")
Expand Down
12 changes: 6 additions & 6 deletions example/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ import (
"os"
"time"

"github.com/go-oauth2/oauth2/v4/generates"
"github.com/NFTGalaxy/oauth2/v4/generates"

"github.com/go-oauth2/oauth2/v4/errors"
"github.com/go-oauth2/oauth2/v4/manage"
"github.com/go-oauth2/oauth2/v4/models"
"github.com/go-oauth2/oauth2/v4/server"
"github.com/go-oauth2/oauth2/v4/store"
"github.com/NFTGalaxy/oauth2/v4/errors"
"github.com/NFTGalaxy/oauth2/v4/manage"
"github.com/NFTGalaxy/oauth2/v4/models"
"github.com/NFTGalaxy/oauth2/v4/server"
"github.com/NFTGalaxy/oauth2/v4/store"
"github.com/go-session/session"
)

Expand Down
76 changes: 38 additions & 38 deletions generates/access.go
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
package generates
import (
"bytes"
"context"
"encoding/base64"
"strconv"
"strings"
"github.com/go-oauth2/oauth2/v4"
"github.com/google/uuid"
)
// NewAccessGenerate create to generate the access token instance
func NewAccessGenerate() *AccessGenerate {
return &AccessGenerate{}
}
// AccessGenerate generate the access token
type AccessGenerate struct {
}
// Token based on the UUID generated token
func (ag *AccessGenerate) Token(ctx context.Context, data *oauth2.GenerateBasic, isGenRefresh bool) (string, string, error) {
buf := bytes.NewBufferString(data.Client.GetID())
buf.WriteString(data.UserID)
buf.WriteString(strconv.FormatInt(data.CreateAt.UnixNano(), 10))
access := base64.URLEncoding.EncodeToString([]byte(uuid.NewMD5(uuid.Must(uuid.NewRandom()), buf.Bytes()).String()))
access = strings.ToUpper(strings.TrimRight(access, "="))
refresh := ""
if isGenRefresh {
refresh = base64.URLEncoding.EncodeToString([]byte(uuid.NewSHA1(uuid.Must(uuid.NewRandom()), buf.Bytes()).String()))
refresh = strings.ToUpper(strings.TrimRight(refresh, "="))
}
return access, refresh, nil
}
package generates

import (
"bytes"
"context"
"encoding/base64"
"strconv"
"strings"

"github.com/NFTGalaxy/oauth2/v4"
"github.com/google/uuid"
)

// NewAccessGenerate create to generate the access token instance
func NewAccessGenerate() *AccessGenerate {
return &AccessGenerate{}
}

// AccessGenerate generate the access token
type AccessGenerate struct {
}

// Token based on the UUID generated token
func (ag *AccessGenerate) Token(ctx context.Context, data *oauth2.GenerateBasic, isGenRefresh bool) (string, string, error) {
buf := bytes.NewBufferString(data.Client.GetID())
buf.WriteString(data.UserID)
buf.WriteString(strconv.FormatInt(data.CreateAt.UnixNano(), 10))

access := base64.URLEncoding.EncodeToString([]byte(uuid.NewMD5(uuid.Must(uuid.NewRandom()), buf.Bytes()).String()))
access = strings.ToUpper(strings.TrimRight(access, "="))
refresh := ""
if isGenRefresh {
refresh = base64.URLEncoding.EncodeToString([]byte(uuid.NewSHA1(uuid.Must(uuid.NewRandom()), buf.Bytes()).String()))
refresh = strings.ToUpper(strings.TrimRight(refresh, "="))
}

return access, refresh, nil
}
6 changes: 3 additions & 3 deletions generates/access_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import (
"testing"
"time"

"github.com/go-oauth2/oauth2/v4"
"github.com/go-oauth2/oauth2/v4/generates"
"github.com/go-oauth2/oauth2/v4/models"
"github.com/NFTGalaxy/oauth2/v4"
"github.com/NFTGalaxy/oauth2/v4/generates"
"github.com/NFTGalaxy/oauth2/v4/models"

. "github.com/smartystreets/goconvey/convey"
)
Expand Down
60 changes: 30 additions & 30 deletions generates/authorize.go
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
package generates
import (
"bytes"
"context"
"encoding/base64"
"strings"
"github.com/go-oauth2/oauth2/v4"
"github.com/google/uuid"
)
// NewAuthorizeGenerate create to generate the authorize code instance
func NewAuthorizeGenerate() *AuthorizeGenerate {
return &AuthorizeGenerate{}
}
// AuthorizeGenerate generate the authorize code
type AuthorizeGenerate struct{}
// Token based on the UUID generated token
func (ag *AuthorizeGenerate) Token(ctx context.Context, data *oauth2.GenerateBasic) (string, error) {
buf := bytes.NewBufferString(data.Client.GetID())
buf.WriteString(data.UserID)
token := uuid.NewMD5(uuid.Must(uuid.NewRandom()), buf.Bytes())
code := base64.URLEncoding.EncodeToString([]byte(token.String()))
code = strings.ToUpper(strings.TrimRight(code, "="))
return code, nil
}
package generates

import (
"bytes"
"context"
"encoding/base64"
"strings"

"github.com/NFTGalaxy/oauth2/v4"
"github.com/google/uuid"
)

// NewAuthorizeGenerate create to generate the authorize code instance
func NewAuthorizeGenerate() *AuthorizeGenerate {
return &AuthorizeGenerate{}
}

// AuthorizeGenerate generate the authorize code
type AuthorizeGenerate struct{}

// Token based on the UUID generated token
func (ag *AuthorizeGenerate) Token(ctx context.Context, data *oauth2.GenerateBasic) (string, error) {
buf := bytes.NewBufferString(data.Client.GetID())
buf.WriteString(data.UserID)
token := uuid.NewMD5(uuid.Must(uuid.NewRandom()), buf.Bytes())
code := base64.URLEncoding.EncodeToString([]byte(token.String()))
code = strings.ToUpper(strings.TrimRight(code, "="))

return code, nil
}
6 changes: 3 additions & 3 deletions generates/authorize_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import (
"testing"
"time"

"github.com/go-oauth2/oauth2/v4"
"github.com/go-oauth2/oauth2/v4/generates"
"github.com/go-oauth2/oauth2/v4/models"
"github.com/NFTGalaxy/oauth2/v4"
"github.com/NFTGalaxy/oauth2/v4/generates"
"github.com/NFTGalaxy/oauth2/v4/models"

. "github.com/smartystreets/goconvey/convey"
)
Expand Down
4 changes: 2 additions & 2 deletions generates/jwt_access.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"strings"
"time"

"github.com/go-oauth2/oauth2/v4"
"github.com/go-oauth2/oauth2/v4/errors"
"github.com/NFTGalaxy/oauth2/v4"
"github.com/NFTGalaxy/oauth2/v4/errors"
"github.com/golang-jwt/jwt"
"github.com/google/uuid"
)
Expand Down
6 changes: 3 additions & 3 deletions generates/jwt_access_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import (
"testing"
"time"

"github.com/go-oauth2/oauth2/v4"
"github.com/go-oauth2/oauth2/v4/generates"
"github.com/go-oauth2/oauth2/v4/models"
"github.com/NFTGalaxy/oauth2/v4"
"github.com/NFTGalaxy/oauth2/v4/generates"
"github.com/NFTGalaxy/oauth2/v4/models"
"github.com/golang-jwt/jwt"

. "github.com/smartystreets/goconvey/convey"
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/go-oauth2/oauth2/v4
module github.com/NFTGalaxy/oauth2/v4

go 1.13

Expand Down
1 change: 1 addition & 0 deletions manage.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ type TokenGenerateRequest struct {
CodeVerifier string
AccessTokenExp time.Duration
Request *http.Request
DeviceID string
}

// Manager authorization management interface
Expand Down
8 changes: 4 additions & 4 deletions manage/manage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import (
"testing"
"time"

"github.com/go-oauth2/oauth2/v4"
"github.com/go-oauth2/oauth2/v4/manage"
"github.com/go-oauth2/oauth2/v4/models"
"github.com/go-oauth2/oauth2/v4/store"
"github.com/NFTGalaxy/oauth2/v4"
"github.com/NFTGalaxy/oauth2/v4/manage"
"github.com/NFTGalaxy/oauth2/v4/models"
"github.com/NFTGalaxy/oauth2/v4/store"

. "github.com/smartystreets/goconvey/convey"
)
Expand Down
Loading