Skip to content

Commit

Permalink
Removed logout method
Browse files Browse the repository at this point in the history
Signed-off-by: Darshit Chanpura <[email protected]>
  • Loading branch information
DarshitChanpura committed Jan 4, 2023
1 parent 0be5ce3 commit 3153ba7
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,6 @@ public interface Subject {
*/
void login(final AuthenticationToken token);

/**
* Logs this subject out and kills any session associated with it
*/
void logout();

/**
* Checks the current authentication status of this subject
* @return true if authenticated, false otherwise
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import java.security.Principal;
import java.util.Objects;

import org.apache.shiro.session.Session;
import org.opensearch.authn.AuthenticationTokenHandler;
import org.opensearch.authn.tokens.AuthenticationToken;
import org.opensearch.authn.Subject;
Expand Down Expand Up @@ -80,26 +79,6 @@ public void login(AuthenticationToken authenticationToken) {
shiroSubject.login(authToken);
}

/**
* Logs out this subject
*
* TODO: test this method
*/
@Override
public void logout() {
try {
if (shiroSubject == null) return;
shiroSubject.logout();
// Get current session and kill it before proceeding to create a new session
// TODO: need to study the impact of this
Session session = shiroSubject.getSession(false);
if (session == null) return;
session.stop();
} catch (Exception e) {
// Ignore all errors, as we're trying to silently kill the session
}
}

/**
* A flag to indicate whether this subject is already authenticated
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,6 @@ public void login(AuthenticationToken authenticationToken) {
// Do nothing as noop subject is always logged in
}

@Override
public void logout() {
// Do nothing as noop subject should not be logged out
}

@Override
public boolean isAuthenticated() {
// Noop subject is always authenticated
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,6 @@ public void testSuccessfulLoginAndLogOut() {

internalSubject.login(AUTH_TOKEN);
assertTrue(internalSubject.isAuthenticated());

internalSubject.logout();
assertFalse(internalSubject.isAuthenticated());

// subsequent logout calls for same user does not fail
internalSubject.logout();
}

public void testLoginFailure() {
Expand Down

0 comments on commit 3153ba7

Please sign in to comment.