Re: Shiro: possible to configure part of the unauthenticated URLs to return 401 instead 302?

2024-02-09 Thread Steinar Bang
> Brian Demers : > That should work, keep us posted! Ok, 2 years, 8 weeks, and 5 days has passed, but now I finally got around to it, and I can report it worked perfectly: 1. User with the required role is logged in: a POST to the API gets 200 OK 2. User withot the required role is logged

Re: Shiro: possible to configure part of the unauthenticated URLs to return 401 instead 302?

2021-12-09 Thread Brian Demers
That should work, keep us posted! On Wed, Dec 8, 2021 at 11:37 AM Steinar Bang wrote: > > > Brian Demers : > > > Cookies will get processed, but if you are using some other form of > > header based auth they wouldn't be (unless you a corresponding filter > > configured) > > In this case I'm

Re: Shiro: possible to configure part of the unauthenticated URLs to return 401 instead 302?

2021-12-08 Thread Steinar Bang
> Brian Demers : > Cookies will get processed, but if you are using some other form of > header based auth they wouldn't be (unless you a corresponding filter > configured) In this case I'm thinking of what's set by the PassThruAuthenticationFilter when authenticating the frontend. Will

Re: Shiro: possible to configure part of the unauthenticated URLs to return 401 instead 302?

2021-12-08 Thread Brian Demers
Cookies will get processed, but if you are using some other form of header based auth they wouldn't be (unless you a corresponding filter configured) On Tue, Dec 7, 2021 at 5:04 PM Steinar Bang wrote: > > Question: > > when I do this: > > > [main] > > authc =

Re: Shiro: possible to configure part of the unauthenticated URLs to return 401 instead 302?

2021-12-07 Thread Steinar Bang
Question: when I do this: > [main] > authc = org.apache.shiro.web.filter.authc.PassThruAuthenticationFilter [snip!] > [urls] > /api/** = anon > /** = authc, role[myapprole] don't I then use a different filter than PassThruAuthenticationFilter for /api/? Can I do this and still use

Re: Shiro: possible to configure part of the unauthenticated URLs to return 401 instead 302?

2021-12-07 Thread Steinar Bang
> Brian Demers : > You can also use `@RequireRoles("myapprole")` annotation instead of > the permission one. > I think the problem you might be running into is the > `PassThruAuthenticationFilter` doesn't have a "permissive" option, so > it's likely redirecting on that fitler. Ok. I can't

Re: Shiro: possible to configure part of the unauthenticated URLs to return 401 instead 302?

2021-12-07 Thread Brian Demers
You can also use `@RequireRoles("myapprole")` annotation instead of the permission one. I think the problem you might be running into is the `PassThruAuthenticationFilter` doesn't have a "permissive" option, so it's likely redirecting on that fitler. To work around this, you could use the form

Re: Shiro: possible to configure part of the unauthenticated URLs to return 401 instead 302?

2021-12-07 Thread Steinar Bang
Side note: shiro-jaxrs and RequiresPermissions annotations may be a way to accomplish what I want to do. But what I really wanted was something simpler: avoid 302 redirects for the part of URL space used by ajax calls (since 302s are handled by the browser and never reach the ajax code waiting

Re: Shiro: possible to configure part of the unauthenticated URLs to return 401 instead 302?

2021-12-07 Thread Steinar Bang
> Brian Demers : > This post is a little old (dependency wise), but it should still be accurate. Hm... I'm on shiro-1.7.0 currently, so the mentioned shiro-jaxrs should be available...? (and currently on jersey 1.8.4, if that matters...?) > See the bit about the "permissive" filter. >

Re: Shiro: possible to configure part of the unauthenticated URLs to return 401 instead 302?

2021-12-06 Thread Brian Demers
This post is a little old (dependency wise), but it should still be accurate. See the bit about the "permissive" filter. https://stormpath.com/blog/protecting-jax-rs-resources-rbac-apache-shiro If you go this route, you will need to ensure you are checking access another way: annotation, another

Shiro: possible to configure part of the unauthenticated URLs to return 401 instead 302?

2021-12-06 Thread Steinar Bang
Is it possible to configure a part of the URL space to return 401 instead of 302 when unauthenticated? I would like to avoid 302 redirects for calls to the REST API. Thanks! - Steinar