-
Notifications
You must be signed in to change notification settings - Fork 236
/
ScooldConfig.java
3551 lines (3180 loc) · 128 KB
/
ScooldConfig.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* Copyright 2013-2022 Erudika. https://erudika.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* For issues and patches go to: https://github.com/erudika
*/
package com.erudika.scoold;
import com.erudika.para.core.App;
import com.erudika.para.core.annotations.Documented;
import com.erudika.para.core.utils.Config;
import com.erudika.para.core.utils.Para;
import static com.erudika.scoold.ScooldServer.SIGNINLINK;
import static com.erudika.scoold.ScooldServer.SIGNOUTLINK;
import com.typesafe.config.ConfigObject;
import jakarta.inject.Named;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.math.NumberUtils;
import org.springframework.stereotype.Component;
/**
* Scoold configuration.
* @author Alex Bogdanovski [alex@erudika.com]
*/
@Component
@Named
public class ScooldConfig extends Config {
@Override
public com.typesafe.config.Config getFallbackConfig() {
if (StringUtils.isBlank(System.getProperty("scoold.autoinit.para_config_file")) &&
StringUtils.isBlank(System.getenv("scoold.autoinit.para_config_file"))) {
return Para.getConfig().getConfig(); // fall back to para.* config
}
return com.typesafe.config.ConfigFactory.empty();
}
@Override
public Set<String> getKeysExcludedFromRendering() {
return Set.of("scoold", "security.ignored", "security.protected.admin");
}
@Override
public String getConfigRootPrefix() {
return "scoold";
}
/* **************************************************************************************************************
* Core Core *
****************************************************************************************************************/
@Documented(position = 10,
identifier = "app_name",
value = "Scoold",
category = "Core",
description = "The formal name of the web application.")
public String appName() {
return getConfigParam("app_name", "Scoold");
}
@Documented(position = 20,
identifier = "para_access_key",
value = "app:scoold",
category = "Core",
tags = {"requires restart"},
description = "App identifier (access key) of the Para app used by Scoold.")
public String paraAccessKey() {
return App.id(getConfigParam("para_access_key", getConfigParam("access_key", "app:scoold")));
}
@Documented(position = 30,
identifier = "para_secret_key",
value = "x",
category = "Core",
tags = {"requires restart"},
description = "Secret key of the Para app used by Scoold.")
public String paraSecretKey() {
return getConfigParam("para_secret_key", getConfigParam("secret_key", "x"));
}
@Documented(position = 40,
identifier = "para_endpoint",
value = "http://localhost:8080",
category = "Core",
tags = {"requires restart"},
description = "The URL of the Para server for Scoold to connects to. For hosted Para, use `https://paraio.com`")
public String paraEndpoint() {
return getConfigParam("para_endpoint", getConfigParam("endpoint", "http://localhost:8080"));
}
@Documented(position = 50,
identifier = "host_url",
value = "http://localhost:8000",
category = "Core",
description = "The internet-facing (public) URL of this Scoold server.")
public String serverUrl() {
return StringUtils.removeEnd(getConfigParam("host_url", "http://localhost:" + serverPort()), "/");
}
@Documented(position = 60,
identifier = "port",
value = "8000",
type = Integer.class,
category = "Core",
tags = {"requires restart"},
description = "The network port of this Scoold server. Port number should be a number above `1024`.")
public int serverPort() {
return NumberUtils.toInt(System.getProperty("server.port"), getConfigInt("port", 8000));
}
@Documented(position = 70,
identifier = "env",
value = "development",
category = "Core",
tags = {"requires restart"},
description = "The environment profile to be used - possible values are `production` or `development`")
public String environment() {
return getConfigParam("env", "development");
}
@Documented(position = 80,
identifier = "app_secret_key",
category = "Core",
description = "A random secret string, min. 32 chars long. *Must be different from the secret key of "
+ "the Para app*. Used for generating JWTs and passwordless authentication tokens.")
public String appSecretKey() {
return getConfigParam("app_secret_key", "");
}
@Documented(position = 90,
identifier = "admins",
category = "Core",
description = "A comma-separated list of emails of people who will be promoted to administrators with "
+ "full rights over the content on the site. This can also contain Para user identifiers.")
public String admins() {
return getConfigParam("admins", "");
}
@Documented(position = 100,
identifier = "is_default_space_public",
value = "true",
type = Boolean.class,
category = "Core",
description = "When enabled, all content in the default space will be publicly visible, "
+ "without authentication, incl. users and tags. Disable to make the site private.")
public boolean isDefaultSpacePublic() {
return getConfigBoolean("is_default_space_public", true);
}
@Documented(position = 110,
identifier = "context_path",
category = "Core",
tags = {"requires restart"},
description = "The context path (subpath) of the web application, defaults to the root path `/`.")
public String serverContextPath() {
String context = getConfigParam("context_path", "");
return StringUtils.stripEnd((StringUtils.isBlank(context) ?
System.getProperty("server.servlet.context-path", "") : context), "/");
}
@Documented(position = 120,
identifier = "webhooks_enabled",
value = "true",
type = Boolean.class,
category = "Core",
description = "Enable/disable webhooks support for events like `question.create`, `user.signup`, etc.")
public boolean webhooksEnabled() {
return getConfigBoolean("webhooks_enabled", true);
}
@Documented(position = 130,
identifier = "api_enabled",
value = "false",
type = Boolean.class,
category = "Core",
description = "Enable/disable the Scoold RESTful API. Disabled by default.")
public boolean apiEnabled() {
return getConfigBoolean("api_enabled", false);
}
@Documented(position = 140,
identifier = "feedback_enabled",
value = "false",
type = Boolean.class,
category = "Core",
description = "Enable/disable the feedback page on the site. It is intended for internal discussion "
+ "about the website itself.")
public boolean feedbackEnabled() {
return getConfigBoolean("feedback_enabled", false);
}
/* **************************************************************************************************************
* Emails Emails *
****************************************************************************************************************/
@Documented(position = 150,
identifier = "support_email",
value = "contact@scoold.com",
category = "Emails",
description = "The email address to use for sending transactional emails, like welcome/password reset emails.")
public String supportEmail() {
return getConfigParam("support_email", "contact@scoold.com");
}
@Documented(position = 160,
identifier = "mail.host",
category = "Emails",
description = "The SMTP server host to use for sending emails.")
public String mailHost() {
return getConfigParam("mail.host", "");
}
@Documented(position = 170,
identifier = "mail.port",
value = "587",
type = Integer.class,
category = "Emails",
description = "The SMTP server port to use for sending emails.")
public int mailPort() {
return getConfigInt("mail.port", 587);
}
@Documented(position = 180,
identifier = "mail.username",
category = "Emails",
description = "The SMTP server username.")
public String mailUsername() {
return getConfigParam("mail.username", "");
}
@Documented(position = 190,
identifier = "mail.password",
category = "Emails",
description = "The SMTP server password.")
public String mailPassword() {
return getConfigParam("mail.password", "");
}
@Documented(position = 200,
identifier = "mail.tls",
value = "true",
type = Boolean.class,
category = "Emails",
description = "Enable/disable TLS for the SMTP connection.")
public boolean mailTLSEnabled() {
return getConfigBoolean("mail.tls", true);
}
@Documented(position = 210,
identifier = "mail.ssl",
value = "false",
type = Boolean.class,
category = "Emails",
description = "Enable/disable SSL for the SMTP connection.")
public boolean mailSSLEnabled() {
return getConfigBoolean("mail.ssl", false);
}
@Documented(position = 220,
identifier = "mail.debug",
value = "false",
type = Boolean.class,
category = "Emails",
description = "Enable/disable debug information when sending emails through SMTP.")
public boolean mailDebugEnabled() {
return getConfigBoolean("mail.debug", false);
}
@Documented(position = 230,
identifier = "favtags_emails_enabled",
value = "false",
type = Boolean.class,
category = "Emails",
description = "Set the default toggle value for all users for receiving emails for new content "
+ "with their favorite tags.")
public boolean favoriteTagsEmailsEnabled() {
return getConfigBoolean("favtags_emails_enabled", false);
}
@Documented(position = 240,
identifier = "reply_emails_enabled",
value = "false",
type = Boolean.class,
category = "Emails",
description = "Set the default toggle value for all users for receiving emails for answers to their questions.")
public boolean replyEmailsEnabled() {
return getConfigBoolean("reply_emails_enabled", false);
}
@Documented(position = 250,
identifier = "comment_emails_enabled",
value = "false",
type = Boolean.class,
category = "Emails",
description = "Set the default toggle value for all users for receiving emails for comments on their posts.")
public boolean commentEmailsEnabled() {
return getConfigBoolean("comment_emails_enabled", false);
}
@Documented(position = 260,
identifier = "summary_email_period_days",
value = "7",
type = Integer.class,
category = "Emails",
tags = {"Pro"},
description = "The time period between each content digest email, in days.")
public int emailsSummaryIntervalDays() {
return getConfigInt("summary_email_period_days", 7);
}
@Documented(position = 270,
identifier = "summary_email_items",
value = "25",
type = Integer.class,
category = "Emails",
description = "The number of posts to include in the digest email (a summary of new posts).")
public int emailsSummaryItems() {
return getConfigInt("summary_email_items", 25);
}
@Documented(position = 280,
identifier = "notification_emails_allowed",
value = "true",
type = Boolean.class,
category = "Emails",
description = "Enable/disable *all* notification emails.")
public boolean notificationEmailsAllowed() {
return getConfigBoolean("notification_emails_allowed", true);
}
@Documented(position = 290,
identifier = "newpost_emails_allowed",
value = "true",
type = Boolean.class,
category = "Emails",
description = "Enable/disable *all* email notifications for every new question that is posted on the site.")
public boolean emailsForNewPostsAllowed() {
return getConfigBoolean("newpost_emails_allowed", true);
}
@Documented(position = 300,
identifier = "favtags_emails_allowed",
value = "true",
type = Boolean.class,
category = "Emails",
description = "Enable/disable *all* email notifications for every new question tagged with a favorite tag.")
public boolean emailsForFavtagsAllowed() {
return getConfigBoolean("favtags_emails_allowed", true);
}
@Documented(position = 310,
identifier = "reply_emails_allowed",
value = "true",
type = Boolean.class,
category = "Emails",
description = "Enable/disable *all* email notifications for every new answer that is posted on the site.")
public boolean emailsForRepliesAllowed() {
return getConfigBoolean("reply_emails_allowed", true);
}
@Documented(position = 320,
identifier = "comment_emails_allowed",
value = "true",
type = Boolean.class,
category = "Emails",
description = "Enable/disable *all* email notifications for every new comment that is posted on the site.")
public boolean emailsForCommentsAllowed() {
return getConfigBoolean("comment_emails_allowed", true);
}
@Documented(position = 330,
identifier = "mentions_emails_allowed",
value = "true",
type = Boolean.class,
category = "Emails",
tags = {"Pro"},
description = "Enable/disable *all* email notifications every time a user is mentioned.")
public boolean emailsForMentionsAllowed() {
return getConfigBoolean("mentions_emails_allowed", true);
}
@Documented(position = 340,
identifier = "summary_email_controlled_by_admins",
value = "false",
type = Boolean.class,
category = "Emails",
tags = {"Pro"},
description = "Controls whether admins can enable/disable summary emails for everyone from the 'Settings' page")
public boolean emailsForSummaryControlledByAdmins() {
return getConfigBoolean("summary_email_controlled_by_admins", false);
}
@Documented(position = 350,
identifier = "mention_emails_controlled_by_admins",
value = "false",
type = Boolean.class,
category = "Emails",
tags = {"Pro"},
description = "Controls whether admins can enable/disable mention emails for everyone from the 'Settings' page")
public boolean emailsForMentionsControlledByAdmins() {
return getConfigBoolean("mention_emails_controlled_by_admins", false);
}
@Documented(position = 360,
identifier = "emails.welcome_text1",
value = "You are now part of {0} - a friendly Q&A community...",
category = "Emails",
description = "Allows for changing the default text (first paragraph) in the welcome email message.")
public String emailsWelcomeText1(Map<String, String> lang) {
return getConfigParam("emails.welcome_text1", lang.get("signin.welcome.body1") + "<br><br>");
}
@Documented(position = 370,
identifier = "emails.welcome_text2",
value = "To get started, simply navigate to the \"Ask question\" page and ask a question...",
category = "Emails",
description = "Allows for changing the default text (second paragraph) in the welcome email message.")
public String emailsWelcomeText2(Map<String, String> lang) {
return getConfigParam("emails.welcome_text2", lang.get("signin.welcome.body2") + "<br><br>");
}
@Documented(position = 380,
identifier = "emails.welcome_text3",
value = "Best, <br>The {0} team",
category = "Emails",
description = "Allows for changing the default text (signature at the end) in the welcome email message.")
public String emailsWelcomeText3(Map<String, String> lang) {
return getConfigParam("emails.welcome_text3", lang.get("notification.signature") + "<br><br>");
}
@Documented(position = 390,
identifier = "emails.default_signature",
value = "Best, <br>The {0} team",
category = "Emails",
description = "The default email signature for all transactional emails sent from Scoold.")
public String emailsDefaultSignatureText(String defaultText) {
return getConfigParam("emails.default_signature", defaultText);
}
/* **************************************************************************************************************
* Security Security *
****************************************************************************************************************/
@Documented(position = 400,
identifier = "approved_domains_for_signups",
category = "Security",
description = "A comma-separated list of domain names, which will be used to restrict the people who "
+ "are allowed to sign up on the site.")
public String approvedDomainsForSignups() {
return getConfigParam("approved_domains_for_signups", "");
}
@Documented(position = 410,
identifier = "security.allow_unverified_emails",
value = "false",
type = Boolean.class,
category = "Security",
description = "Enable/disable email verification after the initial user registration. Users with unverified "
+ "emails won't be able to sign in, unless they use a social login provider.")
public boolean allowUnverifiedEmails() {
return getConfigBoolean("security.allow_unverified_emails", StringUtils.isBlank(mailHost()));
}
@Documented(position = 420,
identifier = "session_timeout",
value = "86400",
type = Integer.class,
category = "Security",
description = "The validity period of the authentication cookie, in seconds. Default is 24h.")
public int sessionTimeoutSec() {
return getConfigInt("session_timeout", Para.getConfig().sessionTimeoutSec());
}
@Documented(position = 430,
identifier = "jwt_expires_after",
value = "86400",
type = Integer.class,
category = "Security",
description = "The validity period of the session token (JWT), in seconds. Default is 24h.")
public int jwtExpiresAfterSec() {
return getConfigInt("jwt_expires_after", Para.getConfig().jwtExpiresAfterSec());
}
@Documented(position = 440,
identifier = "security.one_session_per_user",
value = "true",
type = Boolean.class,
category = "Security",
description = "If disabled, users can sign in from multiple locations and devices, keeping a few open "
+ "sessions at once. Otherwise, only one session will be kept open, others will be closed.")
public boolean oneSessionPerUser() {
return getConfigBoolean("security.one_session_per_user", true);
}
@Documented(position = 450,
identifier = "min_password_length",
value = "8",
type = Integer.class,
category = "Security",
description = "The minimum length of passwords.")
public int minPasswordLength() {
return getConfigInt("min_password_length", Para.getConfig().minPasswordLength());
}
@Documented(position = 460,
identifier = "min_password_strength",
value = "2",
type = Integer.class,
category = "Security",
description = "The minimum password strength - one of 3 levels: `1` good enough, `2` strong, `3` very strong.")
public int minPasswordStrength() {
return getConfigInt("min_password_strength", 2);
}
@Documented(position = 470,
identifier = "pass_reset_timeout",
value = "1800",
type = Integer.class,
category = "Security",
description = "The validity period of the password reset token sent via email for resetting users' "
+ "passwords. Default is 30 min.")
public int passwordResetTimeoutSec() {
return getConfigInt("pass_reset_timeout", Para.getConfig().passwordResetTimeoutSec());
}
@Documented(position = 480,
identifier = "profile_anonimity_enabled",
value = "false",
type = Boolean.class,
category = "Security",
description = "Enable/disable the option for users to anonimize their profiles on the site, "
+ "hiding their name and picture.")
public boolean profileAnonimityEnabled() {
return getConfigBoolean("profile_anonimity_enabled", false);
}
@Documented(position = 490,
identifier = "signup_captcha_site_key",
category = "Security",
description = "The reCAPTCHA v3 site key for protecting the signup and password reset pages.")
public String captchaSiteKey() {
return getConfigParam("signup_captcha_site_key", "");
}
@Documented(position = 500,
identifier = "signup_captcha_secret_key",
category = "Security",
description = "The reCAPTCHA v3 secret.")
public String captchaSecretKey() {
return getConfigParam("signup_captcha_secret_key", "");
}
@Documented(position = 510,
identifier = "csp_reports_enabled",
value = "false",
type = Boolean.class,
category = "Security",
description = "Enable/disable automatic reports each time the Content Security Policy is violated.")
public boolean cspReportsEnabled() {
return getConfigBoolean("csp_reports_enabled", false);
}
@Documented(position = 520,
identifier = "csp_header_enabled",
value = "true",
type = Boolean.class,
category = "Security",
description = "Enable/disable the Content Security Policy (CSP) header.")
public boolean cspHeaderEnabled() {
return getConfigBoolean("csp_header_enabled", true);
}
@Documented(position = 530,
identifier = "csp_header",
category = "Security",
description = "The CSP header value which will overwrite the default one. This can contain one or more "
+ "`{{nonce}}` placeholders, which will be replaced with an actual nonce on each request.")
public String cspHeader(String nonce) {
return getConfigParam("csp_header", getDefaultContentSecurityPolicy()).replaceAll("\\{\\{nonce\\}\\}", nonce);
}
@Documented(position = 540,
identifier = "hsts_header_enabled",
value = "true",
type = Boolean.class,
category = "Security",
description = "Enable/disable the `Strict-Transport-Security` security header.")
public boolean hstsHeaderEnabled() {
return getConfigBoolean("hsts_header_enabled", true);
}
@Documented(position = 550,
identifier = "framing_header_enabled",
value = "true",
type = Boolean.class,
category = "Security",
description = "Enable/disable the `X-Frame-Options` security header.")
public boolean framingHeaderEnabled() {
return getConfigBoolean("framing_header_enabled", true);
}
@Documented(position = 560,
identifier = "xss_header_enabled",
value = "true",
type = Boolean.class,
category = "Security",
description = "Enable/disable the `X-XSS-Protection` security header.")
public boolean xssHeaderEnabled() {
return getConfigBoolean("xss_header_enabled", true);
}
@Documented(position = 570,
identifier = "contenttype_header_enabled",
value = "true",
type = Boolean.class,
category = "Security",
description = "Enable/disable the `X-Content-Type-Options` security header.")
public boolean contentTypeHeaderEnabled() {
return getConfigBoolean("contenttype_header_enabled", true);
}
@Documented(position = 580,
identifier = "referrer_header_enabled",
value = "true",
type = Boolean.class,
category = "Security",
description = "Enable/disable the `Referrer-Policy` security header.")
public boolean referrerHeaderEnabled() {
return getConfigBoolean("referrer_header_enabled", true);
}
@Documented(position = 590,
identifier = "permissions_header_enabled",
value = "true",
type = Boolean.class,
category = "Security",
description = "Enable/disable the `Permissions-Policy` security header.")
public boolean permissionsHeaderEnabled() {
return getConfigBoolean("permissions_header_enabled", true);
}
@Documented(position = 600,
identifier = "csp_connect_sources",
category = "Security",
description = "Additional sources to add to the `connect-src` CSP directive. "
+ "Used when adding external scripts to the site.")
public String cspConnectSources() {
return getConfigParam("csp_connect_sources", "");
}
@Documented(position = 610,
identifier = "csp_frame_sources",
category = "Security",
description = "Additional sources to add to the `frame-src` CSP directive. "
+ "Used when adding external scripts to the site.")
public String cspFrameSources() {
return getConfigParam("csp_frame_sources", "");
}
@Documented(position = 620,
identifier = "csp_font_sources",
category = "Security",
description = "Additional sources to add to the `font-src` CSP directive. "
+ "Used when adding external fonts to the site.")
public String cspFontSources() {
return getConfigParam("csp_font_sources", "");
}
@Documented(position = 630,
identifier = "csp_style_sources",
value = "",
category = "Security",
description = "Additional sources to add to the `style-src` CSP directive. "
+ "Used when adding external fonts to the site.")
public String cspStyleSources() {
return getConfigParam("csp_style_sources", serverUrl() + stylesheetUrl() + " " +
externalStyles().replaceAll(",", ""));
}
/* **************************************************************************************************************
* Basic Authentication Basic Authentication *
****************************************************************************************************************/
@Documented(position = 640,
identifier = "password_auth_enabled",
value = "true",
type = Boolean.class,
category = "Basic Authentication",
description = "Enabled/disable the ability for users to sign in with an email and password.")
public boolean passwordAuthEnabled() {
return getConfigBoolean("password_auth_enabled", true);
}
@Documented(position = 650,
identifier = "fb_app_id",
category = "Basic Authentication",
description = "Facebook OAuth2 app ID.")
public String facebookAppId() {
return getConfigParam("fb_app_id", "");
}
@Documented(position = 660,
identifier = "fb_secret",
category = "Basic Authentication",
description = "Facebook app secret key.")
public String facebookSecret() {
return getConfigParam("fb_secret", "");
}
@Documented(position = 670,
identifier = "gp_app_id",
category = "Basic Authentication",
description = "Google OAuth2 app ID.")
public String googleAppId() {
return getConfigParam("gp_app_id", "");
}
@Documented(position = 680,
identifier = "gp_secret",
category = "Basic Authentication",
description = "Google app secret key.")
public String googleSecret() {
return getConfigParam("gp_secret", "");
}
@Documented(position = 690,
identifier = "in_app_id",
category = "Basic Authentication",
description = "LinkedIn OAuth2 app ID.")
public String linkedinAppId() {
return getConfigParam("in_app_id", "");
}
@Documented(position = 700,
identifier = "in_secret",
category = "Basic Authentication",
description = "LinkedIn app secret key.")
public String linkedinSecret() {
return getConfigParam("in_secret", "");
}
@Documented(position = 710,
identifier = "tw_app_id",
category = "Basic Authentication",
description = "Twitter OAuth app ID.")
public String twitterAppId() {
return getConfigParam("tw_app_id", "");
}
@Documented(position = 720,
identifier = "tw_secret",
category = "Basic Authentication",
description = "Twitter app secret key.")
public String twitterSecret() {
return getConfigParam("tw_secret", "");
}
@Documented(position = 730,
identifier = "gh_app_id",
category = "Basic Authentication",
description = "GitHub OAuth2 app ID.")
public String githubAppId() {
return getConfigParam("gh_app_id", "");
}
@Documented(position = 740,
identifier = "gh_secret",
category = "Basic Authentication",
description = "GitHub app secret key.")
public String githubSecret() {
return getConfigParam("gh_secret", "");
}
@Documented(position = 750,
identifier = "ms_app_id",
category = "Basic Authentication",
description = "Microsoft OAuth2 app ID.")
public String microsoftAppId() {
return getConfigParam("ms_app_id", "");
}
@Documented(position = 760,
identifier = "ms_secret",
category = "Basic Authentication",
description = "Microsoft app secret key.")
public String microsoftSecret() {
return getConfigParam("ms_secret", "");
}
@Documented(position = 770,
identifier = "ms_tenant_id",
value = "common",
category = "Basic Authentication",
description = "Microsoft OAuth2 tenant ID")
public String microsoftTenantId() {
return getConfigParam("ms_tenant_id", "common");
}
@Documented(position = 780,
identifier = "az_app_id",
category = "Basic Authentication",
description = "Amazon OAuth2 app ID.")
public String amazonAppId() {
return getConfigParam("az_app_id", "");
}
@Documented(position = 790,
identifier = "az_secret",
category = "Basic Authentication",
description = "Amazon app secret key.")
public String amazonSecret() {
return getConfigParam("az_secret", "");
}
@Documented(position = 800,
identifier = "sl_app_id",
category = "Basic Authentication",
tags = {"Pro"},
description = "Slack OAuth2 app ID.")
public String slackAppId() {
return getConfigParam("sl_app_id", "");
}
@Documented(position = 810,
identifier = "sl_secret",
category = "Basic Authentication",
tags = {"Pro"},
description = "Slack app secret key.")
public String slackSecret() {
return getConfigParam("sl_secret", "");
}
@Documented(position = 820,
identifier = "mm_app_id",
category = "Basic Authentication",
tags = {"Pro"},
description = "Mattermost OAuth2 app ID.")
public String mattermostAppId() {
return getConfigParam("mm_app_id", "");
}
@Documented(position = 830,
identifier = "mm_secret",
category = "Basic Authentication",
tags = {"Pro"},
description = "Mattermost app secret key.")
public String mattermostSecret() {
return getConfigParam("mm_secret", "");
}
@Documented(position = 840,
identifier = "security.custom.provider",
value = "Continue with Acme Co.",
category = "Basic Authentication",
tags = {"Pro"},
description = "The text on the button for signing in with the custom authentication scheme.")
public String customLoginProvider() {
return getConfigParam("security.custom.provider", "Continue with Acme Co.");
}
@Documented(position = 850,
identifier = "security.custom.login_url",
category = "Basic Authentication",
tags = {"Pro"},
description = "The URL address of an externally hosted, custom login page.")
public String customLoginUrl() {
return getConfigParam("security.custom.login_url", "");
}
/* **************************************************************************************************************
* LDAP Authentication LDAP Authentication *
****************************************************************************************************************/
@Documented(position = 860,
identifier = "security.ldap.server_url",
category = "LDAP Authentication",
description = "LDAP server URL. LDAP will be disabled if this is blank.")
public String ldapServerUrl() {
return getConfigParam("security.ldap.server_url", "");
}
@Documented(position = 870,
identifier = "security.ldap.base_dn",
category = "LDAP Authentication",
description = "LDAP base DN.")
public String ldapBaseDN() {
return getConfigParam("security.ldap.base_dn", "");
}
@Documented(position = 880,
identifier = "security.ldap.user_search_base",
category = "LDAP Authentication",
description = "LDAP search base, which will be used only if a direct bind is unsuccessfull.")
public String ldapUserSearchBase() {
return getConfigParam("security.ldap.user_search_base", "");
}
@Documented(position = 890,
identifier = "security.ldap.user_search_filter",
value = "(cn={0})",
category = "LDAP Authentication",
description = "LDAP search filter, for finding users if a direct bind is unsuccessful.")
public String ldapUserSearchFilter() {
return getConfigParam("security.ldap.user_search_filter", "(cn={0})");
}
@Documented(position = 900,
identifier = "security.ldap.user_dn_pattern",
value = "uid={0}",
category = "LDAP Authentication",
description = "LDAP user DN pattern, which will be comined with the base DN to form the full path to the"
+ "user object, for a direct binding attempt.")
public String ldapUserDNPattern() {
return getConfigParam("security.ldap.user_dn_pattern", "uid={0}");
}
@Documented(position = 901,
identifier = "security.ldap.ad_mode_enabled",
value = "false",
type = Boolean.class,
category = "LDAP Authentication",
description = "Enable/disable support for authenticating with Active Directory. If `true`, AD is enabled.")
public Boolean ldapActiveDirectoryEnabled() {
return getConfigBoolean("security.ldap.ad_mode_enabled", false);
}
@Documented(position = 910,
identifier = "security.ldap.active_directory_domain",
category = "LDAP Authentication",
description = "AD domain name. Add this *only* if you are connecting to an Active Directory server.")
public String ldapActiveDirectoryDomain() {
return getConfigParam("security.ldap.active_directory_domain", "");
}
@Documented(position = 920,
identifier = "security.ldap.password_attribute",
value = "userPassword",
category = "LDAP Authentication",
description = "LDAP password attribute name.")
public String ldapPasswordAttributeName() {
return getConfigParam("security.ldap.password_attribute", "userPassword");
}
@Documented(position = 930,
identifier = "security.ldap.bind_dn",
category = "LDAP Authentication",
description = "LDAP bind DN")
public String ldapBindDN() {
return getConfigParam("security.ldap.bind_dn", "");
}
@Documented(position = 940,
identifier = "security.ldap.bind_pass",
category = "LDAP Authentication",
description = "LDAP bind password.")
public String ldapBindPassword() {
return getConfigParam("security.ldap.bind_pass", "");
}
@Documented(position = 950,
identifier = "security.ldap.username_as_name",
value = "false",
type = Boolean.class,
category = "LDAP Authentication",
description = "Enable/disable the use of usernames for names on Scoold.")
public boolean ldapUsernameAsName() {
return getConfigBoolean("security.ldap.username_as_name", false);
}
@Documented(position = 960,
identifier = "security.ldap.provider",
value = "Continue with LDAP",
category = "LDAP Authentication",
tags = {"Pro"},
description = "The text on the LDAP sign in button.")
public String ldapProvider() {
return getConfigParam("security.ldap.provider", "Continue with LDAP");
}
@Documented(position = 970,
identifier = "security.ldap.mods_group_node",
category = "LDAP Authentication",
description = "Moderators group mapping, mapping LDAP users with this node, to moderators on Scoold.")
public String ldapModeratorsGroupNode() {
return getConfigParam("security.ldap.mods_group_node", "");