Tynamo Security Login Page

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Tynamo Security Login Page

Adam X
I have tapestry-security integrated and working in my project. Page
classes annotated with shiro such as @RequiresAuthentication get
intercepted with the login page.

What is the best way to create a link on my page that redirects to tap
security login page?

In my Laout.java I tried this:

    @Property
    @Inject
    private SecurityService securityService;

    @Property
    @InjectPage
    private org.tynamo.security.pages.Login loginPage;

then in my Layout.tml I have this:

        <t:if test="securityService.authenticated">
          ${securityService.subject.principal}
          <p:else>
            Guest (<t:pagelink page="loginPage">Sign In</t:pagelink>)
          </p:else>
        </t:if>

But Tapestry is unable to find this Tynamo page, even though it is
clearly there:

Caused by: org.apache.tapestry5.ioc.util.UnknownValueException: Unable
to resolve 'loginPage' to a known page name

What is the accepted (or recommended) way to bring up the login page
in such a setup?

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Tynamo Security Login Page

Kalle Korhonen-2
Need to specify the library since it's not your own component - loginPage
is just a local attribute name. Use <t:pagelink page="security/login"> or
just replace the whole block with <:tsecurity.loginlink>.

Kalle

On Wed, Nov 9, 2016 at 9:03 AM, Adam X <[hidden email]> wrote:

> I have tapestry-security integrated and working in my project. Page
> classes annotated with shiro such as @RequiresAuthentication get
> intercepted with the login page.
>
> What is the best way to create a link on my page that redirects to tap
> security login page?
>
> In my Laout.java I tried this:
>
>     @Property
>     @Inject
>     private SecurityService securityService;
>
>     @Property
>     @InjectPage
>     private org.tynamo.security.pages.Login loginPage;
>
> then in my Layout.tml I have this:
>
>         <t:if test="securityService.authenticated">
>           ${securityService.subject.principal}
>           <p:else>
>             Guest (<t:pagelink page="loginPage">Sign In</t:pagelink>)
>           </p:else>
>         </t:if>
>
> But Tapestry is unable to find this Tynamo page, even though it is
> clearly there:
>
> Caused by: org.apache.tapestry5.ioc.util.UnknownValueException: Unable
> to resolve 'loginPage' to a known page name
>
> What is the accepted (or recommended) way to bring up the login page
> in such a setup?
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Tynamo Security Login Page

Adam X
Kyle, you rock man. Works like a charm.

I'm sorry for having so many questions but I like
tapestry-secruity/shiro and I'd like to integrate it all the way in my
solution. So I have few more follow ups:

1)
How do I customize the login page?
a) I'd like to edit error messages: "You must provide a value for Tynamo Login."
b) I'd like to style it differently, add company logo and maybe even edit html

2)
I'd like to hook up a processing interceptor after successful login.
In essence, after shiro accepts credentials, instead of letting it go
to my Tapestry page, I'd like to display my own page which asks for
more information (say two factor authentication).

Adam

On Wed, Nov 9, 2016 at 6:54 PM, Kalle Korhonen
<[hidden email]> wrote:

> Need to specify the library since it's not your own component - loginPage
> is just a local attribute name. Use <t:pagelink page="security/login"> or
> just replace the whole block with <:tsecurity.loginlink>.
>
> Kalle
>
> On Wed, Nov 9, 2016 at 9:03 AM, Adam X <[hidden email]> wrote:
>
>> I have tapestry-security integrated and working in my project. Page
>> classes annotated with shiro such as @RequiresAuthentication get
>> intercepted with the login page.
>>
>> What is the best way to create a link on my page that redirects to tap
>> security login page?
>>
>> In my Laout.java I tried this:
>>
>>     @Property
>>     @Inject
>>     private SecurityService securityService;
>>
>>     @Property
>>     @InjectPage
>>     private org.tynamo.security.pages.Login loginPage;
>>
>> then in my Layout.tml I have this:
>>
>>         <t:if test="securityService.authenticated">
>>           ${securityService.subject.principal}
>>           <p:else>
>>             Guest (<t:pagelink page="loginPage">Sign In</t:pagelink>)
>>           </p:else>
>>         </t:if>
>>
>> But Tapestry is unable to find this Tynamo page, even though it is
>> clearly there:
>>
>> Caused by: org.apache.tapestry5.ioc.util.UnknownValueException: Unable
>> to resolve 'loginPage' to a known page name
>>
>> What is the accepted (or recommended) way to bring up the login page
>> in such a setup?
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden email]
>> For additional commands, e-mail: [hidden email]
>>
>>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Tynamo Security Login Page

Dusko Jovanovski
The behaviors that you are describing can be easily configured using
Symbols. Take a look at the SecuritySymbols class:
https://github.com/tynamo/tapestry-security/blob/master/src/main/java/org/tynamo/security/SecuritySymbols.java

The Symbols that you are looking for are: LOGIN_URL and SUCCESS_URL. The
idea is to provide your own pages instead of the default ones.

Here's how the defaults are configured, you need to override those in your
own module:
https://github.com/tynamo/tapestry-security/blob/master/src/main/java/org/tynamo/security/services/SecurityModule.java#L121

I also agree Kalle rocks.

On Thu, Nov 10, 2016 at 11:51 AM, Adam X <[hidden email]> wrote:

> Kyle, you rock man. Works like a charm.
>
> I'm sorry for having so many questions but I like
> tapestry-secruity/shiro and I'd like to integrate it all the way in my
> solution. So I have few more follow ups:
>
> 1)
> How do I customize the login page?
> a) I'd like to edit error messages: "You must provide a value for Tynamo
> Login."
> b) I'd like to style it differently, add company logo and maybe even edit
> html
>
> 2)
> I'd like to hook up a processing interceptor after successful login.
> In essence, after shiro accepts credentials, instead of letting it go
> to my Tapestry page, I'd like to display my own page which asks for
> more information (say two factor authentication).
>
> Adam
>
> On Wed, Nov 9, 2016 at 6:54 PM, Kalle Korhonen
> <[hidden email]> wrote:
> > Need to specify the library since it's not your own component - loginPage
> > is just a local attribute name. Use <t:pagelink page="security/login"> or
> > just replace the whole block with <:tsecurity.loginlink>.
> >
> > Kalle
> >
> > On Wed, Nov 9, 2016 at 9:03 AM, Adam X <[hidden email]> wrote:
> >
> >> I have tapestry-security integrated and working in my project. Page
> >> classes annotated with shiro such as @RequiresAuthentication get
> >> intercepted with the login page.
> >>
> >> What is the best way to create a link on my page that redirects to tap
> >> security login page?
> >>
> >> In my Laout.java I tried this:
> >>
> >>     @Property
> >>     @Inject
> >>     private SecurityService securityService;
> >>
> >>     @Property
> >>     @InjectPage
> >>     private org.tynamo.security.pages.Login loginPage;
> >>
> >> then in my Layout.tml I have this:
> >>
> >>         <t:if test="securityService.authenticated">
> >>           ${securityService.subject.principal}
> >>           <p:else>
> >>             Guest (<t:pagelink page="loginPage">Sign In</t:pagelink>)
> >>           </p:else>
> >>         </t:if>
> >>
> >> But Tapestry is unable to find this Tynamo page, even though it is
> >> clearly there:
> >>
> >> Caused by: org.apache.tapestry5.ioc.util.UnknownValueException: Unable
> >> to resolve 'loginPage' to a known page name
> >>
> >> What is the accepted (or recommended) way to bring up the login page
> >> in such a setup?
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: [hidden email]
> >> For additional commands, e-mail: [hidden email]
> >>
> >>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Tynamo Security Login Page

Kalle Korhonen-2
In reply to this post by Adam X
On Thu, Nov 10, 2016 at 2:51 AM, Adam X <[hidden email]> wrote:

> 1)
> How do I customize the login page?
> a) I'd like to edit error messages: "You must provide a value for Tynamo
> Login."
> b) I'd like to style it differently, add company logo and maybe even edit
> html
>

(You could override but) don't try to customize it, instead just create
your own custom login page, you could copy the login page source and modify
from there.

2)
> I'd like to hook up a processing interceptor after successful login.
> In essence, after shiro accepts credentials, instead of letting it go
> to my Tapestry page, I'd like to display my own page which asks for
> more information (say two factor authentication).
>

As Dusko said, use the symbols.

Kalle



> On Wed, Nov 9, 2016 at 6:54 PM, Kalle Korhonen
> <[hidden email]> wrote:
> > Need to specify the library since it's not your own component - loginPage
> > is just a local attribute name. Use <t:pagelink page="security/login"> or
> > just replace the whole block with <:tsecurity.loginlink>.
> >
> > Kalle
> >
> > On Wed, Nov 9, 2016 at 9:03 AM, Adam X <[hidden email]> wrote:
> >
> >> I have tapestry-security integrated and working in my project. Page
> >> classes annotated with shiro such as @RequiresAuthentication get
> >> intercepted with the login page.
> >>
> >> What is the best way to create a link on my page that redirects to tap
> >> security login page?
> >>
> >> In my Laout.java I tried this:
> >>
> >>     @Property
> >>     @Inject
> >>     private SecurityService securityService;
> >>
> >>     @Property
> >>     @InjectPage
> >>     private org.tynamo.security.pages.Login loginPage;
> >>
> >> then in my Layout.tml I have this:
> >>
> >>         <t:if test="securityService.authenticated">
> >>           ${securityService.subject.principal}
> >>           <p:else>
> >>             Guest (<t:pagelink page="loginPage">Sign In</t:pagelink>)
> >>           </p:else>
> >>         </t:if>
> >>
> >> But Tapestry is unable to find this Tynamo page, even though it is
> >> clearly there:
> >>
> >> Caused by: org.apache.tapestry5.ioc.util.UnknownValueException: Unable
> >> to resolve 'loginPage' to a known page name
> >>
> >> What is the accepted (or recommended) way to bring up the login page
> >> in such a setup?
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: [hidden email]
> >> For additional commands, e-mail: [hidden email]
> >>
> >>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Tynamo Security Login Page

Adam X
Hi All -

Just as a follow up, I was able to resolve everything based in large
part on the feedback from Kalle. Had a successful demo for the sprint
end.

1)
Did a copy-paste of the login tml/java from tapestry-security and
derived customizations from there. Used symbols to tell
tapestry-security what the new login page is. Worked like a charm.

2)
As for the interceptor, I used "Protecting Pages" example from
jumpstart (http://jumpstart.doublenegative.com.au/jumpstart7/examples/infrastructure/protectingpages)
except instead of protecting page (which is already done by
shiro/tap-security), I was interested in contributing a filter with
intercepting mechansim which displays a 2nd form for dual
authentication. Works like a charm.

So I have to say THANK YOU guys for help received here. Makes a
difference. I'm sure I will have more questions, so I hope you stay
patient with me :)

Adam

On Thu, Nov 10, 2016 at 5:46 PM, Kalle Korhonen
<[hidden email]> wrote:

> On Thu, Nov 10, 2016 at 2:51 AM, Adam X <[hidden email]> wrote:
>
>> 1)
>> How do I customize the login page?
>> a) I'd like to edit error messages: "You must provide a value for Tynamo
>> Login."
>> b) I'd like to style it differently, add company logo and maybe even edit
>> html
>>
>
> (You could override but) don't try to customize it, instead just create
> your own custom login page, you could copy the login page source and modify
> from there.
>
> 2)
>> I'd like to hook up a processing interceptor after successful login.
>> In essence, after shiro accepts credentials, instead of letting it go
>> to my Tapestry page, I'd like to display my own page which asks for
>> more information (say two factor authentication).
>>
>
> As Dusko said, use the symbols.
>
> Kalle
>
>
>
>> On Wed, Nov 9, 2016 at 6:54 PM, Kalle Korhonen
>> <[hidden email]> wrote:
>> > Need to specify the library since it's not your own component - loginPage
>> > is just a local attribute name. Use <t:pagelink page="security/login"> or
>> > just replace the whole block with <:tsecurity.loginlink>.
>> >
>> > Kalle
>> >
>> > On Wed, Nov 9, 2016 at 9:03 AM, Adam X <[hidden email]> wrote:
>> >
>> >> I have tapestry-security integrated and working in my project. Page
>> >> classes annotated with shiro such as @RequiresAuthentication get
>> >> intercepted with the login page.
>> >>
>> >> What is the best way to create a link on my page that redirects to tap
>> >> security login page?
>> >>
>> >> In my Laout.java I tried this:
>> >>
>> >>     @Property
>> >>     @Inject
>> >>     private SecurityService securityService;
>> >>
>> >>     @Property
>> >>     @InjectPage
>> >>     private org.tynamo.security.pages.Login loginPage;
>> >>
>> >> then in my Layout.tml I have this:
>> >>
>> >>         <t:if test="securityService.authenticated">
>> >>           ${securityService.subject.principal}
>> >>           <p:else>
>> >>             Guest (<t:pagelink page="loginPage">Sign In</t:pagelink>)
>> >>           </p:else>
>> >>         </t:if>
>> >>
>> >> But Tapestry is unable to find this Tynamo page, even though it is
>> >> clearly there:
>> >>
>> >> Caused by: org.apache.tapestry5.ioc.util.UnknownValueException: Unable
>> >> to resolve 'loginPage' to a known page name
>> >>
>> >> What is the accepted (or recommended) way to bring up the login page
>> >> in such a setup?
>> >>
>> >> ---------------------------------------------------------------------
>> >> To unsubscribe, e-mail: [hidden email]
>> >> For additional commands, e-mail: [hidden email]
>> >>
>> >>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden email]
>> For additional commands, e-mail: [hidden email]
>>
>>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]