Skip to content
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

Remove the authenticate token method from TokenManager and from the Subject interface #10614

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,11 @@

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.AuthenticationToken;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.opensearch.common.Randomness;
import org.opensearch.identity.IdentityService;
import org.opensearch.identity.Subject;
import org.opensearch.identity.noop.NoopSubject;
import org.opensearch.identity.tokens.AuthToken;
import org.opensearch.identity.tokens.BasicAuthToken;
import org.opensearch.identity.tokens.OnBehalfOfClaims;
Expand Down Expand Up @@ -88,20 +86,6 @@ public AuthToken issueServiceAccountToken(String audience) {
return token;
}

@Override
public Subject authenticateToken(AuthToken authToken) {
return new NoopSubject();
}

public boolean validateToken(AuthToken token) {
if (token instanceof BasicAuthToken) {
final BasicAuthToken basicAuthToken = (BasicAuthToken) token;
return basicAuthToken.getUser().equals(SecurityUtils.getSubject().toString())
&& basicAuthToken.getPassword().equals(shiroTokenPasswordMap.get(basicAuthToken));
}
return false;
}

public String getTokenInfo(AuthToken token) {
if (token instanceof BasicAuthToken) {
final BasicAuthToken basicAuthToken = (BasicAuthToken) token;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,6 @@ public void testShouldFailGetTokenInfo() {
assertThrows(UnsupportedAuthenticationToken.class, () -> shiroAuthTokenHandler.getTokenInfo(bearerAuthToken));
}

public void testShouldFailValidateToken() {
final BearerAuthToken bearerAuthToken = new BearerAuthToken("header.payload.signature");
assertFalse(shiroAuthTokenHandler.validateToken(bearerAuthToken));
}

public void testShoudPassMapLookupWithToken() {
final BasicAuthToken authToken = new BasicAuthToken("Basic dGVzdDp0ZTpzdA==");
shiroAuthTokenHandler.getShiroTokenPasswordMap().put(authToken, "te:st");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,4 @@ public String asAuthHeaderValue() {
}
};
}

@Override
public Subject authenticateToken(AuthToken authToken) {
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,4 @@ public interface TokenManager {
* @return a new auth token
*/
public AuthToken issueServiceAccountToken(final String audience);

/**
* Authenticates a provided authToken
* @param authToken: The authToken to authenticate
* @return The authenticated subject
*/
public Subject authenticateToken(AuthToken authToken);
stephen-crawford marked this conversation as resolved.
Show resolved Hide resolved
}
Loading