/
consent_manager.go
39 lines (33 loc) · 1.37 KB
/
consent_manager.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
package oauth2
import "time"
type ConsentRequest struct {
ID string `json:"id"`
CSRF string `json:"-"`
GrantedScopes []string `json:"-"`
RequestedScope []string `json:"requested_scope,omitempty"`
Audience string `json:"audience"`
Subject string `json:"-"`
ExpiresAt time.Time `json:"expires_at"`
RedirectURL string `json:"redirect_url"`
AccessTokenExtra map[string]interface{} `json:"-"`
IDTokenExtra map[string]interface{} `json:"-"`
Consent string `json:"-"`
}
func (c *ConsentRequest) IsConsentGranted() bool {
return c.Consent == ConsentRequestAccepted
}
type AcceptConsentRequestPayload struct {
AccessTokenExtra map[string]interface{} `json:"access_token_extra"`
IDTokenExtra map[string]interface{} `json:"id_token_extra"`
Subject string `json:"subject"`
GrantScopes []string `json:"grant_scopes"`
}
type ConsentRequestClient interface {
AcceptConsentRequest(id string, payload *AcceptConsentRequestPayload) error
RejectConsentRequest(id string) error
GetConsentRequest(id string) (*ConsentRequest, error)
}
type ConsentRequestManager interface {
PersistConsentRequest(*ConsentRequest) error
ConsentRequestClient
}