app-cloudep-permission-server/internal/logic/tokenservice/utils_claims.go

56 lines
703 B
Go
Raw Permalink Normal View History

2024-08-24 14:40:09 +00:00
package tokenservicelogic
type claims map[string]string
func (c claims) SetID(id string) {
c["id"] = id
}
func (c claims) SetRole(role string) {
c["role"] = role
}
func (c claims) SetDeviceID(deviceID string) {
c["device_id"] = deviceID
}
func (c claims) SetScope(scope string) {
c["scope"] = scope
}
func (c claims) Role() string {
role, ok := c["role"]
if !ok {
return ""
}
return role
}
func (c claims) ID() string {
id, ok := c["id"]
if !ok {
return ""
}
return id
}
func (c claims) DeviceID() string {
deviceID, ok := c["device_id"]
if !ok {
return ""
}
return deviceID
}
func (c claims) UID() string {
uid, ok := c["uid"]
if !ok {
return ""
}
return uid
}