-
Notifications
You must be signed in to change notification settings - Fork 7
Safe redirect action #7695
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Safe redirect action #7695
Changes from all commits
04248e2
43b7ae8
f144b56
36ad9d2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -35,7 +35,9 @@ | |
| import org.labkey.api.action.ExportAction; | ||
| import org.labkey.api.action.MutatingApiAction; | ||
| import org.labkey.api.action.ReadOnlyApiAction; | ||
| import org.labkey.api.action.ReturnUrlForm; | ||
| import org.labkey.api.action.SimpleApiJsonForm; | ||
| import org.labkey.api.action.SimpleRedirectAction; | ||
| import org.labkey.api.action.SimpleViewAction; | ||
| import org.labkey.api.action.SpringActionController; | ||
| import org.labkey.api.admin.AbstractFolderContext.ExportType; | ||
|
|
@@ -204,10 +206,6 @@ | |
|
|
||
| import static org.labkey.api.view.template.WarningService.SESSION_WARNINGS_BANNER_KEY; | ||
|
|
||
| /** | ||
| * User: jeckels | ||
| * Date: Jan 4, 2007 | ||
| */ | ||
| public class CoreController extends SpringActionController | ||
| { | ||
| private static final Map<Container, Content> _customStylesheetCache = new ConcurrentHashMap<>(); | ||
|
|
@@ -2908,4 +2906,20 @@ public void setProvider(String provider) | |
|
|
||
| } | ||
|
|
||
| // Called by various client components to ensure safe redirects, GitHub Issue #1023. This action redirects to | ||
| // local URLs only, never to an external site, even if the host is on the "Allowed External Redirect Hosts" list. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is it that assures this uses local URLs only? Doesn't seem to be codified here.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. First,
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks, Adam!
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. FYI: I expanded the action's comment to lay out the safety guarantees similar to the above |
||
| // Why is this safe? First, ActionURL is guaranteed to be a local URL (schema, host, and port are always taken | ||
| // from local AppProps, even if an absolute URL is requested via getURIString() or similar). Second, | ||
| // SimpleRedirectAction throws RedirectException which also guarantees local redirects (instances of that class | ||
| // always use getLocalURIString()). | ||
| @SuppressWarnings("unused") | ||
| @RequiresNoPermission | ||
| public static class SafeRedirectAction extends SimpleRedirectAction<ReturnUrlForm> | ||
| { | ||
| @Override | ||
| public ActionURL getRedirectURL(ReturnUrlForm form) throws Exception | ||
| { | ||
| return form.getReturnActionURL(AppProps.getInstance().getHomePageActionURL()); | ||
| } | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as noted in the commit message, I'll wait until this gets merged to develop to address this TODO so that I don't need to bump @labkey/components for this branch (and have to handle the merge forward conflicts)