Skip to content

Commit

Permalink
style: _
Browse files Browse the repository at this point in the history
  • Loading branch information
2637309949 committed Nov 29, 2021
1 parent 90f01e1 commit efe5e65
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 18 deletions.
Binary file modified examples/aisle/x_test.db
Binary file not shown.
Binary file modified examples/aisle/x_test_localhost.db
Binary file not shown.
Binary file modified examples/scene/x_test.db
Binary file not shown.
26 changes: 13 additions & 13 deletions platform/api/app.auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@ import (
)

// Provider deifned TODO
type Provider interface {
GetName() string
Config(*Identity)
Verify(*Context) (TokenInfo, bool)
Ticket(userId, extra string, ctx *Context) (TokenInfo, error)
}

// Identity deifned TODO
type Identity struct {
jwt *JWT
OAuth2 *server.Server
providers []Provider
}
type (
Provider interface {
GetName() string
Config(*Identity)
Verify(*Context) (TokenInfo, bool)
Ticket(userId, extra string, ctx *Context) (TokenInfo, error)
}
Identity struct {
JWT *JWT
OAuth2 *server.Server
providers []Provider
}
)

// RegisterProvider register auth provider
func (i *Identity) RegisterProvider(provider Provider) {
Expand Down
8 changes: 4 additions & 4 deletions platform/api/app.auth.jwt.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ func NewJWT(secret string, expire int64) *JWT {
}
}

// BearerAuth defined TODO
func (j *JWT) BearerAuth(req *http.Request) (string, bool) {
// Bearer defined TODO
func (j *JWT) Bearer(req *http.Request) (string, bool) {
prefix, auth := "Bearer ", req.Header.Get("Authorization")
if strings.HasPrefix(auth, prefix) {
return auth[len(prefix):], true
Expand Down Expand Up @@ -77,7 +77,7 @@ func (p *JWTProvider) GetName() string {

// Config defined TODO
func (p *JWTProvider) Config(i *Identity) {
p.jwt = i.jwt
p.jwt = i.JWT
}

// parseToken defined TODO
Expand All @@ -90,7 +90,7 @@ func (p *JWTProvider) parseJWTToken(t *jwt.MapClaims) TokenInfo {

// Verify defined TODO
func (p *JWTProvider) Verify(ctx *Context) (TokenInfo, bool) {
if bearer, ok := p.jwt.BearerAuth(ctx.Request()); ok {
if bearer, ok := p.jwt.Bearer(ctx.Request()); ok {
tk, err := p.jwt.LoadAccessToken(bearer)
if err != nil {
logrus.Error(err)
Expand Down
2 changes: 1 addition & 1 deletion platform/api/app.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified platform/x_test.db
Binary file not shown.

0 comments on commit efe5e65

Please sign in to comment.