-
Notifications
You must be signed in to change notification settings - Fork 0
/
jwt.go
36 lines (29 loc) · 861 Bytes
/
jwt.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package model
import (
"encoding/json"
"github.com/ffauzann/authentication/internal/constant"
"github.com/golang-jwt/jwt/v4"
)
type JwtConfig struct {
SigningKey string
Iss string
Exp string
}
type Claims struct {
UserId uint64 `json:"user_id"`
Name string `json:"name"`
Username string `json:"username"`
Email string `json:"email"`
PhoneNumber string `json:"phone_number"`
Roles []string `json:"roles"`
TokenType constant.TokenType `json:"token_type"`
jwt.RegisteredClaims
}
type Token struct {
AccessToken string `json:"access_token"`
RefreshToken string `json:"refresh_token"`
}
// MarshalBinary fulfills encoding.BinaryMarshaler implementation.
func (t Token) MarshalBinary() ([]byte, error) {
return json.Marshal(t)
}