-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
/
previous_consent_session.go
111 lines (86 loc) · 3.01 KB
/
previous_consent_session.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
// Code generated by go-swagger; DO NOT EDIT.
package models
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
strfmt "github.com/go-openapi/strfmt"
"github.com/go-openapi/errors"
"github.com/go-openapi/swag"
)
// PreviousConsentSession PreviousConsentSession PreviousConsentSession The response used to return used consent requests
// same as HandledLoginRequest, just with consent_request exposed as json
// swagger:model PreviousConsentSession
type PreviousConsentSession struct {
// consent request
ConsentRequest *ConsentRequest `json:"consent_request,omitempty"`
// GrantedAudience sets the audience the user authorized the client to use. Should be a subset of `requested_access_token_audience`.
GrantAccessTokenAudience []string `json:"grant_access_token_audience"`
// GrantScope sets the scope the user authorized the client to use. Should be a subset of `requested_scope`
GrantScope []string `json:"grant_scope"`
// Remember, if set to true, tells ORY Hydra to remember this consent authorization and reuse it if the same
// client asks the same user for the same, or a subset of, scope.
Remember bool `json:"remember,omitempty"`
// RememberFor sets how long the consent authorization should be remembered for in seconds. If set to `0`, the
// authorization will be remembered indefinitely.
RememberFor int64 `json:"remember_for,omitempty"`
// session
Session *ConsentRequestSession `json:"session,omitempty"`
}
// Validate validates this previous consent session
func (m *PreviousConsentSession) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateConsentRequest(formats); err != nil {
res = append(res, err)
}
if err := m.validateSession(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *PreviousConsentSession) validateConsentRequest(formats strfmt.Registry) error {
if swag.IsZero(m.ConsentRequest) { // not required
return nil
}
if m.ConsentRequest != nil {
if err := m.ConsentRequest.Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("consent_request")
}
return err
}
}
return nil
}
func (m *PreviousConsentSession) validateSession(formats strfmt.Registry) error {
if swag.IsZero(m.Session) { // not required
return nil
}
if m.Session != nil {
if err := m.Session.Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("session")
}
return err
}
}
return nil
}
// MarshalBinary interface implementation
func (m *PreviousConsentSession) MarshalBinary() ([]byte, error) {
if m == nil {
return nil, nil
}
return swag.WriteJSON(m)
}
// UnmarshalBinary interface implementation
func (m *PreviousConsentSession) UnmarshalBinary(b []byte) error {
var res PreviousConsentSession
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*m = res
return nil
}