11<?php namespace App \libs \Auth ;
22use Illuminate \Support \Facades \Config ;
3+ use Illuminate \Support \Facades \Request ;
34
45/**
56 * Copyright 2021 OpenStack Foundation
@@ -25,16 +26,15 @@ final class SocialLoginProviders
2526 const LinkedIn = "linkedin " ;
2627 const Google = "google " ;
2728 const OKTA = 'okta ' ;
28-
29- const AUTH0 = 'auth0 ' ;
29+ const LFID = 'lfid ' ;
3030
3131 const ValidProviders = [
3232 self ::Facebook,
3333 self ::LinkedIn,
3434 self ::Apple,
3535 //self::Google
3636 self ::OKTA ,
37- self ::AUTH0 ,
37+ self ::LFID ,
3838 ];
3939
4040 /**
@@ -59,9 +59,24 @@ public static function isEnabledProvider(string $provider):bool{
5959 */
6060 public static function buildSupportedProviders ():array {
6161 $ res = [];
62+ $ tenant = null ;
63+ $ allowed_3rd_party_providers = [];
64+ if (Request::has ("tenant " )){
65+ $ tenant = trim (Request::get ("tenant " ));
66+ $ allowed_3rd_party_providers = explode (', ' ,Config::get ("tenants. " .$ tenant .".allowed_3rd_party_providers " ,"" ));
67+ }
68+
6269 foreach (self ::ValidProviders as $ provider ){
63- if (self ::isEnabledProvider ($ provider ))
70+ // check if the 3rd party provider has defined some exclusive tenants ...
71+ $ tenants = explode (', ' , Config::get ("services. " .$ provider .".tenants " ,"" ));
72+ // check first its enabled ...
73+ if (self ::isEnabledProvider ($ provider )) {
74+ if (count ($ tenants ) > 0 ){ // check if we have tenants defined at provider level
75+ if (empty ($ tenant ) || !in_array ($ tenant , $ tenants )) continue ;
76+ } // else check if the tenant has that provider enabled
77+ else if (!empty ($ tenant ) && !in_array ($ tenant , $ allowed_3rd_party_providers )) continue ;
6478 $ res [$ provider ] = ucfirst ($ provider );
79+ }
6580 }
6681 return $ res ;
6782 }
0 commit comments