Commit 77dd50c6 by nixonrodrigues Committed by Madhan Neethiraj

ATLAS-2352: add configuration to specify validity for authentication token

parent c35f82ca
......@@ -65,6 +65,7 @@ Also following properties should be set.
atlas.authentication.method.kerberos.principal=<principal>/<fqdn>@EXAMPLE.COM
atlas.authentication.method.kerberos.keytab = /<key tab filepath>.keytab
atlas.authentication.method.kerberos.name.rules = RULE:[2:$1@$0](atlas@EXAMPLE.COM)s/.*/atlas/
atlas.authentication.method.kerberos.token.validity = 3600 [ in Seconds (optional)]
</verbatim>
......
......@@ -83,6 +83,7 @@ import java.util.regex.Pattern;
public class AtlasAuthenticationFilter extends AuthenticationFilter {
private static final Logger LOG = LoggerFactory.getLogger(AtlasAuthenticationFilter.class);
private static final String CONFIG_KERBEROS_TOKEN_VALIDITY = "atlas.authentication.method.kerberos.token.validity";
private static final String CONFIG_PROXY_USERS = "atlas.proxyusers";
private static final String PREFIX = "atlas.authentication.method";
private static final String[] DEFAULT_PROXY_USERS = new String[] { "knox" };
......@@ -131,6 +132,22 @@ public class AtlasAuthenticationFilter extends AuthenticationFilter {
headerProperties = ConfigurationConverter.getProperties(configuration.subset("atlas.headers"));
}
String tokenValidityStr = configuration.getString(CONFIG_KERBEROS_TOKEN_VALIDITY);
if (StringUtils.isNotBlank(tokenValidityStr)) {
try {
Long tokenValidity = Long.parseLong(tokenValidityStr);
if (tokenValidity > 0) {
params.put(AuthenticationFilter.AUTH_TOKEN_VALIDITY, tokenValidity.toString());
} else {
throw new ServletException(tokenValidity + ": invalid value for property '" + CONFIG_KERBEROS_TOKEN_VALIDITY + "'. Must be a positive integer");
}
} catch (NumberFormatException e) {
throw new ServletException(tokenValidityStr + ": invalid value for property '" + CONFIG_KERBEROS_TOKEN_VALIDITY + "'. Must be a positive integer", e);
}
}
FilterConfig filterConfig1 = new FilterConfig() {
@Override
public ServletContext getServletContext() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment