discourse/app/services/wildcard_domain_checker.rb
Maja Komel 27e732a58d FEATURE: allow multiple secrets for Discourse SSO provider
This splits off the logic between SSO keys used incoming vs outgoing, it allows to far better restrict who is allowed to log in using a site.

This allows for better auditing of the SSO provider feature
2018-10-15 16:03:53 +11:00

11 lines
293 B
Ruby

module WildcardDomainChecker
def self.check_domain(domain, external_domain)
escaped_domain = domain[0] == "*" ? Regexp.escape(domain).sub("\\*", '\S*') : Regexp.escape(domain)
domain_regex = Regexp.new("^#{escaped_domain}$", 'i')
external_domain.match(domain_regex)
end
end