11use async_trait:: async_trait;
22use cubesql:: {
33 di_service,
4- sql:: { AuthContext , AuthenticateResponse , SqlAuthService } ,
4+ sql:: { AuthContext , AuthenticateResponse , SqlAuthService , SqlAuthServiceAuthenticateRequest } ,
55 transport:: LoadRequestMeta ,
66 CubeError ,
77} ;
@@ -50,9 +50,28 @@ pub struct TransportRequest {
5050 pub meta : Option < LoadRequestMeta > ,
5151}
5252
53+ #[ derive( Debug , Serialize ) ]
54+ pub struct TransportAuthRequest {
55+ pub id : String ,
56+ pub meta : Option < LoadRequestMeta > ,
57+ pub protocol : String ,
58+ pub method : String ,
59+ }
60+
61+ impl From < ( TransportRequest , SqlAuthServiceAuthenticateRequest ) > for TransportAuthRequest {
62+ fn from ( ( t, a) : ( TransportRequest , SqlAuthServiceAuthenticateRequest ) ) -> Self {
63+ Self {
64+ id : t. id ,
65+ meta : t. meta ,
66+ protocol : a. protocol ,
67+ method : a. method ,
68+ }
69+ }
70+ }
71+
5372#[ derive( Debug , Serialize ) ]
5473struct CheckSQLAuthTransportRequest {
55- request : TransportRequest ,
74+ request : TransportAuthRequest ,
5675 user : Option < String > ,
5776 password : Option < String > ,
5877}
@@ -92,6 +111,7 @@ impl AuthContext for NativeSQLAuthContext {
92111impl SqlAuthService for NodeBridgeAuthService {
93112 async fn authenticate (
94113 & self ,
114+ request : SqlAuthServiceAuthenticateRequest ,
95115 user : Option < String > ,
96116 password : Option < String > ,
97117 ) -> Result < AuthenticateResponse , CubeError > {
@@ -100,9 +120,11 @@ impl SqlAuthService for NodeBridgeAuthService {
100120 let request_id = Uuid :: new_v4 ( ) . to_string ( ) ;
101121
102122 let extra = serde_json:: to_string ( & CheckSQLAuthTransportRequest {
103- request : TransportRequest {
123+ request : TransportAuthRequest {
104124 id : format ! ( "{}-span-1" , request_id) ,
105125 meta : None ,
126+ protocol : request. protocol ,
127+ method : request. method ,
106128 } ,
107129 user : user. clone ( ) ,
108130 password : password. clone ( ) ,
0 commit comments