Comments (5)
Oh that's certainly possible, even easy. If you only want the behavior when user clicks on the login link, I'd simply create a custom LoginLink component that generates different login urls based on the state/context. If you want the security to hand you a different login link based on the current page, you'd have to override LoginContextService (specifically, in 0.6.2 it's getLoginURL() ). The service is internal because the API is still somewhat unstable. One thing to note that security runs as part of HttpServletRequest pipeline so T5 Request, Responsed are not available yet. You can follow the implementation in LoginContextServiceImpl.createSavedRequestCookie() to create them if needed. Try implementing it and if you think the library can support the use case then open a more specific, for now I'm closing this as it seems there's no changes needed.
from tapestry-security.
If you want the security to hand you a different login link based on the current page, you'd have to override LoginContextService (specifically, in 0.6.2 it's getLoginURL() )
@kaosko I also thought it was easy, but actually, I'm not quite sure where to do this. Extending/implementing the page class with the LoginContextService interface is probably not the right way. Can you point me to the right direction?
Edit: I've been looking into http://tapestry.apache.org/ioc-cookbook-overriding-ioc-services.html, but find it hard to go further from there. Also looking into Service Advisors; http://tapestry.apache.org/service-advisors.html.
from tapestry-security.
Pages and services are different concepts so don't mix them. As explained on the ioc-services page you linked to, you'd do:
public class CustomLoginContextService extends LoginContextServiceImpl {
@Override
public String getLoginURL() {
return "/some/custom/url";
}
}
public static void bind(ServiceBinder binder)
{
binder.bind(LoginContextService.class, CustomLoginContextServiceImpl.class).withId("CustomLoginContextService");
}
@Contribute(ServiceOverride.class)
public static void setupApplicationServiceOverrides(MappedConfiguration<Class,Object> configuration, @Local LoginContextService override)
{
configuration.add(LoginContextService.class, override);
}
Finally, GitHub issues are not support forums. Join the mailing lists for more advice.
from tapestry-security.
I wasn't successful with this approach. I don't know how to make sure that the new CustomContextLoginService is only used by specific pages / page classes. Tried injecting the page with the service ID. As a side note, I had to implement all the other ContextLoginServiceImpl methods which I didn't want to override - did that by referencing the instance methods of the of the base service. This is just FYI what I tried, feel free to ignore this.
Thanks for looking into it, anyway. I thought that it might be of interest to the project and that's why I posted it here, but maybe it's too much of a niche use case to be taken seriously. Not trying to abuse the issues for support by any means. Will look into the mailing lists. Thanks again!
from tapestry-security.
No, a service is a singleton, you have to let go of the idea that different pages could use a different version of the same service. Instead, you should build the logic inside your one customized service based on the current page/context. Similarly to LoginContextServiceImpl.createSavedRequestCookie(), you could decode eventParameters, and based on getActivePageName() you'd return a different login URL.
Role based logic doesn't seem like it would work - the user would be unauthenticated at that point (unless you have a mechanism to identify the user first, for example with rememberMe cookie).
I don't think your request is too esoteric at all but I simply consider the library to already support your use case with simple enough customization.
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.