File tree Expand file tree Collapse file tree 2 files changed +26
-0
lines changed
Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,8 @@ pub enum AuthenticationData {
1515 /// The `Secret` struct can be imported from
1616 /// `parsec_client::core::secrecy::Secret`.
1717 AppIdentity ( Secret < String > ) ,
18+ /// Used for authentication via
19+ UnixPeerCredentials ,
1820}
1921
2022impl AuthenticationData {
@@ -23,6 +25,7 @@ impl AuthenticationData {
2325 match self {
2426 AuthenticationData :: None => AuthType :: NoAuth ,
2527 AuthenticationData :: AppIdentity ( _) => AuthType :: Direct ,
28+ AuthenticationData :: UnixPeerCredentials => AuthType :: UnixPeerCredentials ,
2629 }
2730 }
2831}
@@ -34,6 +37,10 @@ impl From<&AuthenticationData> for RequestAuth {
3437 AuthenticationData :: AppIdentity ( name) => {
3538 RequestAuth :: new ( name. expose_secret ( ) . bytes ( ) . collect ( ) )
3639 }
40+ AuthenticationData :: UnixPeerCredentials => {
41+ let current_uid = users:: get_current_uid ( ) ;
42+ RequestAuth :: new ( current_uid. to_le_bytes ( ) . to_vec ( ) )
43+ }
3744 }
3845 }
3946}
Original file line number Diff line number Diff line change @@ -774,6 +774,25 @@ fn auth_value_test() {
774774 ) ;
775775}
776776
777+ #[ test]
778+ fn peer_credential_auth_test ( ) {
779+ let mut client: TestBasicClient = Default :: default ( ) ;
780+ client. set_auth_data ( AuthenticationData :: UnixPeerCredentials ) ;
781+ client. set_mock_read ( & get_response_bytes_from_result (
782+ NativeResult :: PsaDestroyKey ( operations:: psa_destroy_key:: Result { } ) ,
783+ ) ) ;
784+ let key_name = String :: from ( "key-name" ) ;
785+ client
786+ . psa_destroy_key ( key_name)
787+ . expect ( "Failed to call destroy key" ) ;
788+
789+ let req = get_req_from_bytes ( client. get_mock_write ( ) ) ;
790+ assert_eq ! (
791+ & users:: get_current_uid( ) . to_le_bytes( ) . to_vec( ) ,
792+ req. auth. buffer. expose_secret( )
793+ ) ;
794+ }
795+
777796#[ test]
778797fn failing_ipc_test ( ) {
779798 let mut client: TestBasicClient = Default :: default ( ) ;
You can’t perform that action at this time.
0 commit comments