-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
/
login_request.go
168 lines (131 loc) · 4.77 KB
/
login_request.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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
// 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 (
"github.com/go-openapi/errors"
"github.com/go-openapi/strfmt"
"github.com/go-openapi/swag"
)
// LoginRequest Contains information on an ongoing login request.
//
// swagger:model loginRequest
type LoginRequest struct {
// Challenge is the identifier ("login challenge") of the login request. It is used to
// identify the session.
Challenge string `json:"challenge,omitempty"`
// client
Client *OAuth2Client `json:"client,omitempty"`
// oidc context
OidcContext *OpenIDConnectContext `json:"oidc_context,omitempty"`
// RequestURL is the original OAuth 2.0 Authorization URL requested by the OAuth 2.0 client. It is the URL which
// initiates the OAuth 2.0 Authorization Code or OAuth 2.0 Implicit flow. This URL is typically not needed, but
// might come in handy if you want to deal with additional request parameters.
RequestURL string `json:"request_url,omitempty"`
// requested access token audience
RequestedAccessTokenAudience StringSlicePipeDelimiter `json:"requested_access_token_audience,omitempty"`
// requested scope
RequestedScope StringSlicePipeDelimiter `json:"requested_scope,omitempty"`
// SessionID is the login session ID. If the user-agent reuses a login session (via cookie / remember flag)
// this ID will remain the same. If the user-agent did not have an existing authentication session (e.g. remember is false)
// this will be a new random value. This value is used as the "sid" parameter in the ID Token and in OIDC Front-/Back-
// channel logout. It's value can generally be used to associate consecutive login requests by a certain user.
SessionID string `json:"session_id,omitempty"`
// Skip, if true, implies that the client has requested the same scopes from the same user previously.
// If true, you can skip asking the user to grant the requested scopes, and simply forward the user to the redirect URL.
//
// This feature allows you to update / set session information.
Skip bool `json:"skip,omitempty"`
// Subject is the user ID of the end-user that authenticated. Now, that end user needs to grant or deny the scope
// requested by the OAuth 2.0 client. If this value is set and `skip` is true, you MUST include this subject type
// when accepting the login request, or the request will fail.
Subject string `json:"subject,omitempty"`
}
// Validate validates this login request
func (m *LoginRequest) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateClient(formats); err != nil {
res = append(res, err)
}
if err := m.validateOidcContext(formats); err != nil {
res = append(res, err)
}
if err := m.validateRequestedAccessTokenAudience(formats); err != nil {
res = append(res, err)
}
if err := m.validateRequestedScope(formats); err != nil {
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *LoginRequest) validateClient(formats strfmt.Registry) error {
if swag.IsZero(m.Client) { // not required
return nil
}
if m.Client != nil {
if err := m.Client.Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("client")
}
return err
}
}
return nil
}
func (m *LoginRequest) validateOidcContext(formats strfmt.Registry) error {
if swag.IsZero(m.OidcContext) { // not required
return nil
}
if m.OidcContext != nil {
if err := m.OidcContext.Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("oidc_context")
}
return err
}
}
return nil
}
func (m *LoginRequest) validateRequestedAccessTokenAudience(formats strfmt.Registry) error {
if swag.IsZero(m.RequestedAccessTokenAudience) { // not required
return nil
}
if err := m.RequestedAccessTokenAudience.Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("requested_access_token_audience")
}
return err
}
return nil
}
func (m *LoginRequest) validateRequestedScope(formats strfmt.Registry) error {
if swag.IsZero(m.RequestedScope) { // not required
return nil
}
if err := m.RequestedScope.Validate(formats); err != nil {
if ve, ok := err.(*errors.Validation); ok {
return ve.ValidateName("requested_scope")
}
return err
}
return nil
}
// MarshalBinary interface implementation
func (m *LoginRequest) MarshalBinary() ([]byte, error) {
if m == nil {
return nil, nil
}
return swag.WriteJSON(m)
}
// UnmarshalBinary interface implementation
func (m *LoginRequest) UnmarshalBinary(b []byte) error {
var res LoginRequest
if err := swag.ReadJSON(b, &res); err != nil {
return err
}
*m = res
return nil
}