1
1
const buildControllerLayer = require ( './controller-layer' )
2
2
const pgp = require ( 'pg-promise' ) ( )
3
3
const 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' )
5
6
const ModelLayer = require ( './model-layer' )
6
7
const PusherPubSubGateway = require ( './pusher-pub-sub-gateway' )
7
8
const SocketClusterPubSubGateway = require ( './socketcluster-pub-sub-gateway' )
@@ -22,59 +23,81 @@ class Server {
22
23
this . githubClientId = options . githubClientId
23
24
this . githubClientSecret = options . githubClientSecret
24
25
this . githubOauthToken = options . githubOauthToken
26
+ this . keycloakApiUrl = options . keycloakApiUrl
27
+ this . keycloakClientId = options . keycloakClientId
28
+ this . keycloakClientSecret = options . keycloakClientSecret
29
+ this . keycloakRealm = options . keycloakRealm
25
30
this . boomtownSecret = options . boomtownSecret
26
31
this . hashSecret = options . hashSecret
27
32
this . port = options . port ,
28
33
this . coturnUsername = options . coturnUsername ,
29
34
this . coturnPassword = options . coturnPassword ,
30
35
this . activePubSubGateway = options . activePubSubGateway ,
31
36
this . activeIceServerProvider = options . activeIceServerProvider
37
+ this . activeIdentityProvider = options . activeIdentityProvider
32
38
}
33
39
34
40
async start ( ) {
35
41
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
+ }
43
66
44
67
var pubSubGateway
45
68
46
69
switch ( this . activePubSubGateway ) {
47
- case 'socketcluster' :
48
- pubSubGateway = new SocketClusterPubSubGateway ( { } )
49
- break ;
70
+ case 'socketcluster' :
71
+ pubSubGateway = new SocketClusterPubSubGateway ( { } )
72
+ break ;
50
73
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 ;
60
83
}
61
84
62
85
var iceServerProvider
63
86
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 ;
70
93
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 ;
78
101
}
79
102
80
103
const controllerLayer = buildControllerLayer ( {
0 commit comments