@@ -26,6 +26,9 @@ def read_config(self, config, **kwargs):
26
26
if not saml2_config or not saml2_config .get ("enabled" , True ):
27
27
return
28
28
29
+ if not saml2_config .get ("sp_config" ) and not saml2_config .get ("config_path" ):
30
+ return
31
+
29
32
try :
30
33
check_requirements ("saml2" )
31
34
except DependencyException as e :
@@ -76,65 +79,73 @@ def generate_config_section(self, config_dir_path, server_name, **kwargs):
76
79
return """\
77
80
# Enable SAML2 for registration and login. Uses pysaml2.
78
81
#
79
- # `sp_config` is the configuration for the pysaml2 Service Provider.
80
- # See pysaml2 docs for format of config .
82
+ # At least one of `sp_config` or `config_path` must be set in this section to
83
+ # enable SAML login .
81
84
#
82
- # Default values will be used for the 'entityid' and 'service' settings,
83
- # so it is not normally necessary to specify them unless you need to
84
- # override them.
85
+ # (You will probably also want to set the following options to `false` to
86
+ # disable the regular login/registration flows:
87
+ # * enable_registration
88
+ # * password_config.enabled
85
89
#
86
90
# Once SAML support is enabled, a metadata file will be exposed at
87
91
# https://<server>:<port>/_matrix/saml2/metadata.xml, which you may be able to
88
92
# use to configure your SAML IdP with. Alternatively, you can manually configure
89
93
# the IdP to use an ACS location of
90
94
# https://<server>:<port>/_matrix/saml2/authn_response.
91
95
#
92
- #saml2_config:
93
- # sp_config:
94
- # # point this to the IdP's metadata. You can use either a local file or
95
- # # (preferably) a URL.
96
- # metadata:
97
- # #local: ["saml2/idp.xml"]
98
- # remote:
99
- # - url: https://our_idp/metadata.xml
100
- #
101
- # # By default, the user has to go to our login page first. If you'd like to
102
- # # allow IdP-initiated login, set 'allow_unsolicited: True' in a
103
- # # 'service.sp' section:
104
- # #
105
- # #service:
106
- # # sp:
107
- # # allow_unsolicited: True
108
- #
109
- # # The examples below are just used to generate our metadata xml, and you
110
- # # may well not need it, depending on your setup. Alternatively you
111
- # # may need a whole lot more detail - see the pysaml2 docs!
112
- #
113
- # description: ["My awesome SP", "en"]
114
- # name: ["Test SP", "en"]
115
- #
116
- # organization:
117
- # name: Example com
118
- # display_name:
119
- # - ["Example co", "en"]
120
- # url: "http://example.com"
121
- #
122
- # contact_person:
123
- # - given_name: Bob
124
- # sur_name: "the Sysadmin"
125
- # email_address": ["[email protected] "]
126
- # contact_type": technical
127
- #
128
- # # Instead of putting the config inline as above, you can specify a
129
- # # separate pysaml2 configuration file:
130
- # #
131
- # config_path: "%(config_dir_path)s/sp_conf.py"
132
- #
133
- # # the lifetime of a SAML session. This defines how long a user has to
134
- # # complete the authentication process, if allow_unsolicited is unset.
135
- # # The default is 5 minutes.
136
- # #
137
- # # saml_session_lifetime: 5m
96
+ saml2_config:
97
+ # `sp_config` is the configuration for the pysaml2 Service Provider.
98
+ # See pysaml2 docs for format of config.
99
+ #
100
+ # Default values will be used for the 'entityid' and 'service' settings,
101
+ # so it is not normally necessary to specify them unless you need to
102
+ # override them.
103
+ #
104
+ #sp_config:
105
+ # # point this to the IdP's metadata. You can use either a local file or
106
+ # # (preferably) a URL.
107
+ # metadata:
108
+ # #local: ["saml2/idp.xml"]
109
+ # remote:
110
+ # - url: https://our_idp/metadata.xml
111
+ #
112
+ # # By default, the user has to go to our login page first. If you'd like
113
+ # # to allow IdP-initiated login, set 'allow_unsolicited: True' in a
114
+ # # 'service.sp' section:
115
+ # #
116
+ # #service:
117
+ # # sp:
118
+ # # allow_unsolicited: true
119
+ #
120
+ # # The examples below are just used to generate our metadata xml, and you
121
+ # # may well not need them, depending on your setup. Alternatively you
122
+ # # may need a whole lot more detail - see the pysaml2 docs!
123
+ #
124
+ # description: ["My awesome SP", "en"]
125
+ # name: ["Test SP", "en"]
126
+ #
127
+ # organization:
128
+ # name: Example com
129
+ # display_name:
130
+ # - ["Example co", "en"]
131
+ # url: "http://example.com"
132
+ #
133
+ # contact_person:
134
+ # - given_name: Bob
135
+ # sur_name: "the Sysadmin"
136
+ # email_address": ["[email protected] "]
137
+ # contact_type": technical
138
+
139
+ # Instead of putting the config inline as above, you can specify a
140
+ # separate pysaml2 configuration file:
141
+ #
142
+ #config_path: "%(config_dir_path)s/sp_conf.py"
143
+
144
+ # the lifetime of a SAML session. This defines how long a user has to
145
+ # complete the authentication process, if allow_unsolicited is unset.
146
+ # The default is 5 minutes.
147
+ #
148
+ #saml_session_lifetime: 5m
138
149
""" % {
139
150
"config_dir_path" : config_dir_path
140
151
}
0 commit comments