forked from kyma-project/control-plane
/
types.go
38 lines (29 loc) · 810 Bytes
/
types.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
37
38
package oauth
import "time"
const (
contentTypeHeader = "Content-Type"
contentTypeApplicationURLEncoded = "application/x-www-form-urlencoded"
grantTypeFieldName = "grant_type"
credentialsGrantType = "client_credentials"
scopeFieldName = "scope"
scopes = "runtime:read runtime:write"
clientIDKey = "client_id"
clientSecretKey = "client_secret"
tokensEndpointKey = "tokens_endpoint"
)
type Token struct {
AccessToken string `json:"access_token"`
Expiration int64 `json:"expires_in"`
}
type credentials struct {
clientID string
clientSecret string
tokensEndpoint string
}
func (token Token) EmptyOrExpired() bool {
if token.AccessToken == "" {
return true
}
expiration := time.Unix(token.Expiration, 0)
return time.Now().After(expiration)
}