Creating a new Realm with Tapestry

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

Creating a new Realm with Tapestry

cbenden
Greetings all,

I want to use shirk on my tapestry website. I have a webserivice that can
authenticate users with logon credentials and also give roles back (which
are assigned in the backend).

I would like to create a custom shiro realm and integrate it in tapestry.

Could please give me a head start were I should place these files (within
Tapestry) and how to integrate them into the tapestry project (basically I'm
looking for best practice here because I absolutely have no clue but since
Tynamo is using shiro, I should be somehow work or tapestry too).

Thanks.
    Clemens



--
Sent from: http://shiro-user.582556.n2.nabble.com/
Reply | Threaded
Open this post in threaded view
|

Re: Creating a new Realm with Tapestry

Brian Demers

On Mon, Feb 12, 2018 at 6:28 AM, cbenden <[hidden email]> wrote:
Greetings all,

I want to use shirk on my tapestry website. I have a webserivice that can
authenticate users with logon credentials and also give roles back (which
are assigned in the backend).

I would like to create a custom shiro realm and integrate it in tapestry.

Could please give me a head start were I should place these files (within
Tapestry) and how to integrate them into the tapestry project (basically I'm
looking for best practice here because I absolutely have no clue but since
Tynamo is using shiro, I should be somehow work or tapestry too).

Thanks.
    Clemens



--
Sent from: http://shiro-user.582556.n2.nabble.com/

Reply | Threaded
Open this post in threaded view
|

Re: Creating a new Realm with Tapestry

cbenden
comming from there.

But what should I expect, when even tapestry itself has bad documentation
and even the smallest things must be aquired by endless trial and error
because the documentation is so bad.

I guess, this is not for those who are new to this stuff or who can not
stand bad documentation. I just go back to the source and try to extract
what I need to do.

Thanks for you effort.



--
Sent from: http://shiro-user.582556.n2.nabble.com/
Reply | Threaded
Open this post in threaded view
|

Re: Creating a new Realm with Tapestry

cbenden
Since I found my own question over and over in google while desperately
seeking for information here the solution how I did it:

1) create you Realm by deriving from AuthorizationRealm (or
AuthenticationRealm if that is all you need). There are plenty of examples -
you can all use them, they are not tapestry specific. Be sure to override
getName (so you know this value). I created a package named security with
all the stuff I needed for shiro in it (the place is really not important as
you work with IOC and only the name of the class is important).

2) weave the thing into you appModule:
        :
        public static void bind(ServiceBinder binder)
                {
                binder.bind(AuthorizingRealm.class,
MyRealm.class).withId(MyRealm.class.getSimpleName());
                }
        /* this will add your realm */
        public static void contributeWebSecurityManager(Configuration<Realm>
configuration, @InjectService("MyRealm") AuthorizingRealm myRealm)
                {
                configuration.add(myRealm);
                }
        /* this will configure your realm - you can do this because of
tapestry-secruity */
        public static void
contributeSecurityConfiguration(OrderedConfiguration<SecurityFilterChain>
configuration,
                                                         
SecurityFilterChainFactory factory)
                {
                // OrderedConfiguration must be named, so they can be overridden later
                configuration.add("signup-anon",
factory.createChain("/authc/signup").add(factory.anon()).build());
                }



--
Sent from: http://shiro-user.582556.n2.nabble.com/
Reply | Threaded
Open this post in threaded view
|

Re: Creating a new Realm with Tapestry

Brian Demers
Good stuff! Thanks for following up!

-Brian

> On Feb 17, 2018, at 5:59 AM, cbenden <[hidden email]> wrote:
>
> Since I found my own question over and over in google while desperately
> seeking for information here the solution how I did it:
>
> 1) create you Realm by deriving from AuthorizationRealm (or
> AuthenticationRealm if that is all you need). There are plenty of examples -
> you can all use them, they are not tapestry specific. Be sure to override
> getName (so you know this value). I created a package named security with
> all the stuff I needed for shiro in it (the place is really not important as
> you work with IOC and only the name of the class is important).
>
> 2) weave the thing into you appModule:
>        :
>    public static void bind(ServiceBinder binder)
>        {
>        binder.bind(AuthorizingRealm.class,
> MyRealm.class).withId(MyRealm.class.getSimpleName());
>        }
>        /* this will add your realm */
>    public static void contributeWebSecurityManager(Configuration<Realm>
> configuration, @InjectService("MyRealm") AuthorizingRealm myRealm)
>        {
>        configuration.add(myRealm);
>        }
>        /* this will configure your realm - you can do this because of
> tapestry-secruity */
>    public static void
> contributeSecurityConfiguration(OrderedConfiguration<SecurityFilterChain>
> configuration,
>                                                      
> SecurityFilterChainFactory factory)
>        {
>        // OrderedConfiguration must be named, so they can be overridden later
>        configuration.add("signup-anon",
> factory.createChain("/authc/signup").add(factory.anon()).build());
>        }
>
>
>
> --
> Sent from: http://shiro-user.582556.n2.nabble.com/