11const buildControllerLayer = require ( './controller-layer' )
22const pgp = require ( 'pg-promise' ) ( )
33const request = require ( 'request-promise-native' )
4- const IdentityProvider = require ( './identity-provider' )
4+ const GithubIdentityProvider = require ( './github-identity-provider' )
5+ const KeycloakIdentityProvider = require ( './keycloak-identity-provider' )
56const ModelLayer = require ( './model-layer' )
67const PusherPubSubGateway = require ( './pusher-pub-sub-gateway' )
78const SocketClusterPubSubGateway = require ( './socketcluster-pub-sub-gateway' )
@@ -22,59 +23,81 @@ class Server {
2223 this . githubClientId = options . githubClientId
2324 this . githubClientSecret = options . githubClientSecret
2425 this . githubOauthToken = options . githubOauthToken
26+ this . keycloakApiUrl = options . keycloakApiUrl
27+ this . keycloakClientId = options . keycloakClientId
28+ this . keycloakClientSecret = options . keycloakClientSecret
29+ this . keycloakRealm = options . keycloakRealm
2530 this . boomtownSecret = options . boomtownSecret
2631 this . hashSecret = options . hashSecret
2732 this . port = options . port ,
2833 this . coturnUsername = options . coturnUsername ,
2934 this . coturnPassword = options . coturnPassword ,
3035 this . activePubSubGateway = options . activePubSubGateway ,
3136 this . activeIceServerProvider = options . activeIceServerProvider
37+ this . activeIdentityProvider = options . activeIdentityProvider
3238 }
3339
3440 async start ( ) {
3541 const modelLayer = new ModelLayer ( { db : pgp ( this . databaseURL ) , hashSecret : this . hashSecret } )
36- const identityProvider = new IdentityProvider ( {
37- request,
38- apiUrl : this . githubApiUrl ,
39- clientId : this . githubClientId ,
40- clientSecret : this . githubClientSecret ,
41- oauthToken : this . githubOauthToken
42- } )
42+
43+ var identityProvider
44+
45+ switch ( this . activeIdentityProvider ) {
46+ case 'keycloak' :
47+ identityProvider = new KeycloakIdentityProvider ( {
48+ request,
49+ apiUrl : this . keycloakApiUrl ,
50+ clientId : this . keycloakClientId ,
51+ clientSecret : this . keycloakClientSecret ,
52+ realm : this . keycloakRealm
53+ } )
54+ break ;
55+ case 'github' :
56+ default :
57+ identityProvider = new GithubIdentityProvider ( {
58+ request,
59+ apiUrl : this . githubApiUrl ,
60+ clientId : this . githubClientId ,
61+ clientSecret : this . githubClientSecret ,
62+ oauthToken : this . githubOauthToken
63+ } )
64+ break ;
65+ }
4366
4467 var pubSubGateway
4568
4669 switch ( this . activePubSubGateway ) {
47- case 'socketcluster' :
48- pubSubGateway = new SocketClusterPubSubGateway ( { } )
49- break ;
70+ case 'socketcluster' :
71+ pubSubGateway = new SocketClusterPubSubGateway ( { } )
72+ break ;
5073
51- case 'pusher' :
52- default :
53- pubSubGateway = new PusherPubSubGateway ( {
54- appId : this . pusherAppId ,
55- key : this . pusherKey ,
56- secret : this . pusherSecret ,
57- cluster : this . pusherCluster
58- } )
59- break ;
74+ case 'pusher' :
75+ default :
76+ pubSubGateway = new PusherPubSubGateway ( {
77+ appId : this . pusherAppId ,
78+ key : this . pusherKey ,
79+ secret : this . pusherSecret ,
80+ cluster : this . pusherCluster
81+ } )
82+ break ;
6083 }
6184
6285 var iceServerProvider
6386 switch ( this . activeIceServerProvider ) {
64- case 'coturn' :
65- iceServerProvider = new CoturnIceServerProvider ( {
66- coturnUsername : this . coturnUsername ,
67- coturnPassword : this . coturnPassword
68- } )
69- break ;
87+ case 'coturn' :
88+ iceServerProvider = new CoturnIceServerProvider ( {
89+ coturnUsername : this . coturnUsername ,
90+ coturnPassword : this . coturnPassword
91+ } )
92+ break ;
7093
71- case 'twilio' :
72- default :
73- iceServerProvider = new TwilioIceServerProvider ( {
74- twilioAccount : this . twilioAccount ,
75- twilioAuthToken : this . twilioAuthToken
76- } )
77- break ;
94+ case 'twilio' :
95+ default :
96+ iceServerProvider = new TwilioIceServerProvider ( {
97+ twilioAccount : this . twilioAccount ,
98+ twilioAuthToken : this . twilioAuthToken
99+ } )
100+ break ;
78101 }
79102
80103 const controllerLayer = buildControllerLayer ( {
0 commit comments