Skip to content

Commit

Permalink
consent: Add login_challenge and login_session_id to the get consent …
Browse files Browse the repository at this point in the history
…response

Signed-off-by: Joao Cardoso <mail@joao-carlos.com>
  • Loading branch information
jcxplorer committed Oct 23, 2018
1 parent bbc4020 commit 428b8a3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
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

0 comments on commit 428b8a3

Please sign in to comment.