Skip to content

Commit f49c17c

Browse files
committed
Added isRememberedAuthentication to SecuritySupport
Retrieves if a user has already logged in a previous session
1 parent 50e8b82 commit f49c17c

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

security/core/src/main/java/org/seedstack/seed/security/internal/ShiroSecuritySupport.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,13 @@ public SimplePrincipalProvider getSimplePrincipalByName(String principalName) {
8282
public boolean isAuthenticated() {
8383
return SecurityUtils.getSubject().isAuthenticated();
8484
}
85+
86+
@Override
87+
public boolean isRememberedAuthentication() {
88+
Subject subject = SecurityUtils.getSubject();
89+
return subject.isAuthenticated() || subject.isRemembered();
90+
}
91+
8592

8693
@Override
8794
public boolean isPermitted(String permission) {
@@ -246,4 +253,6 @@ public String getHost() {
246253
}
247254
return s.getHost();
248255
}
256+
257+
249258
}

security/specs/src/main/java/org/seedstack/seed/security/SecuritySupport.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,10 +235,21 @@ public interface SecuritySupport {
235235
/**
236236
* Check if the current user is authenticated.
237237
*
238+
* Authenticated on Shiro means that subject has successfully logged in on the current session
239+
* @see org.seedstack.seed.security.SecuritySupport#isRememberedAuthentication()
240+
*
238241
* @return true if authenticated, false otherwise.
239242
*/
240243
boolean isAuthenticated();
241244

245+
246+
/**
247+
* Checks if the current user has logged successfully on a previous session
248+
*
249+
* @return true if remembered, false otherwise.
250+
*/
251+
boolean isRememberedAuthentication();
252+
242253
/**
243254
* Returns the host name or IP string of the host of the connected user, or {@code null} if the host is unknown.
244255
*

0 commit comments

Comments
 (0)