I haven't used Vaadin in a long time, cool project though!
Couple things that stick out at me:
1.) There are a couple community Vaadin plugins, i'm not sure if any of
them solve this problem though
2.) I'd be hesitant to allow multiple users to log in with different tabs
on the same browser. Unless your goal is do allow the same user access to
multiple account (i.e. what google does, I have multiple gmail windows open
right now, one is mail/u/0 the other is mail/u/1)
Assuming this is just for a single person with multiple accounts, you might
be able to get away with this with less code.
Possible just with a SessionManager. You would still need to pull out the
Vaadin ID from the request and munch it with the exiting browser session
As for SecurityUtils.getSubject(), that _should_ be handled for you, if
your SessionManager is working correctly the incoming request will be bound
with the current subject at the start of the request, and cleaned up at the
(the normal http session model goes out the window with async servlets, so
if that is your bag, you would also need to wrap the async bits in a
callable: https://shiro.apache.org/subject.html#thread-association (I have
some example code for this somewhere, but cannot find it at a glance)
Anyway, let us know if we can point you in more specific direction!
On Wed, Aug 9, 2017 at 3:53 AM, vpcoder <m.rells...@docu.com> wrote:
> Hi all,
> following situation in short: I'm using Shiro together with Vaadin. As
> Vaadin supports multiple tabs (each tab is a separate UI instance,
> independent from each other) in one browser session, I must to reproduce
> same behaviour in Shiro too. That means, I must manage a separate subject
> for each browser tab (different users logged into each tab).
> From Vaadin's UI instance (and of course from the http request paramters) ,
> I get a unique embedId to distinguish each tab. So, theoretical it should
> not be a problem to hold multiple independent subjects in one session.
> What I've done so far is extending SecurityManager, SubjectContext,
> SubjectDAO, Subject/-Factory. The idea at the end is, to not only handle
> keys DefaultSubjectContext.PRINCIPALS_SESSION_KEY and
> DefaultSubjectContext.AUTHENTICATED_SESSION_KEY for storing the subject's
> state in the session. Instead of this, I will create for each browser tab a
> new pair of these keys and adding the Vaadin's embedId to the key name. So
> have a separate principal key and authenticated key for each tab stored in
> the session.
> All this seems to work quite well when I debug, but the only thing I
> struggle a bit is the static SecurityUtils.getSubject(). This method always
> returns the Subject of the ThreadContext if it is already stored there. But
> exactly here, it should return a tab dependent Subject. Unfortunately, I
> can't extend the SecurityUtils, because it is static. Of course, I can
> my own util class for the tab related Subject. But the
> SecurityUtils.getSubject() is also used inside the Shiro framework and also
> in the Shiro extension package Pac4j which I use (SAML - stuff).
> Now I thought about extending my MultiTabSubject in such a way, that it
> holds the state of all Subjects of it's session and then decides which
> it should return when asking for principal and authenticated state. All the
> other Subject's properties should share the same states. That means, my own
> MultiTabSubject works like a decorator. But I'm not really sure, if this
> works without any problems together with the SecurityManager and all it's
> Does anyone of you has a better idea, how to do this? Or is this a
> approach at all? Thank you very much for any input.
> View this message in context: http://shiro-user.582556.n2.
> Sent from the Shiro User mailing list archive at Nabble.com.