-
Notifications
You must be signed in to change notification settings - Fork 6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Max Sessions on WebFlux #13752
Max Sessions on WebFlux #13752
Conversation
marcusdacoregio
commented
Aug 30, 2023
•
edited
Loading
edited
- Add Documentation for Max Sessions on WebFlux #13791
079f151
to
6da89ca
Compare
6da89ca
to
489b838
Compare
HI @marcusdacoregio Thanks for this. Can you please take it forward? |
Can't wait for this feature release in 6.2.0 |
Hi, @maradanasai. Unfortunately, this will not make it into the 6.2 release. I will try to get it added for the first milestone of 6.3 though. |
489b838
to
dca6941
Compare
c4ddb21
to
162fcfe
Compare
406b1cc
to
7154041
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great, @marcusdacoregio. Per your request, I've reviewed the following:
- Interface naming; I also took the liberty to comment on some class names
- DSL names and contracts
...k/security/web/server/authentication/session/PreventLoginMaximumSessionsExceededHandler.java
Outdated
Show resolved
Hide resolved
* @param maxSessions the {@link Function} to use | ||
* @return the {@link ConcurrentSessionsSpec} to continue customizing | ||
*/ | ||
public ConcurrentSessionsSpec maxSessions(Function<Authentication, Mono<Integer>> maxSessions) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having a Function
as an API can be a bit more challenging. Have you considered having two methods:
.maxSessions(Function)
.maxSessions(Integer)
In this way, folks can supply a global max, should that be preferred, in a way that is clearly correct.
} | ||
|
||
/** | ||
* Sets the {@link Function} to use to determine the maximum number of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not clear to me how I'd state that for some authentications, there is no maximum. For example, is it:
.maxSessions((authentication) -> containsSomeAuthority(authentication) ? Mono.just(Integer.MAX_VALUE) : Mono.just(3))
or something else?
(I can see in the reference that it is -1, but this may be value to place in the JavaDoc, too. Also, since it is a magic number, you might consider a static constant like UNLIMITED
. This adds clarity to the user's intent and it also gives you the ability to change that value in the future should it become necessary.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of the user dealing with magic numbers, I think it would be better to define a SessionLimit
POJO with a SessionLimit#of(int)
and SessionLimit#unlimited()
static factory methods to achieve a better declarative configuration.
In addition to that, there are now maximumSessions(SessionLimit)
and maximumSessions(Function<Authentication, Mono<SessionLimit>)
available.
.sessionManagement((sessionManagement) -> sessionManagement
.concurrentSessions((concurrentSessions) -> concurrentSessions
.maximumSessions(SessionLimit.of(1))
)
);
* @since 6.3 | ||
* @see AuthenticationWebFilter#setSessionAuthenticationStrategy(ServerSessionAuthenticationStrategy) | ||
*/ | ||
public interface ServerSessionAuthenticationStrategy { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if a new interface is necessary in this case since we already have ServerAuthenticationSuccessHandler
, whose method signature is the same.
It seems like the implementations could be added to a DelegatingServerAuthenticationSuccessHandler
instance. Do you try that already?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! I've changed the implementation to use the ServerAuthenticationSuccessHandler
instead of a new interface.
e26521d
to
df3d7fd
Compare
ddd0d82
to
e3d457d
Compare
75f880b
to
0d6ef5f
Compare