MakeJWT 시그니처 수정
This commit is contained in:
@ -135,13 +135,13 @@ func init() {
|
|||||||
jwtHeader = string(dst[:enclen])
|
jwtHeader = string(dst[:enclen])
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) MakeJWT(subject string, ttl time.Duration) string {
|
func (c *Client) MakeJWT(subject string, role string, ttl time.Duration) string {
|
||||||
if len(c.signingKey) == 0 {
|
if len(c.signingKey) == 0 {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
now := time.Now().UTC().Add(ttl).Add(time.Hour).Unix()
|
now := time.Now().UTC().Add(ttl).Add(time.Hour).Unix()
|
||||||
src := []byte(fmt.Sprintf(`{"exp":%d,"sub":"%s","roles":"ds_client_full_access"}`, now, subject))
|
src := []byte(fmt.Sprintf(`{"exp":%d,"sub":"%s","roles":"%s"}`, now, subject, role))
|
||||||
payload := make([]byte, encoding.EncodedLen(len(src)))
|
payload := make([]byte, encoding.EncodedLen(len(src)))
|
||||||
encoding.Encode(payload, src)
|
encoding.Encode(payload, src)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user