-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for Hardware Key PIN (#31743)
* Update RFD with hardware key pin policies. * Consolidate policy logic and update tests. * Add pin private key policies; Make PIV PIN/Touch prompts work together. * Prompt user to set pin/puk from default. * Handle unexpected PIN auth errors. * Resolve RFD password prompt comment. * Handle incompatible private key policy in role sets (future-proof). * Resolve comment on require mfa type string godocs and tests. * A satisfying change. * Address PIN/PUK prompt comments and other code suggestions. * Resolve comments. * Fix test that prompts for pin twice. * Fix test.
- Loading branch information
1 parent
025b9de
commit 85b6db2
Showing
25 changed files
with
2,270 additions
and
1,711 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* | ||
Copyright 2022 Gravitational, Inc. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package types | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
// TestMarshalUnmarshalRequireMFAType tests encoding/decoding of the RequireMFAType. | ||
func TestEncodeDecodeRequireMFAType(t *testing.T) { | ||
for _, tt := range []struct { | ||
requireMFAType RequireMFAType | ||
encoded any | ||
}{ | ||
{ | ||
requireMFAType: RequireMFAType_OFF, | ||
encoded: false, | ||
}, { | ||
requireMFAType: RequireMFAType_SESSION, | ||
encoded: true, | ||
}, { | ||
requireMFAType: RequireMFAType_SESSION_AND_HARDWARE_KEY, | ||
encoded: RequireMFATypeHardwareKeyString, | ||
}, { | ||
requireMFAType: RequireMFAType_HARDWARE_KEY_TOUCH, | ||
encoded: RequireMFATypeHardwareKeyTouchString, | ||
}, { | ||
requireMFAType: RequireMFAType_HARDWARE_KEY_PIN, | ||
encoded: RequireMFATypeHardwareKeyPINString, | ||
}, { | ||
requireMFAType: RequireMFAType_HARDWARE_KEY_TOUCH_AND_PIN, | ||
encoded: RequireMFATypeHardwareKeyTouchAndPINString, | ||
}, | ||
} { | ||
t.Run(tt.requireMFAType.String(), func(t *testing.T) { | ||
t.Run("encode", func(t *testing.T) { | ||
encoded, err := tt.requireMFAType.encode() | ||
require.NoError(t, err) | ||
require.Equal(t, tt.encoded, encoded) | ||
}) | ||
|
||
t.Run("decode", func(t *testing.T) { | ||
var decoded RequireMFAType | ||
err := decoded.decode(tt.encoded) | ||
require.NoError(t, err) | ||
require.Equal(t, tt.requireMFAType, decoded) | ||
}) | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.