@@ -11,6 +11,7 @@ use stackable_operator::{
1111    } , 
1212    schemars:: { self ,  JsonSchema } , 
1313} ; 
14+ use  stackable_versioned:: versioned; 
1415use  tracing:: info; 
1516
1617// The assumed OIDC provider if no hint is given in the AuthClass 
@@ -88,33 +89,36 @@ pub enum Error {
8889
8990type  Result < T ,  E  = Error >  = std:: result:: Result < T ,  E > ; 
9091
91- #[ derive( Clone ,  Debug ,  Deserialize ,  Eq ,  JsonSchema ,  PartialEq ,  Serialize ) ]  
92- #[ serde( rename_all = "camelCase" ) ]  
93- pub  struct  SupersetClientAuthenticationDetails  { 
94-     #[ serde( flatten) ]  
95-     pub  common :  ClientAuthenticationDetails < ( ) > , 
96- 
97-     /// Allow users who are not already in the FAB DB. 
98-      /// Gets mapped to `AUTH_USER_REGISTRATION` 
99-      #[ serde( default  = "default_user_registration" ) ]  
100-     pub  user_registration :  bool , 
101- 
102-     /// This role will be given in addition to any AUTH_ROLES_MAPPING. 
103-      /// Gets mapped to `AUTH_USER_REGISTRATION_ROLE` 
104-      #[ serde( default  = "default_user_registration_role" ) ]  
105-     pub  user_registration_role :  String , 
106- 
107-     /// If we should replace ALL the user's roles each login, or only on registration. 
108-      /// Gets mapped to `AUTH_ROLES_SYNC_AT_LOGIN` 
109-      #[ serde( default ) ]  
110-     pub  sync_roles_at :  FlaskRolesSyncMoment , 
111- } 
92+ #[ versioned( version( name = "v1alpha1" ) ) ]  
93+ pub  mod  versioned { 
94+     #[ derive( Clone ,  Debug ,  Deserialize ,  Eq ,  JsonSchema ,  PartialEq ,  Serialize ) ]  
95+     #[ serde( rename_all = "camelCase" ) ]  
96+     pub  struct  SupersetClientAuthenticationDetails  { 
97+         #[ serde( flatten) ]  
98+         pub  common :  ClientAuthenticationDetails < ( ) > , 
99+ 
100+         /// Allow users who are not already in the FAB DB. 
101+          /// Gets mapped to `AUTH_USER_REGISTRATION` 
102+          #[ serde( default  = "default_user_registration" ) ]  
103+         pub  user_registration :  bool , 
104+ 
105+         /// This role will be given in addition to any AUTH_ROLES_MAPPING. 
106+          /// Gets mapped to `AUTH_USER_REGISTRATION_ROLE` 
107+          #[ serde( default  = "default_user_registration_role" ) ]  
108+         pub  user_registration_role :  String , 
109+ 
110+         /// If we should replace ALL the user's roles each login, or only on registration. 
111+          /// Gets mapped to `AUTH_ROLES_SYNC_AT_LOGIN` 
112+          #[ serde( default ) ]  
113+         pub  sync_roles_at :  FlaskRolesSyncMoment , 
114+     } 
112115
113- #[ derive( Clone ,  Debug ,  Default ,  Deserialize ,  Eq ,  JsonSchema ,  PartialEq ,  Serialize ) ]  
114- pub  enum  FlaskRolesSyncMoment  { 
115-     #[ default]  
116-     Registration , 
117-     Login , 
116+     #[ derive( Clone ,  Debug ,  Default ,  Deserialize ,  Eq ,  JsonSchema ,  PartialEq ,  Serialize ) ]  
117+     pub  enum  FlaskRolesSyncMoment  { 
118+         #[ default]  
119+         Registration , 
120+         Login , 
121+     } 
118122} 
119123
120124/// Resolved and validated counter part for `SupersetClientAuthenticationDetails`. 
@@ -123,7 +127,7 @@ pub struct SupersetClientAuthenticationDetailsResolved {
123127    pub  authentication_classes_resolved :  Vec < SupersetAuthenticationClassResolved > , 
124128    pub  user_registration :  bool , 
125129    pub  user_registration_role :  String , 
126-     pub  sync_roles_at :  FlaskRolesSyncMoment , 
130+     pub  sync_roles_at :  v1alpha1 :: FlaskRolesSyncMoment , 
127131} 
128132
129133#[ derive( Clone ,  Debug ,  Eq ,  PartialEq ) ]  
@@ -147,7 +151,7 @@ pub fn default_user_registration_role() -> String {
147151
148152impl  SupersetClientAuthenticationDetailsResolved  { 
149153    pub  async  fn  from ( 
150-         auth_details :  & [ SupersetClientAuthenticationDetails ] , 
154+         auth_details :  & [ v1alpha1 :: SupersetClientAuthenticationDetails ] , 
151155        client :  & Client , 
152156    )  -> Result < SupersetClientAuthenticationDetailsResolved >  { 
153157        let  resolve_auth_class = |auth_details :  ClientAuthenticationDetails | async  move  { 
@@ -157,7 +161,7 @@ impl SupersetClientAuthenticationDetailsResolved {
157161    } 
158162
159163    pub  async  fn  resolve < R > ( 
160-         auth_details :  & [ SupersetClientAuthenticationDetails ] , 
164+         auth_details :  & [ v1alpha1 :: SupersetClientAuthenticationDetails ] , 
161165        resolve_auth_class :  impl  Fn ( ClientAuthenticationDetails )  -> R , 
162166    )  -> Result < SupersetClientAuthenticationDetailsResolved > 
163167    where 
@@ -264,14 +268,14 @@ impl SupersetClientAuthenticationDetailsResolved {
264268            user_registration :  user_registration. unwrap_or_else ( default_user_registration) , 
265269            user_registration_role :  user_registration_role
266270                . unwrap_or_else ( default_user_registration_role) , 
267-             sync_roles_at :  sync_roles_at. unwrap_or_else ( FlaskRolesSyncMoment :: default) , 
271+             sync_roles_at :  sync_roles_at. unwrap_or_else ( v1alpha1 :: FlaskRolesSyncMoment :: default) , 
268272        } ) 
269273    } 
270274
271275    fn  from_oidc ( 
272276        auth_class_name :  & str , 
273277        provider :  & oidc:: AuthenticationProvider , 
274-         auth_details :  & SupersetClientAuthenticationDetails , 
278+         auth_details :  & v1alpha1 :: SupersetClientAuthenticationDetails , 
275279    )  -> Result < SupersetAuthenticationClassResolved >  { 
276280        let  oidc_provider = match  & provider. provider_hint  { 
277281            None  => { 
@@ -346,7 +350,7 @@ mod tests {
346350                authentication_classes_resolved:  Vec :: default ( ) , 
347351                user_registration:  default_user_registration( ) , 
348352                user_registration_role:  default_user_registration_role( ) , 
349-                 sync_roles_at:  FlaskRolesSyncMoment :: default ( ) 
353+                 sync_roles_at:  v1alpha1 :: FlaskRolesSyncMoment :: default ( ) 
350354            } , 
351355            auth_details_resolved
352356        ) ; 
@@ -383,7 +387,7 @@ mod tests {
383387                } ] , 
384388                user_registration:  false , 
385389                user_registration_role:  "Gamma" . into( ) , 
386-                 sync_roles_at:  FlaskRolesSyncMoment :: Login 
390+                 sync_roles_at:  v1alpha1 :: FlaskRolesSyncMoment :: Login 
387391            } , 
388392            auth_details_resolved
389393        ) ; 
@@ -495,7 +499,7 @@ mod tests {
495499                ] , 
496500                user_registration:  false , 
497501                user_registration_role:  "Gamma" . into( ) , 
498-                 sync_roles_at:  FlaskRolesSyncMoment :: Login 
502+                 sync_roles_at:  v1alpha1 :: FlaskRolesSyncMoment :: Login 
499503            } , 
500504            auth_details_resolved
501505        ) ; 
@@ -901,7 +905,7 @@ mod tests {
901905     /// Fail if the given string cannot be deserialized. 
902906     fn  deserialize_superset_client_authentication_details ( 
903907        input :  & str , 
904-     )  -> Vec < SupersetClientAuthenticationDetails >  { 
908+     )  -> Vec < v1alpha1 :: SupersetClientAuthenticationDetails >  { 
905909        serde_yaml:: from_str ( input) 
906910            . expect ( "The definition of the authentication configuration should be valid." ) 
907911    } 
0 commit comments