feat: add strict_domain_check config attribute to be used in GET /login #4
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Background:
In current setup if we want to register a subdomain to vouch we need to configure it on openresty and vouch-proxy config. Sometime we forgot to configure the vouch proxy part (or developers just add it without telling infra team). When that happen they will be redirected to any subdomain (usually the first) that share a domain suffix. For example from grafana.cermati.com to jenkins.cermati.com. It is because the request hostname are checked for matching suffix domain. The problem is we must include the top level domain (e.g
cermati.com
) because it will be used for email checking.The logic to get redirect URL is as follow:
Config.Domains
to check for matching domain.callback_urls
usingstrings.Contains
, which if the returned domain is TLD we will guaranteed to get a redirect URL.Changes:
Add
strict_domain_check
attribute in config to indicates that we need to use strict comparison on subdomain matching. If the subdomain is not match it will send 400 response (instead of redirecting to random URL)