Skip to content

Commit

Permalink
add signature algorithm suite to ping response (#44567)
Browse files Browse the repository at this point in the history
* add signature algorithm suite to ping response

* type fix

Co-authored-by: Tiago Silva <[email protected]>

---------

Co-authored-by: Tiago Silva <[email protected]>
  • Loading branch information
nklaassen and tigrato authored Jul 24, 2024
1 parent f03639b commit bca26e0
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
3 changes: 3 additions & 0 deletions api/client/webclient/webclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,9 @@ type AuthenticationSettings struct {
// DefaultSessionTTL is the TTL requested for user certs if
// a TTL is not otherwise specified.
DefaultSessionTTL types.Duration `json:"default_session_ttl"`
// SignatureAlgorithmSuite is the configured signature algorithm suite for
// the cluster.
SignatureAlgorithmSuite types.SignatureAlgorithmSuite `json:"signature_algorithm_suite,omitempty"`
}

// LocalSettings holds settings for local authentication.
Expand Down
4 changes: 2 additions & 2 deletions api/types/signaturealgorithmsuite.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import (

// MarshalText marshals a SignatureAlgorithmSuite value to text. This gets used
// by json.Marshal.
func (s *SignatureAlgorithmSuite) MarshalText() ([]byte, error) {
switch *s {
func (s SignatureAlgorithmSuite) MarshalText() ([]byte, error) {
switch s {
case SignatureAlgorithmSuite_SIGNATURE_ALGORITHM_SUITE_LEGACY:
return []byte("legacy"), nil
case SignatureAlgorithmSuite_SIGNATURE_ALGORITHM_SUITE_BALANCED_V1:
Expand Down
1 change: 1 addition & 0 deletions lib/web/apiserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -1326,6 +1326,7 @@ func getAuthSettings(ctx context.Context, authClient authclient.ClientI) (webcli
}
as.LoadAllCAs = pingResp.LoadAllCAs
as.DefaultSessionTTL = authPreference.GetDefaultSessionTTL()
as.SignatureAlgorithmSuite = authPreference.GetSignatureAlgorithmSuite()

return as, nil
}
Expand Down
11 changes: 11 additions & 0 deletions lib/web/apiserver_ping_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,17 @@ func TestPing(t *testing.T) {
webCfg, _ := cap.GetWebauthn()
require.NotNil(t, resp.Auth.Webauthn)
assert.Equal(t, webCfg.RPID, resp.Auth.Webauthn.RPID)

assert.Equal(t, types.SignatureAlgorithmSuite_SIGNATURE_ALGORITHM_SUITE_UNSPECIFIED, resp.Auth.SignatureAlgorithmSuite)
},
},
{
name: "OK signature algorithm suite",
spec: &types.AuthPreferenceSpecV2{
SignatureAlgorithmSuite: types.SignatureAlgorithmSuite_SIGNATURE_ALGORITHM_SUITE_BALANCED_V1,
},
assertResp: func(cap types.AuthPreference, resp *webclient.PingResponse) {
assert.Equal(t, types.SignatureAlgorithmSuite_SIGNATURE_ALGORITHM_SUITE_BALANCED_V1, resp.Auth.SignatureAlgorithmSuite)
},
},
{
Expand Down

0 comments on commit bca26e0

Please sign in to comment.