2
2
// License, v. 2.0. If a copy of the MPL was not distributed with this
3
3
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
4
4
5
+ use crate :: db:: identity:: Resource ;
5
6
use crate :: db:: model:: impl_enum_type;
6
7
use crate :: db:: schema:: { identity_provider, saml_identity_provider} ;
7
8
use db_macros:: Resource ;
8
9
10
+ use nexus_types:: external_api:: views;
9
11
use serde:: { Deserialize , Serialize } ;
10
12
use uuid:: Uuid ;
11
13
@@ -22,6 +24,14 @@ impl_enum_type!(
22
24
Saml => b"saml"
23
25
) ;
24
26
27
+ impl From < IdentityProviderType > for views:: IdentityProviderType {
28
+ fn from ( idp_type : IdentityProviderType ) -> Self {
29
+ match idp_type {
30
+ IdentityProviderType :: Saml => views:: IdentityProviderType :: Saml ,
31
+ }
32
+ }
33
+ }
34
+
25
35
#[ derive( Queryable , Insertable , Clone , Debug , Selectable , Resource ) ]
26
36
#[ diesel( table_name = identity_provider) ]
27
37
pub struct IdentityProvider {
@@ -33,6 +43,15 @@ pub struct IdentityProvider {
33
43
pub provider_type : IdentityProviderType ,
34
44
}
35
45
46
+ impl From < IdentityProvider > for views:: IdentityProvider {
47
+ fn from ( idp : IdentityProvider ) -> Self {
48
+ Self {
49
+ identity : idp. identity ( ) ,
50
+ provider_type : idp. provider_type . into ( ) ,
51
+ }
52
+ }
53
+ }
54
+
36
55
#[ derive( Queryable , Insertable , Clone , Debug , Selectable , Resource ) ]
37
56
#[ diesel( table_name = saml_identity_provider) ]
38
57
pub struct SamlIdentityProvider {
@@ -51,3 +70,17 @@ pub struct SamlIdentityProvider {
51
70
pub public_cert : Option < String > ,
52
71
pub private_key : Option < String > ,
53
72
}
73
+
74
+ impl From < SamlIdentityProvider > for views:: SamlIdentityProvider {
75
+ fn from ( saml_idp : SamlIdentityProvider ) -> Self {
76
+ Self {
77
+ identity : saml_idp. identity ( ) ,
78
+ idp_entity_id : saml_idp. idp_entity_id ,
79
+ sp_client_id : saml_idp. sp_client_id ,
80
+ acs_url : saml_idp. acs_url ,
81
+ slo_url : saml_idp. slo_url ,
82
+ technical_contact_email : saml_idp. technical_contact_email ,
83
+ public_cert : saml_idp. public_cert ,
84
+ }
85
+ }
86
+ }
0 commit comments