This repository has been archived by the owner on Apr 9, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 18
/
oauth_token.go
65 lines (55 loc) · 1.74 KB
/
oauth_token.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package stormpath
import "net/url"
//OAuthToken represents the Stormpath OAuthToken see: https://docs.stormpath.com/guides/token-management/
type OAuthToken struct {
resource
Account *Account `json:"account"`
Application *Application `json:"application"`
Tenant *Tenant `json:"tenant"`
JWT string `json:"jwt"`
ExpandedJWT ExpandedJWT `json:"expandedJwt"`
}
//ExpandedJWT represents the OAuth token expanded JWT information
type ExpandedJWT struct {
Claims Claims `json:"claims"`
Header Header `json:"header"`
Signature string `json:"signature"`
}
//Claims represents the expanded JWT claims
type Claims struct {
EXP int64 `json:"exp"`
IAT int64 `json:"iat"`
ISS string `json:"iss"`
JTI string `json:"jti"`
RTI string `json:"rti"`
SUB string `json:"sub"`
}
//Header represents the expanded JWT header
type Header struct {
ALG string `json:"alg"`
KID string `json:"kid"`
STT string `json:"stt"`
}
//OAuthTokens collection type for OAuthToken
type OAuthTokens struct {
collectionResource
Items []OAuthToken `json:"items,omitempty"`
}
//OAuthResponse represents an OAuth2 response from StormPath
type OAuthResponse struct {
AccessToken string `json:"access_token"`
RefreshToken string `json:"refresh_token,omitempty"`
TokenType string `json:"token_type"`
ExpiresIn int `json:"expires_in"`
StormpathAccessTokenHref string `json:"stormpath_access_token_href,omitempty"`
}
type OAuthTokenCriteria struct {
baseCriteria
}
func MakeOAuthTokensCriteria() OAuthTokenCriteria {
return OAuthTokenCriteria{baseCriteria{limit: 25, filter: url.Values{}}}
}
//Delete deletes the given OAuthToken
func (t *OAuthToken) Delete() error {
return client.delete(t.Href)
}