Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix missing LoginChallenge and LoginSessionID from GetConsentRequest #1105

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions consent/manager_test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,7 @@ func compareAuthenticationRequest(t *testing.T, a, b *AuthenticationRequest) {
assert.EqualValues(t, a.RequestURL, b.RequestURL)
assert.EqualValues(t, a.CSRF, b.CSRF)
assert.EqualValues(t, a.Skip, b.Skip)
assert.EqualValues(t, a.SessionID, b.SessionID)
}

func compareConsentRequest(t *testing.T, a, b *ConsentRequest) {
Expand All @@ -520,4 +521,6 @@ func compareConsentRequest(t *testing.T, a, b *ConsentRequest) {
assert.EqualValues(t, a.RequestURL, b.RequestURL)
assert.EqualValues(t, a.CSRF, b.CSRF)
assert.EqualValues(t, a.Skip, b.Skip)
assert.EqualValues(t, a.LoginChallenge, b.LoginChallenge)
assert.EqualValues(t, a.LoginSessionID, b.LoginSessionID)
}
11 changes: 6 additions & 5 deletions consent/sql_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,14 +200,13 @@ type sqlAuthenticationRequest struct {
CSRF string `db:"csrf"`
AuthenticatedAt *time.Time `db:"authenticated_at"`
RequestedAt time.Time `db:"requested_at"`
SessionID string `db:"login_session_id"`
LoginSessionID string `db:"login_session_id"`
WasHandled bool `db:"was_handled"`
}

type sqlConsentRequest struct {
sqlAuthenticationRequest
LoginChallenge string `db:"login_challenge"`
LoginSessionID string `db:"login_session_id"`
ForcedSubjectIdentifier string `db:"forced_subject_identifier"`
}

Expand Down Expand Up @@ -244,9 +243,8 @@ func newSQLConsentRequest(c *ConsentRequest) (*sqlConsentRequest, error) {
CSRF: c.CSRF,
AuthenticatedAt: toMySQLDateHack(c.AuthenticatedAt),
RequestedAt: c.RequestedAt,
SessionID: c.LoginSessionID,
LoginSessionID: c.LoginSessionID,
},
LoginSessionID: c.LoginSessionID,
LoginChallenge: c.LoginChallenge,
ForcedSubjectIdentifier: c.ForceSubjectIdentifier,
}, nil
Expand All @@ -270,7 +268,7 @@ func newSQLAuthenticationRequest(c *AuthenticationRequest) (*sqlAuthenticationRe
CSRF: c.CSRF,
AuthenticatedAt: toMySQLDateHack(c.AuthenticatedAt),
RequestedAt: c.RequestedAt,
SessionID: c.SessionID,
LoginSessionID: c.SessionID,
}, nil
}

Expand All @@ -293,6 +291,7 @@ func (s *sqlAuthenticationRequest) toAuthenticationRequest(client *client.Client
AuthenticatedAt: fromMySQLDateHack(s.AuthenticatedAt),
RequestedAt: s.RequestedAt,
WasHandled: s.WasHandled,
SessionID: s.LoginSessionID,
}, nil
}

Expand All @@ -316,6 +315,8 @@ func (s *sqlConsentRequest) toConsentRequest(client *client.Client) (*ConsentReq
ForceSubjectIdentifier: s.ForcedSubjectIdentifier,
RequestedAt: s.RequestedAt,
WasHandled: s.WasHandled,
LoginSessionID: s.LoginSessionID,
LoginChallenge: s.LoginChallenge,
}, nil
}

Expand Down
3 changes: 3 additions & 0 deletions consent/sql_helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ func TestSQLAuthenticationConverter(t *testing.T) {
RequestedScope: []string{"scopea", "scopeb"},
Verifier: "verifier",
CSRF: "csrf",
SessionID: "session-id",
}

b := &HandledAuthenticationRequest{
Expand Down Expand Up @@ -112,6 +113,8 @@ func TestSQLConsentConverter(t *testing.T) {
Verifier: "verifier",
CSRF: "csrf",
AuthenticatedAt: time.Now().UTC().Add(-time.Minute),
LoginChallenge: "login-challenge",
LoginSessionID: "login-session-id",
}

b := &HandledConsentRequest{
Expand Down