Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
atlas
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
dataplatform
atlas
Commits
01953121
Commit
01953121
authored
May 22, 2015
by
Suma Shivaprasad
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
https://github.com/hortonworks/metadata
into BUG_37105
parents
30ba5a0a
01eaf500
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
7 deletions
+24
-7
SecurityProperties.java
...g/apache/hadoop/metadata/security/SecurityProperties.java
+2
-1
MetadataAuthenticationFilter.java
...op/metadata/web/filters/MetadataAuthenticationFilter.java
+2
-2
LoginProcessor.java
.../apache/hadoop/metadata/web/listeners/LoginProcessor.java
+20
-4
No files found.
client/src/main/java/org/apache/hadoop/metadata/security/SecurityProperties.java
View file @
01953121
...
...
@@ -31,5 +31,6 @@ public interface SecurityProperties {
public
static
final
String
SERVER_CERT_PASSWORD_KEY
=
"password"
;
public
static
final
String
CLIENT_AUTH_KEY
=
"client.auth.enabled"
;
public
static
final
String
CERT_STORES_CREDENTIAL_PROVIDER_PATH
=
"cert.stores.credential.provider.path"
;
String
SSL_CLIENT_PROPERTIES
=
"ssl-client.xml"
;
public
static
final
String
SSL_CLIENT_PROPERTIES
=
"ssl-client.xml"
;
public
static
final
String
BIND_ADDRESS
=
"metadata.server.bind.address"
;
}
webapp/src/main/java/org/apache/hadoop/metadata/web/filters/MetadataAuthenticationFilter.java
View file @
01953121
...
...
@@ -21,6 +21,7 @@ package org.apache.hadoop.metadata.web.filters;
import
com.google.inject.Singleton
;
import
org.apache.commons.configuration.ConfigurationException
;
import
org.apache.commons.configuration.PropertiesConfiguration
;
import
org.apache.hadoop.metadata.security.SecurityProperties
;
import
org.apache.hadoop.metadata.PropertiesUtil
;
import
org.apache.hadoop.security.SecurityUtil
;
import
org.apache.hadoop.security.authentication.server.AuthenticationFilter
;
...
...
@@ -44,7 +45,6 @@ import java.util.Properties;
public
class
MetadataAuthenticationFilter
extends
AuthenticationFilter
{
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
MetadataAuthenticationFilter
.
class
);
static
final
String
PREFIX
=
"metadata.http.authentication."
;
static
final
String
BIND_ADDRESS
=
"metadata.server.bind.address"
;
@Override
protected
Properties
getConfiguration
(
String
configPrefix
,
FilterConfig
filterConfig
)
throws
ServletException
{
...
...
@@ -77,7 +77,7 @@ public class MetadataAuthenticationFilter extends AuthenticationFilter {
}
//Resolve _HOST into bind address
String
bindAddress
=
config
.
getProperty
(
BIND_ADDRESS
);
String
bindAddress
=
config
.
getProperty
(
SecurityProperties
.
BIND_ADDRESS
);
if
(
bindAddress
==
null
)
{
LOG
.
info
(
"No host name configured. Defaulting to local host name."
);
try
{
...
...
webapp/src/main/java/org/apache/hadoop/metadata/web/listeners/LoginProcessor.java
View file @
01953121
...
...
@@ -21,14 +21,17 @@ import org.apache.commons.configuration.PropertiesConfiguration;
import
org.apache.hadoop.conf.Configuration
;
import
org.apache.hadoop.metadata.MetadataException
;
import
org.apache.hadoop.metadata.PropertiesUtil
;
import
org.apache.hadoop.metadata.security.SecurityProperties
;
import
org.apache.hadoop.security.SecurityUtil
;
import
org.apache.hadoop.security.UserGroupInformation
;
import
org.apache.hadoop.util.Shell
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
javax.servlet.ServletException
;
import
java.io.IOException
;
import
java.net.InetAddress
;
import
java.net.UnknownHostException
;
/**
* A class capable of performing a simple or kerberos login.
...
...
@@ -73,17 +76,30 @@ public class LoginProcessor {
if
(
authenticationMethod
==
UserGroupInformation
.
AuthenticationMethod
.
SIMPLE
)
{
UserGroupInformation
.
loginUserFromSubject
(
null
);
}
else
if
(
authenticationMethod
==
UserGroupInformation
.
AuthenticationMethod
.
KERBEROS
)
{
String
bindAddress
=
getHostname
(
configuration
);
UserGroupInformation
.
loginUserFromKeytab
(
getServerPrincipal
(
configuration
.
getString
(
AUTHENTICATION_PRINCIPAL
)),
getServerPrincipal
(
configuration
.
getString
(
AUTHENTICATION_PRINCIPAL
)
,
bindAddress
),
configuration
.
getString
(
AUTHENTICATION_KEYTAB
));
}
LOG
.
info
(
"Logged in user {}"
,
UserGroupInformation
.
getLoginUser
());
}
catch
(
IOException
e
)
{
throw
new
IllegalStateException
(
String
.
format
(
"Unable to perform %s login."
,
authenticationMethod
),
e
);
}
}
private
String
getHostname
(
PropertiesConfiguration
configuration
)
{
String
bindAddress
=
configuration
.
getString
(
SecurityProperties
.
BIND_ADDRESS
);
if
(
bindAddress
==
null
)
{
LOG
.
info
(
"No host name configured. Defaulting to local host name."
);
try
{
bindAddress
=
InetAddress
.
getLocalHost
().
getHostName
();
}
catch
(
UnknownHostException
e
)
{
throw
new
IllegalStateException
(
e
);
}
}
return
bindAddress
;
}
protected
void
setupHadoopConfiguration
(
Configuration
hadoopConfig
,
PropertiesConfiguration
configuration
)
{
String
authMethod
;
authMethod
=
configuration
!=
null
?
configuration
.
getString
(
AUTHENTICATION_METHOD
)
:
null
;
...
...
@@ -104,8 +120,8 @@ public class LoginProcessor {
* @return the service principal.
* @throws IOException
*/
private
String
getServerPrincipal
(
String
principal
)
throws
IOException
{
return
SecurityUtil
.
getServerPrincipal
(
principal
,
InetAddress
.
getLocalHost
().
getHostName
()
);
private
String
getServerPrincipal
(
String
principal
,
String
host
)
throws
IOException
{
return
SecurityUtil
.
getServerPrincipal
(
principal
,
host
);
}
/**
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment