You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Martin Nielsen <mn...@gmail.com> on 2017/12/07 09:08:26 UTC

Disabling a link based on the authorization state of the page it links to.

Hello everyone.

I have been looking through this guide:
https://ci.apache.org/projects/wicket/guide/6.x/guide/security.html
I am currently trying to implement the AnnotationsRoleAuthorizationStrategy but
I have a followup question.

I would like to create a navbar with Links which disable themselves if the
page they link to is not allowed for the logged in user. I am guessing i
need to create a subclass of Link for this case.
So what i need is some way to ask Wicket if a page is allowed based on its
class alone.
Is there a method along the lines of isAllowed(Class<? extends Page>)
somewhere?

Or does anyone have a different idea of accomplishing this?


Thank you

-Martin

Re: Disabling a link based on the authorization state of the page it links to.

Posted by Martin Nielsen <mn...@gmail.com>.
Brilliant. Thank you:)

On Thu, Dec 7, 2017 at 10:31 AM, Andrea Del Bene <an...@gmail.com>
wrote:

> Hi,
>
> you can do it using your IAuthorizationStrategy:
>
> IAuthorizationStrategy as =
> Application.get().getSecuritySettings().getAuthorizationStrategy();
> as.isInstantiationAuthorized(Page.class);
>
>
>
> On Thu, Dec 7, 2017 at 10:08 AM, Martin Nielsen <mn...@gmail.com> wrote:
>
> > Hello everyone.
> >
> > I have been looking through this guide:
> > https://ci.apache.org/projects/wicket/guide/6.x/guide/security.html
> > I am currently trying to implement the AnnotationsRoleAuthorizationSt
> rategy
> > but
> > I have a followup question.
> >
> > I would like to create a navbar with Links which disable themselves if
> the
> > page they link to is not allowed for the logged in user. I am guessing i
> > need to create a subclass of Link for this case.
> > So what i need is some way to ask Wicket if a page is allowed based on
> its
> > class alone.
> > Is there a method along the lines of isAllowed(Class<? extends Page>)
> > somewhere?
> >
> > Or does anyone have a different idea of accomplishing this?
> >
> >
> > Thank you
> >
> > -Martin
> >
>

Re: Disabling a link based on the authorization state of the page it links to.

Posted by Andrea Del Bene <an...@gmail.com>.
Hi,

you can do it using your IAuthorizationStrategy:

IAuthorizationStrategy as =
Application.get().getSecuritySettings().getAuthorizationStrategy();
as.isInstantiationAuthorized(Page.class);



On Thu, Dec 7, 2017 at 10:08 AM, Martin Nielsen <mn...@gmail.com> wrote:

> Hello everyone.
>
> I have been looking through this guide:
> https://ci.apache.org/projects/wicket/guide/6.x/guide/security.html
> I am currently trying to implement the AnnotationsRoleAuthorizationStrategy
> but
> I have a followup question.
>
> I would like to create a navbar with Links which disable themselves if the
> page they link to is not allowed for the logged in user. I am guessing i
> need to create a subclass of Link for this case.
> So what i need is some way to ask Wicket if a page is allowed based on its
> class alone.
> Is there a method along the lines of isAllowed(Class<? extends Page>)
> somewhere?
>
> Or does anyone have a different idea of accomplishing this?
>
>
> Thank you
>
> -Martin
>