You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by csckid <te...@gmail.com> on 2011/12/17 05:12:21 UTC

shiro

I wrote this following code to restrict the user from accessing certain
pages. Problem is it isn't working correctly.
configuration.add(factory.createChain("/index").add(factory.authc()).build());
I wrote this code so that only authorized user view the page, But in my
program everyone can view.

configuration.add(factory.createChain("/medicine/**").add(factory.roles(),
"employee").build());
configuration.add(factory.createChain("/medicine/**").add(factory.roles(),
"doctor").build());
With this code employee cannot access tml file of medicine folder but doctor
can. Why is this so?

public static void
contributeSecurityConfiguration(Configuration<SecurityFilterChain>
configuration,
			SecurityFilterChainFactory factory) {
	
    
configuration.add(factory.createChain("/signin").add(factory.anon()).build());
    
configuration.add(factory.createChain("/index").add(factory.authc()).build());
    	
    
configuration.add(factory.createChain("/medicine/**").add(factory.roles(),
"employee").build());
    
configuration.add(factory.createChain("/prescription/**").add(factory.roles(),
"doctor").build());
    
configuration.add(factory.createChain("/medicine/**").add(factory.roles(),
"doctor").build());
}	


--
View this message in context: http://tapestry.1045711.n5.nabble.com/shiro-tp5082018p5082018.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: shiro

Posted by Kalle Korhonen <ka...@gmail.com>.
On Tue, Dec 20, 2011 at 3:45 AM, csckid <te...@gmail.com> wrote:
>  public static void
> contributeSecurityConfiguration(Configuration<SecurityFilterChain>
> configuration,
>                        SecurityFilterChainFactory factory) {
>
> configuration.add(factory.createChain("/medicine/create").add(factory.roles(),"employee,
> doctor").build());
> }
>
> and
> @RequiresRoles(value = {"doctor", "employee"})

As Alejandro says, the default logical operation is AND, meaning you
need both of the roles. You should specify @RequiresRoles(value =
{"doctor", "employee"}, logical=Logical.OR) instead. If that doesn't
work, open an issue.

Kalle

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: shiro

Posted by csckid <te...@gmail.com>.
I tried this

 public static void
contributeSecurityConfiguration(Configuration<SecurityFilterChain>
configuration,
			SecurityFilterChainFactory factory) {
    
configuration.add(factory.createChain("/medicine/create").add(factory.roles(),"employee,
doctor").build()); 
}	

and

@RequiresRoles(value = {"doctor", "employee"})

None of them worked. :(
I wanted doctor and employee to access the page. But, with these code none
of them were working. 

--
View this message in context: http://tapestry.1045711.n5.nabble.com/shiro-tp5082018p5088642.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: shiro

Posted by Alejandro Scandroli <al...@gmail.com>.
Hi

1) I think the first issue could be that the "/index" URL is almost
never used. All the links to the Index.java page will be pointed to
"/".
You can try 2 things:
a) rewrite your rule like this:
configuration.add(factory.createChain("/").add(factory.authc()).build());

b) Add @RequiresAuthentication to your Index.java page

2) The first thing that comes to my mind is that (from the shire
documentation) Order Matters! URL path expressions are evaluated
against an incoming request in the order they are defined and the
FIRST MATCH WINS. So…. I'd have recommended that you rewrite your rule
like this:
	configuration.add(factory.createChain("/medicine/**").add(factory.roles(),"employee,
doctor").build());

But, that wouldn't work because our current RolesAuthorizationFilter
implementation works with "subject.hasAllRoles" which means that to
access "/medicine/" you'd have to be both and employe AND a doctor.

As a workaround you can write your own RolesAuthorizationFilter
version checking for "hasAnyRoles" instead of "hasAllRoles". I don't
know if there is any other option.

Cheers.
Alejandro.




On Sat, Dec 17, 2011 at 5:12 AM, csckid <te...@gmail.com> wrote:
> I wrote this following code to restrict the user from accessing certain
> pages. Problem is it isn't working correctly.
> configuration.add(factory.createChain("/index").add(factory.authc()).build());
> I wrote this code so that only authorized user view the page, But in my
> program everyone can view.
>
> configuration.add(factory.createChain("/medicine/**").add(factory.roles(),
> "employee").build());
> configuration.add(factory.createChain("/medicine/**").add(factory.roles(),
> "doctor").build());
> With this code employee cannot access tml file of medicine folder but doctor
> can. Why is this so?
>
> public static void
> contributeSecurityConfiguration(Configuration<SecurityFilterChain>
> configuration,
>                        SecurityFilterChainFactory factory) {
>
>
> configuration.add(factory.createChain("/signin").add(factory.anon()).build());
>
> configuration.add(factory.createChain("/index").add(factory.authc()).build());
>
>
> configuration.add(factory.createChain("/medicine/**").add(factory.roles(),
> "employee").build());
>
> configuration.add(factory.createChain("/prescription/**").add(factory.roles(),
> "doctor").build());
>
> configuration.add(factory.createChain("/medicine/**").add(factory.roles(),
> "doctor").build());
> }
>
>
> --
> View this message in context: http://tapestry.1045711.n5.nabble.com/shiro-tp5082018p5082018.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org