44 $ Database = Gdn::database ();
55 $ SQL = $ Database ->sql ();
66
7- // DB settings
8- saveToConfig ('Database.Host ' , getenv ('DB_HOSTNAME ' ), false );
9- saveToConfig ('Database.Name ' , getenv ('DB_DATABASE ' ), false );
10- saveToConfig ('Database.User ' , getenv ('DB_USERNAME ' ), false );
11- saveToConfig ('Database.Password ' , getenv ('DB_PASSWORD ' ), false );
12-
13- saveToConfig ('Garden.Email.SupportName ' , getenv ('MAIL_FROM_NAME ' ), false );
14- saveToConfig ('Garden.Email.SupportAddress ' , getenv ('MAIL_FROM_ADDRESS ' ), false );
15- saveToConfig ('Garden.Email.UseSmtp ' , getenv ('MAIL_USE_SMTP ' ), false );
16- saveToConfig ('Garden.Email.SmtpHost ' , getenv ('MAIL_SMTP_HOSTNAME ' ), false );
17- saveToConfig ('Garden.Email.SmtpUser ' , getenv ('MAIL_SMTP_USERNAME ' ), false );
18- saveToConfig ('Garden.Email.SmtpPassword ' , getenv ('MAIL_SMTP_PASSWORD ' ), false );
19- saveToConfig ('Garden.Email.SmtpPort ' , getenv ('MAIL_SMTP_PORT ' ), false );
20- saveToConfig ('Garden.Email.SmtpSecurity ' , getenv ('MAIL_SMTP_SECURITY ' ), false );
21-
22- //Disable plugins
23- saveToConfig ('EnabledPlugins.stubcontent ' , false );
24-
25- //Enable plugins
26- saveToConfig ('EnabledPlugins.Topcoder ' , true );
27- saveToConfig ('EnabledPlugins.rich-editor ' ,true );
28- saveToConfig ('EnabledPlugins.recaptcha ' , true );
29- saveToConfig ('EnabledPlugins.editor ' , true );
30- saveToConfig ('EnabledPlugins.emojiextender ' , true );
31- saveToConfig ('EnabledPlugins.GooglePrettify ' , true );
32- saveToConfig ('EnabledPlugins.Quotes ' , true );
33- saveToConfig ('EnabledPlugins.swagger-ui ' , true );
34- saveToConfig ('EnabledPlugins.oauth2 ' , true );
35-
36- // Set Theme Options
37- saveToConfig ('Garden.ThemeOptions.Styles.Key ' , 'Coral ' );
38- saveToConfig ('Garden.ThemeOptions.Styles.Value ' , '%s_coral ' );
39- saveToConfig ('Garden.ThemeOptions.Options.panelToLeft ' ,true );
7+ // Cache Settings
8+ saveToConfig ('Cache.Enabled ' , getenv ('CACHE_ENABLED ' ), true );
9+ saveToConfig ('Cache.Method ' , getenv ('CACHE_METHOD ' ), 'dirtycache ' );
10+ saveToConfig ('memcached.Store ' , getenv ('MEMCACHED_SERVER ' ), 'localhost:11211 ' );
11+
12+ saveToConfig ('Garden.Email.SupportName ' , getenv ('MAIL_FROM_NAME ' ) );
13+ saveToConfig ('Garden.Email.SupportAddress ' , getenv ('MAIL_FROM_ADDRESS ' ));
14+ saveToConfig ('Garden.Email.UseSmtp ' , getenv ('MAIL_USE_SMTP ' ));
15+ saveToConfig ('Garden.Email.SmtpHost ' , getenv ('MAIL_SMTP_HOSTNAME ' ));
16+ saveToConfig ('Garden.Email.SmtpUser ' , getenv ('MAIL_SMTP_USERNAME ' ));
17+ saveToConfig ('Garden.Email.SmtpPassword ' , getenv ('MAIL_SMTP_PASSWORD ' ));
18+ saveToConfig ('Garden.Email.SmtpPort ' , getenv ('MAIL_SMTP_PORT ' ));
19+ saveToConfig ('Garden.Email.SmtpSecurity ' , getenv ('MAIL_SMTP_SECURITY ' ));
20+
21+ // Appearance
22+ saveToConfig ('Garden.Theme ' , 'topcoder-theme ' , false );
23+ saveToConfig ('Garden.MobileTheme ' , 'topcoder-theme ' , false );
24+ saveToConfig ('Feature.NewFlyouts.Enabled ' , true );
4025
4126 // Profile settings
4227 saveToConfig ('Garden.Profile.EditPhotos ' , false );
4328
4429 // Add settings for the Topcoder plugin
45- if (c ('Plugins.Topcoder.BaseApiURL ' ) === false ) {
46- saveToConfig ('Plugins.Topcoder.BaseApiURL ' , getenv ('TOPCODER_PLUGIN_BASE_API_URL ' ), false );
47- saveToConfig ('Plugins.Topcoder.MemberApiURI ' , getenv ('TOPCODER_PLUGIN_MEMBER_API_URI ' ), false );
48- saveToConfig ('Plugins.Topcoder.RoleApiURI ' , getenv ('TOPCODER_PLUGIN_ROLE_API_URI ' ), false );
49- saveToConfig ('Plugins.Topcoder.MemberProfileURL ' , getenv ('TOPCODER_PLUGIN_MEMBER_PROFILE_URL ' ), false );
30+ saveToConfig ('Plugins.Topcoder.BaseApiURL ' , getenv ('TOPCODER_PLUGIN_BASE_API_URL ' ),false );
31+ saveToConfig ('Plugins.Topcoder.MemberApiURI ' , getenv ('TOPCODER_PLUGIN_MEMBER_API_URI ' ),false );
32+ saveToConfig ('Plugins.Topcoder.RoleApiURI ' , getenv ('TOPCODER_PLUGIN_ROLE_API_URI ' ),false );
33+ saveToConfig ('Plugins.Topcoder.ResourceRolesApiURI ' , '/v5/resource-roles ' , false );
34+ saveToConfig ('Plugins.Topcoder.ResourcesApiURI ' , '/v5/resources ' , false );
35+ saveToConfig ('Plugins.Topcoder.MemberProfileURL ' , 'https://www.topcoder-dev.com/members ' ,false ); // prod: getenv('TOPCODER_PLUGIN_MEMBER_PROFILE_URL')
36+ saveToConfig ('Plugins.Topcoder.UseTopcoderAuthToken ' , getenv ('TOPCODER_PLUGIN_USE_AUTH_TOKEN ' ),false );
37+
38+ saveToConfig ('Plugins.Topcoder.ValidIssuers ' , str_replace (["[ " , "] " , "\\" , "\"" , " " ], '' , getenv ('VALID_ISSUERS ' )));
39+
40+ //Add settings for Topcoder M2M Auth0
41+ saveToConfig ('Plugins.Topcoder.M2M.Auth0Audience ' ,'https://m2m.topcoder-dev.com/ ' ); // getenv('AUTH0_AUDIENCE')
42+ saveToConfig ('Plugins.Topcoder.M2M.Auth0ClientId ' , getenv ('AUTH0_CLIENT_ID ' ));
43+ saveToConfig ('Plugins.Topcoder.M2M.Auth0ClientSecret ' , getenv ('AUTH0_CLIENT_SECRET ' ));
44+ saveToConfig ('Plugins.Topcoder.M2M.Auth0Url ' , getenv ('AUTH0_URL ' ));
45+ saveToConfig ('Plugins.Topcoder.M2M.Auth0ProxyServerUrl ' , getenv ('AUTH0_PROXY_SERVER_URL ' ));
46+
47+ //Add settings for Topcoder SSO Auth0
48+ saveToConfig ('Plugins.Topcoder.SSO.Auth0Domain ' , 'https://api.topcoder-dev.com ' );
49+ saveToConfig ('Plugins.Topcoder.SSO.AuthorizationURI ' , '/v3/authorizations/1 ' );
50+ saveToConfig ('Plugins.Topcoder.SSO.CookieName ' , 'v3jwt ' ,false );
51+ saveToConfig ('Plugins.Topcoder.SSO.TopcoderRS256.ID ' , 'BXWXUWnilVUPdN01t2Se29Tw2ZYNGZvH ' );
52+ saveToConfig ('Plugins.Topcoder.SSO.TopcoderHS256.ID ' , 'JFDo7HMkf0q2CkVFHojy3zHWafziprhT ' );
53+ saveToConfig ('Plugins.Topcoder.SSO.TopcoderHS256.Secret ' , getenv ('TOPCODER_HS256_SECRET ' ) );
54+ saveToConfig ('Plugins.Topcoder.SSO.TopcoderRS256.UsernameClaim ' , 'nickname ' ,false );
55+ saveToConfig ('Plugins.Topcoder.SSO.TopcoderHS256.UsernameClaim ' , 'handle ' ,false );
56+ $ topcoderSSOAuth0Url = 'https://accounts-auth0.topcoder-dev.com/ ' ;
57+ saveToConfig ('Plugins.Topcoder.SSO.RefreshTokenURL ' , $ topcoderSSOAuth0Url ,false );
58+ $ signInUrl = getenv ('TOPCODER_PLUGIN_SIGNIN_URL ' );
59+ $ signOutUrl = getenv ('TOPCODER_PLUGIN_SIGNOUT_URL ' );
60+ if ($ signInUrl === false ) {
61+ $ signInUrl =$ topcoderSSOAuth0Url .'?retUrl= ' .urlencode ('https:// ' .$ _SERVER ['SERVER_NAME ' ].'/ ' );
5062 }
63+ if ($ signOutUrl === false ) {
64+ $ signOutUrl =$ topcoderSSOAuth0Url .'?logout=true&retUrl= ' .urlencode ('https:// ' .$ _SERVER ['SERVER_NAME ' ].'/ ' );
65+ }
66+ saveToConfig ('Plugins.Topcoder.AuthenticationProvider.SignInUrl ' , $ signInUrl ,false );
67+ saveToConfig ('Plugins.Topcoder.AuthenticationProvider.SignOutUrl ' , $ signOutUrl ,false );
68+ saveToConfig ('Plugins.Topcoder.AuthenticationProvider.RegisterUrl ' , 'https://www.topcoder-dev.com/user-selection/ ' ,false );
69+
70+ // Filestack
71+ saveToConfig ('Plugins.Filestack.ApiKey ' , getenv ('FILESTACK_API_KEY ' ),false );
72+
73+ // SumoLogic
74+ saveToConfig ('Plugins.Sumologic.HttpSourceURL ' , '' ,false );
75+ saveToConfig ('Plugins.Sumologic.BatchSize ' , '10 ' ,false );
5176
5277 // Add settings for the Editor plugin
5378 if (c ('Plugins.editor.ForceWysiwyg ' ) === false ) {
6893 saveToConfig ('Recaptcha.PublicKey ' , getenv ('RECAPTCHA_PLUGIN_PUBLIC_KEY ' ), false );
6994 }
7095
71- // Add settings for the OAuth 2 SSO plugin
72- if ($ SQL ->getWhere ('UserAuthenticationProvider ' , ['AuthenticationKey ' => 'oauth2 ' ])->numRows () == 0 ) {
73- $ attributes = array (
74- 'AssociationKey ' => getenv ('TOPCODER_AUTH0_ASSOCIATION_KEY ' ),
75- 'AuthorizeUrl ' => getenv ('TOPCODER_AUTH0_AUTHORIZE_URL ' ),
76- 'TokenUrl ' => getenv ('TOPCODER_AUTH0_TOKEN_URL ' ),
77- 'AcceptedScope ' => getenv ('TOPCODER_AUTH0_ACCEPTED_SCOPE ' ),
78- 'ProfileKeyEmail ' => getenv ('TOPCODER_AUTH0_PROFILE_KEY_EMAIL ' ),
79- 'ProfileKeyPhoto ' => getenv ('TOPCODER_AUTH0_PROFILE_KEY_PHOTO ' ),
80- 'ProfileKeyName ' => getenv ('TOPCODER_AUTH0_PROFILE_KEY_NAME ' ),
81- 'ProfileKeyFullName ' => getenv ('TOPCODER_AUTH0_PROFILE_KEY_FULL_NAME ' ),
82- 'ProfileKeyUniqueID ' => getenv ('TOPCODER_AUTH0_PROFILE_KEY_UNIQUE_ID ' ),
83- 'Prompt ' => getenv ('TOPCODER_AUTH0_PROMPT ' ),
84- 'BearerToken ' => getenv ('TOPCODER_AUTH0_BEARER_TOKEN ' ),
85- 'BaseUrl ' => getenv ('TOPCODER_AUTH0_BASE_URL ' )
86- );
96+
97+ // Fix: OAuth 2 SSO should be inactive and not by default. It should be removed later.
98+ if ($ SQL ->getWhere ('UserAuthenticationProvider ' , ['AuthenticationKey ' => 'oauth2 ' ])->numRows () > 0 ) {
99+ $ SQL ->update ('UserAuthenticationProvider ' )
100+ ->set ('Active ' , 0 )
101+ ->set ('IsDefault ' ,0 )
102+ ->where ('AuthenticationKey ' , 'oauth2 ' )->put ();
103+ }
104+
105+ // Add Topcoder User Authentication Provider.
106+ // SignInUrl/SignOutUrl should be set in Topcoder plugin's setup; otherwise they couldn't be updated in DB
107+ if ($ SQL ->getWhere ('UserAuthenticationProvider ' , ['AuthenticationKey ' => 'topcoder ' ])->numRows () == 0 ) {
87108 $ SQL ->insert ('UserAuthenticationProvider ' , [
88- 'AuthenticationKey ' => 'oauth2 ' ,
89- 'AuthenticationSchemeAlias ' => 'oauth2 ' ,
90- 'Name ' => 'oauth2 ' ,
91- 'AssociationSecret ' => getenv ('TOPCODER_AUTH0_SECRET ' ),
92- 'RegisterUrl ' => getenv ('TOPCODER_AUTH0_REGISTER_URL ' ),
93- 'SignInUrl ' => getenv ('TOPCODER_AUTH0_SIGNIN_URL ' ),
94- 'SignOutUrl ' => getenv ('TOPCODER_AUTH0_SIGNOUT_URL ' ),
95- 'ProfileUrl ' => getenv ('TOPCODER_AUTH0_PROFILE_URL ' ),
96- 'Attributes ' => json_encode ($ attributes ,JSON_UNESCAPED_SLASHES ),
109+ 'AuthenticationKey ' => 'topcoder ' ,
110+ 'AuthenticationSchemeAlias ' => 'topcoder ' ,
111+ 'Name ' => 'topcoder ' ,
97112 'Active ' => 1 ,
98113 'IsDefault ' => 1
99114 ]);
100115 }
101116
102- // Define Topcoder Member role
103- $ topcoderRoleName = 'Topcoder Member ' ;
104- if ($ SQL ->getWhere ('Role ' , ['Name ' => $ topcoderRoleName ])->numRows () == 0 ) {
105- $ roleID = $ SQL ->insert ('Role ' , [
106- 'Name ' => $ topcoderRoleName ,
107- 'Type ' => 'member ' ,
108- 'Deletable ' => 0 ,
109- 'CanSession ' => 1 ,
110- 'PersonalInfo ' => 1 ,
111- 'Description ' => 'Topcoder Members can edit Notification Preferences and participate in discussions. '
112- ]);
113-
114- // Define the set of permissions to singIn, view Profiles and edit Notification Preferences
115- $ SQL ->insert ('Permission ' , [
116- 'RoleID ' => $ roleID ,
117- '`Garden.SignIn.Allow` ' => 1 ,
118- '`Garden.Profiles.View` ' => 1 ,
119- '`Garden.PersonalInfo.View` ' => 1 ,
120- '`Garden.AdvancedNotifications.Allow` ' => 1
121- ]);
122-
123- // Define the set of permissions to view categories
124- $ SQL ->insert ('Permission ' , [
125- 'RoleID ' => $ roleID ,
126- 'JunctionTable ' => 'Category ' ,
127- 'JunctionColumn ' => 'PermissionCategoryID ' ,
128- 'JunctionID ' => -1 ,
129- '`Vanilla.Discussions.View` ' => 1
130- ]);
131- }
117+ // Fix: Add the 'topcoder' role type in Role Table. It should be removed after upgrading existing DB.
118+ // The Topcoder plugin's setup method will upgrade DB during Vanilla installation
119+ $ SQL ->query ('alter table GDN_Role modify Type enum( \'topcoder \', \'guest \', \'unconfirmed \', \'applicant \', \'member \', \'moderator \', \'administrator \') ' );
132120
133121}
0 commit comments