159 local origin, features = event.origin, event.features; |
159 local origin, features = event.origin, event.features; |
160 if not origin.username then |
160 if not origin.username then |
161 if secure_auth_only and not origin.secure then |
161 if secure_auth_only and not origin.secure then |
162 return; |
162 return; |
163 end |
163 end |
|
164 local realm = module:get_option("sasl_realm") or origin.host; |
164 if module:get_option("anonymous_login") then |
165 if module:get_option("anonymous_login") then |
165 origin.sasl_handler = new_sasl(origin.host, anonymous_authentication_profile); |
166 origin.sasl_handler = new_sasl(realm, anonymous_authentication_profile); |
166 else |
167 else |
167 origin.sasl_handler = new_sasl(origin.host, default_authentication_profile); |
168 origin.sasl_handler = new_sasl(realm, default_authentication_profile); |
168 if not (module:get_option("allow_unencrypted_plain_auth")) and not origin.secure then |
169 if not (module:get_option("allow_unencrypted_plain_auth")) and not origin.secure then |
169 origin.sasl_handler:forbidden({"PLAIN"}); |
170 origin.sasl_handler:forbidden({"PLAIN"}); |
170 end |
171 end |
171 end |
172 end |
172 features:tag("mechanisms", mechanisms_attr); |
173 features:tag("mechanisms", mechanisms_attr); |