@@ -695,3 +695,79 @@ impl UserRegistrationToken {
695695 ]
696696 }
697697}
698+
699+ /// An upstream OAuth 2.0 provider
700+ #[ derive( Serialize , JsonSchema ) ]
701+ pub struct UpstreamOAuthProvider {
702+ #[ serde( skip) ]
703+ id : Ulid ,
704+
705+ /// The OIDC issuer of the provider
706+ issuer : Option < String > ,
707+
708+ /// A human-readable name for the provider
709+ human_name : Option < String > ,
710+
711+ /// A brand identifier, e.g. "apple" or "google"
712+ brand_name : Option < String > ,
713+
714+ /// When the provider was created
715+ created_at : DateTime < Utc > ,
716+
717+ /// When the provider was disabled. If null, the provider is enabled.
718+ disabled_at : Option < DateTime < Utc > > ,
719+ }
720+
721+ impl From < mas_data_model:: UpstreamOAuthProvider > for UpstreamOAuthProvider {
722+ fn from ( provider : mas_data_model:: UpstreamOAuthProvider ) -> Self {
723+ Self {
724+ id : provider. id ,
725+ issuer : provider. issuer ,
726+ human_name : provider. human_name ,
727+ brand_name : provider. brand_name ,
728+ created_at : provider. created_at ,
729+ disabled_at : provider. disabled_at ,
730+ }
731+ }
732+ }
733+
734+ impl Resource for UpstreamOAuthProvider {
735+ const KIND : & ' static str = "upstream-oauth-provider" ;
736+ const PATH : & ' static str = "/api/admin/v1/upstream-oauth-providers" ;
737+
738+ fn id ( & self ) -> Ulid {
739+ self . id
740+ }
741+ }
742+
743+ impl UpstreamOAuthProvider {
744+ /// Samples of upstream OAuth 2.0 providers
745+ pub fn samples ( ) -> [ Self ; 3 ] {
746+ [
747+ Self {
748+ id : Ulid :: from_bytes ( [ 0x01 ; 16 ] ) ,
749+ issuer : Some ( "https://accounts.google.com" . to_owned ( ) ) ,
750+ human_name : Some ( "Google" . to_owned ( ) ) ,
751+ brand_name : Some ( "google" . to_owned ( ) ) ,
752+ created_at : DateTime :: default ( ) ,
753+ disabled_at : None ,
754+ } ,
755+ Self {
756+ id : Ulid :: from_bytes ( [ 0x02 ; 16 ] ) ,
757+ issuer : Some ( "https://appleid.apple.com" . to_owned ( ) ) ,
758+ human_name : Some ( "Apple ID" . to_owned ( ) ) ,
759+ brand_name : Some ( "apple" . to_owned ( ) ) ,
760+ created_at : DateTime :: default ( ) ,
761+ disabled_at : Some ( DateTime :: default ( ) ) ,
762+ } ,
763+ Self {
764+ id : Ulid :: from_bytes ( [ 0x03 ; 16 ] ) ,
765+ issuer : None ,
766+ human_name : Some ( "Custom OAuth Provider" . to_owned ( ) ) ,
767+ brand_name : None ,
768+ created_at : DateTime :: default ( ) ,
769+ disabled_at : None ,
770+ } ,
771+ ]
772+ }
773+ }
0 commit comments