Comments (6)
Yes, federated accounts sign-in components already support returnPageName @parameter (return page is Oauth specific term). While the LoginForm was meant mainly as an example rather than reusable component, we can add support for the more common use cases. Take a look at https://github.com/tynamo/tynamo-federatedaccounts/blob/master/tynamo-federatedaccounts-core/src/main/java/org/tynamo/security/federatedaccounts/base/AbstractOauthSignIn.java and go ahead and implement getSuccessPageUri() similar to getReturnPageUri() (with caret support!) and I'll merge that in.
from tapestry-security.
Thanks, will do.
from tapestry-security.
I have started to implement this feature based on AbstractOauthSignIn
,
If I understand correctly the caret support comes handy if you embed the login form in a page where you would like to return after successful login. For this scenario the context of the page is considered when constructing return URL.
For other pages than the current one it is not possible to pass context or parameters.
For my use case I would need context support. I have log in button on a page what takes the user to the log in page and up on successful log in the user should be redirected to the page where it came from.
To solve this I introduced a @Parameter String successURL
to security.loginForm (default value is SecuritySymbols.SUCCESS_URL
).
My getSuccessPageUri()
simply returns it, so it's the responsibility of the client code to build the custom success URL.
@Parameter(defaultPrefix = BindingConstants.LITERAL, value = "prop:defaultSuccessURL")
private String successURL;
@Inject
@Symbol(SecuritySymbols.SUCCESS_URL)
@Property(write = false)
private String defaultSuccessURL;
private String getSuccessPageUri()
{
if ("^".equals(successURL))
{
return pageRenderLinkSource.createPageRenderLink(componentResources.getPage().getClass()).toAbsoluteURI();
}
if (StringUtils.hasText(getSuccessURL()))
{
return getSuccessURL();
}
else
{
// Empty returnpageName denotes a base url. Default for default return page may be set to a non empty value.
// If default is empty and not locally overridden, return the baseurl
return baseURLSource.getBaseURL(request.isSecure());
}
}
public String getSuccessURL()
{
return StringUtils.hasText(successURL) ? successURL : defaultSuccessURL;
}
I was trying to research how would this should be done in the tapestry way, but this is I could come up.
I can confirm that this works for my use case.
@kaosko is this the right direction to support link context and parameters?
from tapestry-security.
The client code looks like this:
Login.tml:
<t:security.loginForm successURL="prop:successURL">
</t:security.loginForm>
Login.java
@ActivationRequestParameter("successURL")
@Property
private String successURL;
Page that is navigating to Login page with custom successURL.
.tml
<a t:type="pagelink" t:page="user/Login" t:parameters="loginQueryParams" class="navbar-button">
<button class="btn btn-primary">${message:login}</button>
</a>
.java
@Inject
private Request request;
public Map<String, Object> getLoginQueryParams()
{
final Map<String, Object> queryParams = new HashMap<>();
queryParams.put("successURL", this.request.getPath()); //getPath() returns URL containing the page context
return queryParams;
}
from tapestry-security.
Shiro's savedRequest cookies is meant exactly for that use case. support for savedRequest is meant to address the use case but comment out because the functionality was pushed down to LoginContextService Impl. You use a query parameter instead - wouldn't it be easier to just override LoginContextService for your purposes? (Just asking, it's quite possible I'm missing something from the picture).
from tapestry-security.
Closing. @balapal, see comments in my commit to see what was kept and what changed and why.
from tapestry-security.
Related Issues (20)
- Update to Tapestry 5.4.1
- Add a symbol for setting a permanent rememberme cipher key
- Regression: Remember me stopped working in 0.6.5 HOT 4
- Contribution methods are used to contribute to wrong services HOT 1
- post session timeout redirect loosing query params HOT 1
- tapestry-security pom.xml has unneeded "compile" dependency on testng HOT 4
- Add a Binding for permission checks
- Default SecurityConfiguration causes warnings in logs HOT 2
- SecurityFilterChainHubImpl don't consider RegExPatternMatcher
- resolvePageNameToClassName() called twice HOT 1
- REMEMBERME_CIPHERKERY constant name incorrectly spelt HOT 1
- Missing license HOT 2
- SAML with Okta support HOT 4
- Invalid response returned from AccessControlFilter.redirectToLogin for XMLHttpRequests for Tapestry > 5.4 HOT 3
- Does not work with tapestry 5.7.0 HOT 4
- Update 0.9.x to use Shiro 1.7.1
- Any plans for migrating tapestry security to T5.7.2? HOT 1
- CAS support is based on deprecated library in Shiro HOT 3
- SecurityModule should use symbols for assets and modules paths
- 0.8.0 and 0.9.0 Pulling in wrong depencencies HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tapestry-security.