Skip to content

Commit ba0cb06

Browse files
zepatrikory-bot
authored andcommitted
chore: remove db tags from fields that are not supposed to be stored
GitOrigin-RevId: 50e6feb45583953e40aa1d2eac8f5318fc5fc844
1 parent c309185 commit ba0cb06

22 files changed

+118
-512
lines changed

consent/test/manager_test_helpers.go

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -409,25 +409,24 @@ func ConsentManagerTests(t *testing.T, deps Deps, m consent.Manager, loginManage
409409
require.NoError(t, clientManager.CreateClient(t.Context(), cl))
410410

411411
f := &flow.Flow{
412+
ID: uuidx.NewV4().String(),
412413
NID: deps.Networker().NetworkID(t.Context()),
413414
OpenIDConnectContext: &flow.OAuth2ConsentRequestOpenIDConnectContext{
414415
ACRValues: []string{"1", "2"},
415416
UILocales: []string{"fr", "de"},
416417
Display: "popup",
417418
},
418-
RequestedAt: time.Now().UTC().Add(-time.Hour),
419-
Client: cl,
420-
Subject: ls.Subject,
421-
RequestURL: "https://request-url/path",
422-
LoginSkip: true,
423-
RequestedScope: []string{"scopea", "scopeb"},
424-
SessionID: sqlxx.NullString(ls.ID),
425-
ConsentRequestID: sqlxx.NullString(uuid.Must(uuid.NewV4()).String()),
426-
ConsentCSRF: sqlxx.NullString(uuid.Must(uuid.NewV4()).String()),
427-
428-
LoginCSRF: uuid.Must(uuid.NewV4()).String(),
429-
ID: uuid.Must(uuid.NewV4()).String(),
430-
State: flow.FlowStateLoginUsed,
419+
ACR: "1",
420+
AMR: sqlxx.StringSliceJSONFormat{"passwd"},
421+
RequestedAt: time.Now().UTC().Add(-time.Hour),
422+
Client: cl,
423+
Subject: ls.Subject,
424+
RequestURL: "https://request-url/path",
425+
RequestedScope: []string{"scopea", "scopeb"},
426+
SessionID: sqlxx.NullString(ls.ID),
427+
ConsentRequestID: sqlxx.NullString(uuid.Must(uuid.NewV4()).String()),
428+
GrantedScope: sqlxx.StringSliceJSONFormat{"scopea", "scopeb"},
429+
ConsentRememberFor: pointerx.Ptr(0),
431430
}
432431

433432
require.NoError(t, m.CreateConsentSession(t.Context(), f))

flow/flow.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ type Flow struct {
141141
// This feature allows you to update / set session information.
142142
//
143143
// required: true
144-
LoginSkip bool `db:"login_skip" json:"ls,omitempty"`
144+
LoginSkip bool `db:"-" json:"ls,omitempty"`
145145

146146
// Subject is the user ID of the end-user that authenticated. Now, that end user needs to grant or deny the scope
147147
// requested by the OAuth 2.0 client. If this value is set and `skip` is true, you MUST include this subject type
@@ -177,24 +177,24 @@ type Flow struct {
177177
// If specified, we will use this value to propagate the logout.
178178
IdentityProviderSessionID sqlxx.NullString `db:"identity_provider_session_id" json:"is,omitempty"`
179179

180-
LoginCSRF string `db:"login_csrf" json:"lc,omitempty"`
180+
LoginCSRF string `db:"-" json:"lc,omitempty"`
181181

182182
RequestedAt time.Time `db:"requested_at" json:"ia,omitempty"`
183183

184-
State State `db:"state" json:"q,omitempty"`
184+
State State `db:"-" json:"q,omitempty"`
185185

186186
// LoginRemember, if set to true, tells ORY Hydra to remember this user by telling the user agent (browser) to store
187187
// a cookie with authentication data. If the same user performs another OAuth 2.0 Authorization Request, he/she
188188
// will not be asked to log in again.
189-
LoginRemember bool `db:"login_remember" json:"lr,omitempty"`
189+
LoginRemember bool `db:"-" json:"lr,omitempty"`
190190

191191
// LoginRememberFor sets how long the authentication should be remembered for in seconds. If set to `0`, the
192192
// authorization will be remembered for the duration of the browser session (using a session cookie).
193-
LoginRememberFor int `db:"login_remember_for" json:"lf,omitempty"`
193+
LoginRememberFor int `db:"-" json:"lf,omitempty"`
194194

195195
// LoginExtendSessionLifespan, if set to true, session cookie expiry time will be updated when session is
196196
// refreshed (login skip=true).
197-
LoginExtendSessionLifespan bool `db:"login_extend_session_lifespan" json:"ll,omitempty"`
197+
LoginExtendSessionLifespan bool `db:"-" json:"ll,omitempty"`
198198

199199
// ACR sets the Authentication AuthorizationContext Class Reference value for this authentication session. You can use it
200200
// to express that, for example, a user authenticated using two factor authentication.
@@ -230,17 +230,17 @@ type Flow struct {
230230
// data.
231231
Context sqlxx.JSONRawMessage `db:"context" json:"ct"`
232232

233-
LoginError *RequestDeniedError `db:"login_error" json:"le,omitempty"`
234-
LoginAuthenticatedAt sqlxx.NullTime `db:"login_authenticated_at" json:"la,omitempty"`
233+
LoginError *RequestDeniedError `db:"-" json:"le,omitempty"`
234+
LoginAuthenticatedAt sqlxx.NullTime `db:"-" json:"la,omitempty"`
235235

236236
// DeviceChallengeID is the device request's challenge ID
237237
DeviceChallengeID sqlxx.NullString `db:"device_challenge_id" json:"di,omitempty"`
238238
// DeviceCodeRequestID is the device request's ID
239239
DeviceCodeRequestID sqlxx.NullString `db:"device_code_request_id" json:"dr,omitempty"`
240240
// DeviceCSRF is the device request's CSRF
241-
DeviceCSRF sqlxx.NullString `db:"device_csrf" json:"dc,omitempty"`
241+
DeviceCSRF sqlxx.NullString `db:"-" json:"dc,omitempty"`
242242
// DeviceHandledAt contains the timestamp the device user_code verification request was handled
243-
DeviceHandledAt sqlxx.NullTime `db:"device_handled_at" json:"dh,omitempty"`
243+
DeviceHandledAt sqlxx.NullTime `db:"-" json:"dh,omitempty"`
244244

245245
// ConsentRequestID is the identifier of the consent request.
246246
// The database column should be named `consent_request_id`, but is not for historical reasons.
@@ -249,7 +249,7 @@ type Flow struct {
249249
// If true, you must not ask the user to grant the requested scopes. You must however either allow or deny the
250250
// consent request using the usual API call.
251251
ConsentSkip bool `db:"consent_skip" json:"cs,omitempty"`
252-
ConsentCSRF sqlxx.NullString `db:"consent_csrf" json:"cr,omitempty"`
252+
ConsentCSRF sqlxx.NullString `db:"-" json:"cr,omitempty"`
253253

254254
// GrantedScope sets the scope the user authorized the client to use. Should be a subset of `requested_scope`.
255255
GrantedScope sqlxx.StringSliceJSONFormat `db:"granted_scope" json:"gs,omitempty"`
@@ -268,7 +268,7 @@ type Flow struct {
268268
// ConsentHandledAt contains the timestamp the consent request was handled.
269269
ConsentHandledAt sqlxx.NullTime `db:"consent_handled_at" json:"ch,omitempty"`
270270

271-
ConsentError *RequestDeniedError `db:"consent_error" json:"cx"`
271+
ConsentError *RequestDeniedError `db:"-" json:"cx"`
272272
SessionIDToken sqlxx.MapStringInterface `db:"session_id_token" faker:"-" json:"st"`
273273
SessionAccessToken sqlxx.MapStringInterface `db:"session_access_token" faker:"-" json:"sa"`
274274
}

persistence/sql/migratest/fixtures/hydra_oauth2_flow/challenge-0001.json

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,47 +4,26 @@
44
"rs": [
55
"requested_scope-0001_1"
66
],
7-
"ls": true,
87
"s": "subject-0001",
98
"oc": {
109
"display": "display-0001"
1110
},
1211
"ci": "client-0014",
1312
"r": "http://request/0001",
14-
"lc": "csrf-0001",
1513
"ia": "2022-02-15T22:20:21Z",
16-
"q": 128,
17-
"lr": true,
18-
"lf": 1,
1914
"a": "acr-0001",
2015
"ct": {},
21-
"le": {
22-
"error": "",
23-
"error_description": "",
24-
"error_hint": "",
25-
"status_code": 0,
26-
"error_debug": "",
27-
"valid": false
28-
},
29-
"la": "2022-02-15T22:20:21Z",
16+
"la": null,
3017
"dh": null,
3118
"cc": "challenge-0001",
3219
"cs": true,
33-
"cr": "csrf-0001",
3420
"gs": [
3521
"granted_scope-0001_1"
3622
],
3723
"ce": true,
3824
"cf": 1,
3925
"ch": null,
40-
"cx": {
41-
"error": "",
42-
"error_description": "",
43-
"error_hint": "",
44-
"status_code": 0,
45-
"error_debug": "",
46-
"valid": false
47-
},
26+
"cx": null,
4827
"st": {
4928
"session_id_token-0001": "0001"
5029
},

persistence/sql/migratest/fixtures/hydra_oauth2_flow/challenge-0002.json

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,48 +4,27 @@
44
"rs": [
55
"requested_scope-0002_1"
66
],
7-
"ls": true,
87
"s": "subject-0002",
98
"oc": {
109
"display": "display-0002"
1110
},
1211
"ci": "client-0014",
1312
"r": "http://request/0002",
14-
"lc": "csrf-0002",
1513
"ia": "2022-02-15T22:20:21Z",
16-
"q": 128,
17-
"lr": true,
18-
"lf": 2,
1914
"a": "acr-0002",
2015
"fs": "force_subject_id-0002",
2116
"ct": {},
22-
"le": {
23-
"error": "",
24-
"error_description": "",
25-
"error_hint": "",
26-
"status_code": 0,
27-
"error_debug": "",
28-
"valid": false
29-
},
30-
"la": "2022-02-15T22:20:21Z",
17+
"la": null,
3118
"dh": null,
3219
"cc": "challenge-0002",
3320
"cs": true,
34-
"cr": "csrf-0002",
3521
"gs": [
3622
"granted_scope-0002_1"
3723
],
3824
"ce": true,
3925
"cf": 2,
4026
"ch": null,
41-
"cx": {
42-
"error": "",
43-
"error_description": "",
44-
"error_hint": "",
45-
"status_code": 0,
46-
"error_debug": "",
47-
"valid": false
48-
},
27+
"cx": null,
4928
"st": {
5029
"session_id_token-0002": "0002"
5130
},

persistence/sql/migratest/fixtures/hydra_oauth2_flow/challenge-0003.json

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,49 +4,28 @@
44
"rs": [
55
"requested_scope-0003_1"
66
],
7-
"ls": true,
87
"s": "subject-0003",
98
"oc": {
109
"display": "display-0003"
1110
},
1211
"ci": "client-0014",
1312
"r": "http://request/0003",
1413
"si": "auth_session-0003",
15-
"lc": "csrf-0003",
1614
"ia": "2022-02-15T22:20:21Z",
17-
"q": 128,
18-
"lr": true,
19-
"lf": 3,
2015
"a": "acr-0003",
2116
"fs": "force_subject_id-0003",
2217
"ct": {},
23-
"le": {
24-
"error": "",
25-
"error_description": "",
26-
"error_hint": "",
27-
"status_code": 0,
28-
"error_debug": "",
29-
"valid": false
30-
},
31-
"la": "2022-02-15T22:20:21Z",
18+
"la": null,
3219
"dh": null,
3320
"cc": "challenge-0003",
3421
"cs": true,
35-
"cr": "csrf-0003",
3622
"gs": [
3723
"granted_scope-0003_1"
3824
],
3925
"ce": true,
4026
"cf": 3,
4127
"ch": null,
42-
"cx": {
43-
"error": "",
44-
"error_description": "",
45-
"error_hint": "",
46-
"status_code": 0,
47-
"error_debug": "",
48-
"valid": false
49-
},
28+
"cx": null,
5029
"st": {
5130
"session_id_token-0003": "0003"
5231
},

persistence/sql/migratest/fixtures/hydra_oauth2_flow/challenge-0004.json

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,35 +7,21 @@
77
"ra": [
88
"requested_audience-0004_1"
99
],
10-
"ls": true,
1110
"s": "subject-0004",
1211
"oc": {
1312
"display": "display-0004"
1413
},
1514
"ci": "client-0014",
1615
"r": "http://request/0004",
1716
"si": "auth_session-0004",
18-
"lc": "csrf-0004",
1917
"ia": "2022-02-15T22:20:21Z",
20-
"q": 128,
21-
"lr": true,
22-
"lf": 4,
2318
"a": "acr-0004",
2419
"fs": "force_subject_id-0004",
2520
"ct": {},
26-
"le": {
27-
"error": "",
28-
"error_description": "",
29-
"error_hint": "",
30-
"status_code": 0,
31-
"error_debug": "",
32-
"valid": false
33-
},
34-
"la": "2022-02-15T22:20:21Z",
21+
"la": null,
3522
"dh": null,
3623
"cc": "challenge-0004",
3724
"cs": true,
38-
"cr": "csrf-0004",
3925
"gs": [
4026
"granted_scope-0004_1"
4127
],
@@ -45,14 +31,7 @@
4531
"ce": true,
4632
"cf": 4,
4733
"ch": null,
48-
"cx": {
49-
"error": "",
50-
"error_description": "",
51-
"error_hint": "",
52-
"status_code": 0,
53-
"error_debug": "",
54-
"valid": false
55-
},
34+
"cx": null,
5635
"st": {
5736
"session_id_token-0004": "0004"
5837
},

persistence/sql/migratest/fixtures/hydra_oauth2_flow/challenge-0005.json

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,35 +7,21 @@
77
"ra": [
88
"requested_audience-0005_1"
99
],
10-
"ls": true,
1110
"s": "subject-0005",
1211
"oc": {
1312
"display": "display-0005"
1413
},
1514
"ci": "client-0014",
1615
"r": "http://request/0005",
1716
"si": "auth_session-0005",
18-
"lc": "csrf-0005",
1917
"ia": "2022-02-15T22:20:21Z",
20-
"q": 128,
21-
"lr": true,
22-
"lf": 5,
2318
"a": "acr-0005",
2419
"fs": "force_subject_id-0005",
2520
"ct": {},
26-
"le": {
27-
"error": "",
28-
"error_description": "",
29-
"error_hint": "",
30-
"status_code": 0,
31-
"error_debug": "",
32-
"valid": false
33-
},
34-
"la": "2022-02-15T22:20:21Z",
21+
"la": null,
3522
"dh": null,
3623
"cc": "challenge-0005",
3724
"cs": true,
38-
"cr": "csrf-0005",
3925
"gs": [
4026
"granted_scope-0005_1"
4127
],
@@ -45,14 +31,7 @@
4531
"ce": true,
4632
"cf": 5,
4733
"ch": null,
48-
"cx": {
49-
"error": "",
50-
"error_description": "",
51-
"error_hint": "",
52-
"status_code": 0,
53-
"error_debug": "",
54-
"valid": false
55-
},
34+
"cx": null,
5635
"st": {
5736
"session_id_token-0005": "0005"
5837
},

0 commit comments

Comments
 (0)