Fix compliance page login redirect to custom domains
SafeRedirect previously matched against a single static host string, so OIDC callbacks always fell back to the console instead of redirecting back to compliance pages on custom domains. Refactor AllowedHost into a dynamic AllowedHostFunc and wire a trust-service lookup into the connect handler so custom domain hosts are accepted. Signed-off-by: Bryan Frimin <bryan@getprobo.com>
This commit is contained in:
@@ -81,7 +81,7 @@ func NewMux(
|
||||
) *chi.Mux {
|
||||
r := chi.NewMux()
|
||||
|
||||
safeRedirect := &saferedirect.SafeRedirect{AllowedHost: baseURL.Host()}
|
||||
safeRedirect := saferedirect.New(saferedirect.StaticHosts(baseURL.Host()))
|
||||
|
||||
graphqlHandler := NewGraphQLHandler(iamSvc, proboSvc, esignSvc, mailmanSvc, customDomainCname, logger)
|
||||
|
||||
@@ -141,9 +141,9 @@ func NewMux(
|
||||
var oauthSafeRedirect *saferedirect.SafeRedirect
|
||||
switch provider {
|
||||
case "SLACK":
|
||||
oauthSafeRedirect = &saferedirect.SafeRedirect{AllowedHost: "slack.com"}
|
||||
oauthSafeRedirect = saferedirect.New(saferedirect.StaticHosts("slack.com"))
|
||||
case "GOOGLE_WORKSPACE":
|
||||
oauthSafeRedirect = &saferedirect.SafeRedirect{AllowedHost: "accounts.google.com"}
|
||||
oauthSafeRedirect = saferedirect.New(saferedirect.StaticHosts("accounts.google.com"))
|
||||
}
|
||||
oauthSafeRedirect.Redirect(w, r, redirectURL, "/", http.StatusSeeOther)
|
||||
})
|
||||
|
||||
@@ -8778,6 +8778,7 @@ func (r *riskConnectionResolver) TotalCount(ctx context.Context, obj *types.Risk
|
||||
func (r *slackConnectionResolver) Permission(ctx context.Context, obj *types.SlackConnection, action string) (bool, error) {
|
||||
return r.Resolver.Permission(ctx, obj, action)
|
||||
}
|
||||
|
||||
// Organization is the resolver for the organization field.
|
||||
func (r *snapshotResolver) Organization(ctx context.Context, obj *types.Snapshot) (*types.Organization, error) {
|
||||
if err := r.authorize(ctx, obj.ID, probo.ActionOrganizationGet); err != nil {
|
||||
@@ -10716,6 +10717,7 @@ func (r *Resolver) RiskConnection() schema.RiskConnectionResolver { return &risk
|
||||
func (r *Resolver) SlackConnection() schema.SlackConnectionResolver {
|
||||
return &slackConnectionResolver{r}
|
||||
}
|
||||
|
||||
// Snapshot returns schema.SnapshotResolver implementation.
|
||||
func (r *Resolver) Snapshot() schema.SnapshotResolver { return &snapshotResolver{r} }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user