Dear Wiki user, You have subscribed to a wiki page or wiki category on "Tapestry Wiki" for change notification.
The following page has been changed by UlrichStaerk: http://wiki.apache.org/tapestry/Tapestry5HowToSpringSecurityAndOpenId ------------------------------------------------------------------------------ } }}} + Next we have to define ourselves a URL to which incoming OpenID authentication requests will be send and which the filter intercepts. Background: Every filter is intercepting requests for it's specific URL. If we just used the URL of an existing filter, our OpenID filter would intercept requests for this filter, thus making authentication fail. + + {{{ + #!java + public static void contributeApplicationDefaults( + MappedConfiguration<String, String> configuration) + { + /* here goes your own configuration... */ + ... + + configuration.add("spring-security.openidcheck.url", "/j_spring_openid_security_check"); + } + }}} + The second part is to configure the filter that intercepts incoming OpenID authentication requests and delegates those to the respective services: {{{ @@ -355, +369 @@ @SpringSecurityServices final RememberMeServices rememberMeServices, - @Inject @Value("${spring-security.check.url}") final String authUrl, + @Inject @Value("${spring-security.openidcheck.url}") final String authUrl, @Inject @Value("${spring-security.target.url}") final String targetUrl, @@ -424, +438 @@ public class LoginPage { @Inject - @Value("${spring-security.check.url}") + @Value("${spring-security.openidcheck.url}") private String checkUrl; @Inject @@ -465, +479 @@ </html> }}} + An example of how a login page for both form-based and OpenID based login could look like: + + LoginPage.java: + {{{ + #!java + package org.yourgroup.yourapp.pages; + + import org.apache.tapestry5.ioc.annotations.Inject; + import org.apache.tapestry5.ioc.annotations.Value; + import org.apache.tapestry5.services.Request; + + /** + * The login page (adapted from the tapestry-spring-security project). + * + * @author Ulrich Stärk + */ + public class LoginPage + { + @Inject + @Value("${spring-security.check.url}") + private String checkUrl; + + @Inject + @Value("${spring-security.openidcheck.url}") + private String openidCheckUrl; + + @Inject + private Request request; + + private boolean failed = false; + + public boolean isFailed() + { + return failed; + } + + public String getLoginCheckUrl() + { + return request.getContextPath() + checkUrl; + } + + public String getOpenIdCheckUrl() + { + return request.getContextPath() + openidCheckUrl; + } + + void onActivate(String extra) + { + if (extra.equals("failed")) + { + failed = true; + } + } + } + }}} + + LoginPage.tml: + {{{ + <html t:type="layout" xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd"> + OpenID: <br /> + <form xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd" action="${openIdCheckUrl}" method="POST"> + <t:if test="failed">Username and/or password was wrong!<br /></t:if> + <label class="username" for="j_username">Username:</label> + <input class="username" name="j_username" type="text" size="30"/> + <input id="submit" class="submit" type="submit" value="log in"/> + </form> + Form-based: <br /> + <form xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd" action="${loginCheckUrl}" method="POST"> + <t:if test="failed">Username and/or password was wrong!<br /></t:if> + <label class="username" for="j_username">Username:</label> + <input class="username" name="j_username" type="text" size="30"/> + <label class="password" for="j_password">Password</label> + <input class="password" name="j_password" type="password" size="10" maxlength="30"/> + <input id="submit" class="submit" type="submit" value="log in"/> + </form> + </html> + }}} + --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
