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
34f51a2a
Commit
34f51a2a
authored
9 years ago
by
Hemanth Yamijala
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ATLAS-661 REST API Authentication (nixonrodrigues via yhemanth)
parent
1ddf3137
Hide whitespace changes
Inline
Side-by-side
Showing
24 changed files
with
424 additions
and
201 deletions
+424
-201
HiveMetaStoreBridge.java
...ava/org/apache/atlas/hive/bridge/HiveMetaStoreBridge.java
+12
-2
AtlasAdminClient.java
client/src/main/java/org/apache/atlas/AtlasAdminClient.java
+10
-1
AtlasClient.java
client/src/main/java/org/apache/atlas/AtlasClient.java
+28
-4
AuthenticationUtil.java
.../main/java/org/apache/atlas/utils/AuthenticationUtil.java
+73
-0
Utils.js
dashboardv2/public/js/utils/Utils.js
+5
-24
users-credentials.properties
distro/src/conf/users-credentials.properties
+4
-3
release-log.txt
release-log.txt
+1
-0
QuickStart.java
...p/src/main/java/org/apache/atlas/examples/QuickStart.java
+25
-2
UserDao.java
webapp/src/main/java/org/apache/atlas/web/dao/UserDao.java
+54
-7
AtlasAuthenticationEntryPoint.java
...ache/atlas/web/filters/AtlasAuthenticationEntryPoint.java
+11
-5
AtlasADAuthenticationProvider.java
...che/atlas/web/security/AtlasADAuthenticationProvider.java
+6
-45
AtlasAbstractAuthenticationProvider.java
...las/web/security/AtlasAbstractAuthenticationProvider.java
+1
-1
AtlasAuthenticationProvider.java
...pache/atlas/web/security/AtlasAuthenticationProvider.java
+26
-7
AtlasFileAuthenticationProvider.java
...e/atlas/web/security/AtlasFileAuthenticationProvider.java
+8
-5
AtlasLdapAuthenticationProvider.java
...e/atlas/web/security/AtlasLdapAuthenticationProvider.java
+1
-6
atlas-admin-site.xml
webapp/src/main/resources/atlas-admin-site.xml
+10
-6
spring-security.xml
webapp/src/main/resources/spring-security.xml
+55
-58
web.xml
webapp/src/main/webapp/WEB-INF/web.xml
+10
-9
QuickStartIT.java
...src/test/java/org/apache/atlas/examples/QuickStartIT.java
+2
-1
BaseResourceIT.java
...t/java/org/apache/atlas/web/resources/BaseResourceIT.java
+7
-1
FileAuthenticationTest.java
...org/apache/atlas/web/security/FileAuthenticationTest.java
+56
-4
NegativeSSLAndKerberosTest.java
...apache/atlas/web/security/NegativeSSLAndKerberosTest.java
+6
-5
SSLAndKerberosTest.java
...ava/org/apache/atlas/web/security/SSLAndKerberosTest.java
+2
-1
UserDaoTest.java
.../test/java/org/apache/atlas/web/security/UserDaoTest.java
+11
-4
No files found.
addons/hive-bridge/src/main/java/org/apache/atlas/hive/bridge/HiveMetaStoreBridge.java
View file @
34f51a2a
...
@@ -32,6 +32,7 @@ import org.apache.atlas.typesystem.Struct;
...
@@ -32,6 +32,7 @@ import org.apache.atlas.typesystem.Struct;
import
org.apache.atlas.typesystem.json.InstanceSerialization
;
import
org.apache.atlas.typesystem.json.InstanceSerialization
;
import
org.apache.atlas.typesystem.json.TypesSerialization
;
import
org.apache.atlas.typesystem.json.TypesSerialization
;
import
org.apache.atlas.typesystem.persistence.Id
;
import
org.apache.atlas.typesystem.persistence.Id
;
import
org.apache.atlas.utils.AuthenticationUtil
;
import
org.apache.commons.configuration.Configuration
;
import
org.apache.commons.configuration.Configuration
;
import
org.apache.hadoop.hive.conf.HiveConf
;
import
org.apache.hadoop.hive.conf.HiveConf
;
import
org.apache.hadoop.hive.metastore.api.Database
;
import
org.apache.hadoop.hive.metastore.api.Database
;
...
@@ -43,12 +44,12 @@ import org.apache.hadoop.hive.metastore.api.hive_metastoreConstants;
...
@@ -43,12 +44,12 @@ import org.apache.hadoop.hive.metastore.api.hive_metastoreConstants;
import
org.apache.hadoop.hive.ql.metadata.Hive
;
import
org.apache.hadoop.hive.ql.metadata.Hive
;
import
org.apache.hadoop.hive.ql.metadata.HiveException
;
import
org.apache.hadoop.hive.ql.metadata.HiveException
;
import
org.apache.hadoop.hive.ql.metadata.Table
;
import
org.apache.hadoop.hive.ql.metadata.Table
;
import
org.apache.hadoop.security.UserGroupInformation
;
import
org.codehaus.jettison.json.JSONArray
;
import
org.codehaus.jettison.json.JSONArray
;
import
org.codehaus.jettison.json.JSONException
;
import
org.codehaus.jettison.json.JSONException
;
import
org.codehaus.jettison.json.JSONObject
;
import
org.codehaus.jettison.json.JSONObject
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.List
;
...
@@ -533,9 +534,18 @@ public class HiveMetaStoreBridge {
...
@@ -533,9 +534,18 @@ public class HiveMetaStoreBridge {
}
}
public
static
void
main
(
String
[]
argv
)
throws
Exception
{
public
static
void
main
(
String
[]
argv
)
throws
Exception
{
Configuration
atlasConf
=
ApplicationProperties
.
get
();
Configuration
atlasConf
=
ApplicationProperties
.
get
();
String
atlasEndpoint
=
atlasConf
.
getString
(
ATLAS_ENDPOINT
,
DEFAULT_DGI_URL
);
String
atlasEndpoint
=
atlasConf
.
getString
(
ATLAS_ENDPOINT
,
DEFAULT_DGI_URL
);
AtlasClient
atlasClient
=
new
AtlasClient
(
atlasEndpoint
);
AtlasClient
atlasClient
;
if
(!
AuthenticationUtil
.
isKerberosAuthicationEnabled
())
{
String
[]
basicAuthUsernamePassword
=
AuthenticationUtil
.
getBasicAuthenticationInput
();
atlasClient
=
new
AtlasClient
(
new
String
[]{
atlasEndpoint
},
basicAuthUsernamePassword
);
}
else
{
UserGroupInformation
ugi
=
UserGroupInformation
.
getCurrentUser
();
atlasClient
=
new
AtlasClient
(
ugi
,
ugi
.
getShortUserName
(),
atlasEndpoint
);
}
HiveMetaStoreBridge
hiveMetaStoreBridge
=
new
HiveMetaStoreBridge
(
new
HiveConf
(),
atlasClient
);
HiveMetaStoreBridge
hiveMetaStoreBridge
=
new
HiveMetaStoreBridge
(
new
HiveConf
(),
atlasClient
);
hiveMetaStoreBridge
.
registerHiveDataModel
();
hiveMetaStoreBridge
.
registerHiveDataModel
();
...
...
This diff is collapsed.
Click to expand it.
client/src/main/java/org/apache/atlas/AtlasAdminClient.java
View file @
34f51a2a
...
@@ -18,6 +18,7 @@
...
@@ -18,6 +18,7 @@
package
org
.
apache
.
atlas
;
package
org
.
apache
.
atlas
;
import
org.apache.atlas.utils.AuthenticationUtil
;
import
org.apache.commons.cli.CommandLine
;
import
org.apache.commons.cli.CommandLine
;
import
org.apache.commons.cli.CommandLineParser
;
import
org.apache.commons.cli.CommandLineParser
;
import
org.apache.commons.cli.GnuParser
;
import
org.apache.commons.cli.GnuParser
;
...
@@ -27,6 +28,7 @@ import org.apache.commons.cli.Options;
...
@@ -27,6 +28,7 @@ import org.apache.commons.cli.Options;
import
org.apache.commons.cli.ParseException
;
import
org.apache.commons.cli.ParseException
;
import
org.apache.commons.configuration.Configuration
;
import
org.apache.commons.configuration.Configuration
;
/**
/**
* An application that allows users to run admin commands against an Atlas server.
* An application that allows users to run admin commands against an Atlas server.
*
*
...
@@ -60,7 +62,14 @@ public class AtlasAdminClient {
...
@@ -60,7 +62,14 @@ public class AtlasAdminClient {
Configuration
configuration
=
ApplicationProperties
.
get
();
Configuration
configuration
=
ApplicationProperties
.
get
();
String
atlasServerUri
=
configuration
.
getString
(
String
atlasServerUri
=
configuration
.
getString
(
AtlasConstants
.
ATLAS_REST_ADDRESS_KEY
,
AtlasConstants
.
DEFAULT_ATLAS_REST_ADDRESS
);
AtlasConstants
.
ATLAS_REST_ADDRESS_KEY
,
AtlasConstants
.
DEFAULT_ATLAS_REST_ADDRESS
);
AtlasClient
atlasClient
=
new
AtlasClient
(
atlasServerUri
);
AtlasClient
atlasClient
=
null
;
if
(!
AuthenticationUtil
.
isKerberosAuthicationEnabled
())
{
String
[]
basicAuthUsernamePassword
=
AuthenticationUtil
.
getBasicAuthenticationInput
();
atlasClient
=
new
AtlasClient
(
new
String
[]{
atlasServerUri
},
basicAuthUsernamePassword
);
}
else
{
atlasClient
=
new
AtlasClient
(
atlasServerUri
,
null
,
null
);
}
return
handleCommand
(
commandLine
,
atlasServerUri
,
atlasClient
);
return
handleCommand
(
commandLine
,
atlasServerUri
,
atlasClient
);
}
}
...
...
This diff is collapsed.
Click to expand it.
client/src/main/java/org/apache/atlas/AtlasClient.java
View file @
34f51a2a
...
@@ -36,6 +36,7 @@ import org.apache.atlas.typesystem.types.AttributeDefinition;
...
@@ -36,6 +36,7 @@ import org.apache.atlas.typesystem.types.AttributeDefinition;
import
org.apache.atlas.typesystem.types.HierarchicalTypeDefinition
;
import
org.apache.atlas.typesystem.types.HierarchicalTypeDefinition
;
import
org.apache.atlas.typesystem.types.TraitType
;
import
org.apache.atlas.typesystem.types.TraitType
;
import
org.apache.atlas.typesystem.types.utils.TypesUtil
;
import
org.apache.atlas.typesystem.types.utils.TypesUtil
;
import
org.apache.atlas.utils.AuthenticationUtil
;
import
org.apache.commons.configuration.Configuration
;
import
org.apache.commons.configuration.Configuration
;
import
org.apache.commons.lang.StringUtils
;
import
org.apache.commons.lang.StringUtils
;
import
org.apache.hadoop.security.UserGroupInformation
;
import
org.apache.hadoop.security.UserGroupInformation
;
...
@@ -44,7 +45,6 @@ import org.codehaus.jettison.json.JSONException;
...
@@ -44,7 +45,6 @@ import org.codehaus.jettison.json.JSONException;
import
org.codehaus.jettison.json.JSONObject
;
import
org.codehaus.jettison.json.JSONObject
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
javax.ws.rs.HttpMethod
;
import
javax.ws.rs.HttpMethod
;
import
javax.ws.rs.core.MediaType
;
import
javax.ws.rs.core.MediaType
;
import
javax.ws.rs.core.Response
;
import
javax.ws.rs.core.Response
;
...
@@ -55,7 +55,7 @@ import java.util.ArrayList;
...
@@ -55,7 +55,7 @@ import java.util.ArrayList;
import
java.util.Arrays
;
import
java.util.Arrays
;
import
java.util.Collection
;
import
java.util.Collection
;
import
java.util.List
;
import
java.util.List
;
import
com.sun.jersey.api.client.filter.HTTPBasicAuthFilter
;
import
static
org
.
apache
.
atlas
.
security
.
SecurityProperties
.
TLS_ENABLED
;
import
static
org
.
apache
.
atlas
.
security
.
SecurityProperties
.
TLS_ENABLED
;
/**
/**
...
@@ -125,6 +125,16 @@ public class AtlasClient {
...
@@ -125,6 +125,16 @@ public class AtlasClient {
private
WebResource
service
;
private
WebResource
service
;
private
AtlasClientContext
atlasClientContext
;
private
AtlasClientContext
atlasClientContext
;
private
Configuration
configuration
;
private
Configuration
configuration
;
private
String
basicAuthUser
;
private
String
basicAuthPassword
;
// New constuctor for Basic auth
public
AtlasClient
(
String
[]
baseUrl
,
String
[]
basicAuthUserNamepassword
)
{
this
.
basicAuthUser
=
basicAuthUserNamepassword
[
0
];
this
.
basicAuthPassword
=
basicAuthUserNamepassword
[
1
];
initializeState
(
baseUrl
,
null
,
null
);
}
/**
/**
* Create a new Atlas client.
* Create a new Atlas client.
...
@@ -170,6 +180,12 @@ public class AtlasClient {
...
@@ -170,6 +180,12 @@ public class AtlasClient {
private
void
initializeState
(
String
[]
baseUrls
,
UserGroupInformation
ugi
,
String
doAsUser
)
{
private
void
initializeState
(
String
[]
baseUrls
,
UserGroupInformation
ugi
,
String
doAsUser
)
{
configuration
=
getClientProperties
();
configuration
=
getClientProperties
();
Client
client
=
getClient
(
configuration
,
ugi
,
doAsUser
);
Client
client
=
getClient
(
configuration
,
ugi
,
doAsUser
);
if
((!
AuthenticationUtil
.
isKerberosAuthicationEnabled
())
&&
basicAuthUser
!=
null
&&
basicAuthPassword
!=
null
)
{
final
HTTPBasicAuthFilter
authFilter
=
new
HTTPBasicAuthFilter
(
basicAuthUser
,
basicAuthPassword
);
client
.
addFilter
(
authFilter
);
}
String
activeServiceUrl
=
determineActiveServiceURL
(
baseUrls
,
client
);
String
activeServiceUrl
=
determineActiveServiceURL
(
baseUrls
,
client
);
atlasClientContext
=
new
AtlasClientContext
(
baseUrls
,
client
,
ugi
,
doAsUser
);
atlasClientContext
=
new
AtlasClientContext
(
baseUrls
,
client
,
ugi
,
doAsUser
);
service
=
client
.
resource
(
UriBuilder
.
fromUri
(
activeServiceUrl
).
build
());
service
=
client
.
resource
(
UriBuilder
.
fromUri
(
activeServiceUrl
).
build
());
...
@@ -195,9 +211,14 @@ public class AtlasClient {
...
@@ -195,9 +211,14 @@ public class AtlasClient {
LOG
.
info
(
"Error processing client configuration."
,
e
);
LOG
.
info
(
"Error processing client configuration."
,
e
);
}
}
URLConnectionClientHandler
handler
=
URLConnectionClientHandler
handler
=
null
;
SecureClientUtils
.
getClientConnectionHandler
(
config
,
clientConfig
,
doAsUser
,
ugi
);
if
((!
AuthenticationUtil
.
isKerberosAuthicationEnabled
())
&&
basicAuthUser
!=
null
&&
basicAuthPassword
!=
null
)
{
handler
=
new
URLConnectionClientHandler
();
}
else
{
handler
=
SecureClientUtils
.
getClientConnectionHandler
(
config
,
clientConfig
,
doAsUser
,
ugi
);
}
Client
client
=
new
Client
(
handler
,
config
);
Client
client
=
new
Client
(
handler
,
config
);
client
.
setReadTimeout
(
readTimeout
);
client
.
setReadTimeout
(
readTimeout
);
client
.
setConnectTimeout
(
connectTimeout
);
client
.
setConnectTimeout
(
connectTimeout
);
...
@@ -1049,6 +1070,8 @@ public class AtlasClient {
...
@@ -1049,6 +1070,8 @@ public class AtlasClient {
public
AtlasClientContext
(
String
[]
baseUrls
,
Client
client
,
UserGroupInformation
ugi
,
String
doAsUser
)
{
public
AtlasClientContext
(
String
[]
baseUrls
,
Client
client
,
UserGroupInformation
ugi
,
String
doAsUser
)
{
this
.
baseUrls
=
baseUrls
;
this
.
baseUrls
=
baseUrls
;
this
.
client
=
client
;
this
.
client
=
client
;
this
.
ugi
=
ugi
;
this
.
doAsUser
=
doAsUser
;
}
}
public
Client
getClient
()
{
public
Client
getClient
()
{
...
@@ -1068,4 +1091,5 @@ public class AtlasClient {
...
@@ -1068,4 +1091,5 @@ public class AtlasClient {
}
}
}
}
}
}
This diff is collapsed.
Click to expand it.
common/src/main/java/org/apache/atlas/utils/AuthenticationUtil.java
0 → 100644
View file @
34f51a2a
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org
.
apache
.
atlas
.
utils
;
import
org.apache.atlas.ApplicationProperties
;
import
org.apache.atlas.AtlasException
;
import
org.apache.commons.configuration.Configuration
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
java.io.BufferedReader
;
import
java.io.InputStreamReader
;
/**
* Util class for Authentication.
*/
public
final
class
AuthenticationUtil
{
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
AuthenticationUtil
.
class
);
private
AuthenticationUtil
()
{
}
public
static
boolean
isKerberosAuthicationEnabled
()
{
boolean
isKerberosAuthicationEnabled
=
false
;
try
{
Configuration
atlasConf
=
ApplicationProperties
.
get
();
if
(
"true"
.
equalsIgnoreCase
(
atlasConf
.
getString
(
"atlas.http.authentication.enabled"
))
&&
"kerberos"
.
equalsIgnoreCase
(
atlasConf
.
getString
(
"atlas.http.authentication.type"
)))
{
isKerberosAuthicationEnabled
=
true
;
}
else
{
isKerberosAuthicationEnabled
=
false
;
}
}
catch
(
AtlasException
e
)
{
LOG
.
error
(
"Error while isKerberosAuthicationEnabled "
,
e
);
}
return
isKerberosAuthicationEnabled
;
}
public
static
String
[]
getBasicAuthenticationInput
()
{
String
username
=
null
;
String
password
=
null
;
try
{
BufferedReader
bufferRead
=
new
BufferedReader
(
new
InputStreamReader
(
System
.
in
));
System
.
out
.
println
(
"Enter username for atlas :-"
);
username
=
bufferRead
.
readLine
();
System
.
out
.
println
(
"Enter password for atlas :-"
);
password
=
bufferRead
.
readLine
();
}
catch
(
Exception
e
)
{
System
.
out
.
print
(
"Error while reading "
);
System
.
exit
(
1
);
}
return
new
String
[]{
username
,
password
};
}
}
This diff is collapsed.
Click to expand it.
dashboardv2/public/js/utils/Utils.js
View file @
34f51a2a
...
@@ -74,31 +74,12 @@
...
@@ -74,31 +74,12 @@
});
});
};
};
Utils
.
defaultErrorHandler
=
function
(
model
,
error
)
{
Utils
.
defaultErrorHandler
=
function
(
model
,
error
)
{
/*
if
(
error
.
status
==
401
)
{
require(['views/common/ErrorView', 'App'], function(vError, App) {
window
.
location
=
'/login.jsp'
if (error.status == 404) {
}
else
if
(
error
.
status
==
419
)
{
App.rContent.show(new vError({
window
.
location
=
'/login.jsp'
status: error.status
}
}));
} else if (error.status == 401) {
App.rContent.show(new vError({
status: error.status
}));
} else if (error.status == 419) {
window.location = 'login.jsp'
} else if (error.status == "0") {
var diffTime = (new Date().getTime() - prevNetworkErrorTime);
if (diffTime > 3000) {
prevNetworkErrorTime = new Date().getTime();
Utils.notifyError({
content: "Network Connection Failure : " +
"It seems you are not connected to the internet. Please check your internet connection and try again"
})
}
}
});
*/
};
};
Utils
.
localStorage
=
{
Utils
.
localStorage
=
{
...
...
This diff is collapsed.
Click to expand it.
distro/src/conf/users-credentials.properties
View file @
34f51a2a
#username=password
#username=group::sha256-password
admin
=
admin
admin
=
ADMIN::8c6976e5b5410415bde908bd4dee15dfb167a9c873fc4bb8a81f6f2ab448a918
user
=
user123
michael
=
DATA_SCIENTIST::95bfb24de17d285d734b9eaa9109bfe922adc85f20d2e5e66a78bddb4a4ebddb
paul
=
DATA_STEWARD::e7c0dcf5f8a93e93791e9bac1ae454a691c1d2a902fc4256d489e96c1b9ac68c
This diff is collapsed.
Click to expand it.
release-log.txt
View file @
34f51a2a
...
@@ -3,6 +3,7 @@ Apache Atlas Release Notes
...
@@ -3,6 +3,7 @@ Apache Atlas Release Notes
--trunk - unreleased
--trunk - unreleased
INCOMPATIBLE CHANGES:
INCOMPATIBLE CHANGES:
ATLAS-661 REST API Authentication (nixonrodrigues via yhemanth)
ATLAS-672 UI: Make dashboard v2 the default UI implementation (bergenholtz via yhemanth)
ATLAS-672 UI: Make dashboard v2 the default UI implementation (bergenholtz via yhemanth)
ATLAS-532 Change Data types of all timestamps in Hive model(currently long)(sumasai via yhemanth)
ATLAS-532 Change Data types of all timestamps in Hive model(currently long)(sumasai via yhemanth)
ATLAS-622 Introduce soft delete (shwethags)
ATLAS-622 Introduce soft delete (shwethags)
...
...
This diff is collapsed.
Click to expand it.
webapp/src/main/java/org/apache/atlas/examples/QuickStart.java
View file @
34f51a2a
...
@@ -18,6 +18,7 @@
...
@@ -18,6 +18,7 @@
package
org
.
apache
.
atlas
.
examples
;
package
org
.
apache
.
atlas
.
examples
;
import
com.google.common.annotations.VisibleForTesting
;
import
com.google.common.base.Preconditions
;
import
com.google.common.base.Preconditions
;
import
com.google.common.collect.ImmutableList
;
import
com.google.common.collect.ImmutableList
;
import
com.google.common.collect.ImmutableSet
;
import
com.google.common.collect.ImmutableSet
;
...
@@ -39,9 +40,9 @@ import org.apache.atlas.typesystem.types.Multiplicity;
...
@@ -39,9 +40,9 @@ import org.apache.atlas.typesystem.types.Multiplicity;
import
org.apache.atlas.typesystem.types.StructTypeDefinition
;
import
org.apache.atlas.typesystem.types.StructTypeDefinition
;
import
org.apache.atlas.typesystem.types.TraitType
;
import
org.apache.atlas.typesystem.types.TraitType
;
import
org.apache.atlas.typesystem.types.utils.TypesUtil
;
import
org.apache.atlas.typesystem.types.utils.TypesUtil
;
import
org.apache.atlas.utils.AuthenticationUtil
;
import
org.apache.commons.configuration.Configuration
;
import
org.apache.commons.configuration.Configuration
;
import
org.codehaus.jettison.json.JSONArray
;
import
org.codehaus.jettison.json.JSONArray
;
import
java.util.List
;
import
java.util.List
;
/**
/**
...
@@ -70,8 +71,24 @@ public class QuickStart {
...
@@ -70,8 +71,24 @@ public class QuickStart {
public
static
final
String
INPUT_TABLES_ATTRIBUTE
=
"inputTables"
;
public
static
final
String
INPUT_TABLES_ATTRIBUTE
=
"inputTables"
;
public
static
void
main
(
String
[]
args
)
throws
Exception
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
String
[]
basicAuthUsernamePassword
=
null
;
if
(!
AuthenticationUtil
.
isKerberosAuthicationEnabled
())
{
basicAuthUsernamePassword
=
AuthenticationUtil
.
getBasicAuthenticationInput
();
}
runQuickstart
(
args
,
basicAuthUsernamePassword
);
}
@VisibleForTesting
static
void
runQuickstart
(
String
[]
args
,
String
[]
basicAuthUsernamePassword
)
throws
Exception
{
String
baseUrl
=
getServerUrl
(
args
);
String
baseUrl
=
getServerUrl
(
args
);
QuickStart
quickStart
=
new
QuickStart
(
baseUrl
);
QuickStart
quickStart
;
if
(!
AuthenticationUtil
.
isKerberosAuthicationEnabled
())
{
quickStart
=
new
QuickStart
(
baseUrl
,
basicAuthUsernamePassword
);
}
else
{
quickStart
=
new
QuickStart
(
baseUrl
);
}
// Shows how to create types in Atlas for your meta model
// Shows how to create types in Atlas for your meta model
quickStart
.
createTypes
();
quickStart
.
createTypes
();
...
@@ -111,11 +128,17 @@ public class QuickStart {
...
@@ -111,11 +128,17 @@ public class QuickStart {
private
final
AtlasClient
metadataServiceClient
;
private
final
AtlasClient
metadataServiceClient
;
QuickStart
(
String
baseUrl
,
String
[]
basicAuthUsernamePassword
)
{
String
[]
urls
=
baseUrl
.
split
(
","
);
metadataServiceClient
=
new
AtlasClient
(
urls
,
basicAuthUsernamePassword
);
}
QuickStart
(
String
baseUrl
)
throws
AtlasException
{
QuickStart
(
String
baseUrl
)
throws
AtlasException
{
String
[]
urls
=
baseUrl
.
split
(
","
);
String
[]
urls
=
baseUrl
.
split
(
","
);
metadataServiceClient
=
new
AtlasClient
(
urls
);
metadataServiceClient
=
new
AtlasClient
(
urls
);
}
}
void
createTypes
()
throws
Exception
{
void
createTypes
()
throws
Exception
{
TypesDef
typesDef
=
createTypeDefinitions
();
TypesDef
typesDef
=
createTypeDefinitions
();
...
...
This diff is collapsed.
Click to expand it.
webapp/src/main/java/org/apache/atlas/web/dao/UserDao.java
View file @
34f51a2a
...
@@ -20,8 +20,11 @@ package org.apache.atlas.web.dao;
...
@@ -20,8 +20,11 @@ package org.apache.atlas.web.dao;
import
com.google.common.annotations.VisibleForTesting
;
import
com.google.common.annotations.VisibleForTesting
;
import
java.io.FileInputStream
;
import
java.io.FileInputStream
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.Properties
;
import
java.util.Properties
;
import
java.util.List
;
import
javax.annotation.PostConstruct
;
import
javax.annotation.PostConstruct
;
import
org.apache.atlas.web.security.AtlasAuthenticationException
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.stereotype.Repository
;
import
org.springframework.stereotype.Repository
;
...
@@ -29,7 +32,13 @@ import org.apache.atlas.ApplicationProperties;
...
@@ -29,7 +32,13 @@ import org.apache.atlas.ApplicationProperties;
import
org.apache.atlas.AtlasException
;
import
org.apache.atlas.AtlasException
;
import
org.apache.atlas.web.model.User
;
import
org.apache.atlas.web.model.User
;
import
org.apache.commons.configuration.Configuration
;
import
org.apache.commons.configuration.Configuration
;
import
org.springframework.security.core.GrantedAuthority
;
import
org.springframework.security.core.authority.SimpleGrantedAuthority
;
import
org.springframework.security.core.userdetails.UsernameNotFoundException
;
import
org.springframework.security.core.userdetails.UsernameNotFoundException
;
import
java.security.MessageDigest
;
import
org.springframework.security.core.AuthenticationException
;
import
org.springframework.util.StringUtils
;
@Repository
@Repository
public
class
UserDao
{
public
class
UserDao
{
...
@@ -65,21 +74,59 @@ public class UserDao {
...
@@ -65,21 +74,59 @@ public class UserDao {
}
}
public
User
loadUserByUsername
(
final
String
username
)
public
User
loadUserByUsername
(
final
String
username
)
throws
UsernameNotFound
Exception
{
throws
Authentication
Exception
{
String
password
=
userLogins
.
getProperty
(
username
);
String
userdetailsStr
=
userLogins
.
getProperty
(
username
);
if
(
password
==
null
||
password
.
isEmpty
())
{
if
(
userdetailsStr
==
null
||
userdetailsStr
.
isEmpty
())
{
throw
new
UsernameNotFoundException
(
"Username not found."
throw
new
UsernameNotFoundException
(
"Username not found."
+
username
);
+
username
);
}
}
User
user
=
new
User
();
String
password
=
""
;
user
.
setUsername
(
username
);
String
role
=
""
;
user
.
setPassword
(
password
);
String
dataArr
[]
=
userdetailsStr
.
split
(
"::"
);
return
user
;
if
(
dataArr
!=
null
&&
dataArr
.
length
==
2
)
{
role
=
dataArr
[
0
];
password
=
dataArr
[
1
];
}
else
{
LOG
.
error
(
"User role credentials is not set properly for "
+
username
);
throw
new
AtlasAuthenticationException
(
"User role credentials is not set properly for "
+
username
);
}
List
<
GrantedAuthority
>
grantedAuths
=
new
ArrayList
<
GrantedAuthority
>();
if
(
StringUtils
.
hasText
(
role
))
{
grantedAuths
.
add
(
new
SimpleGrantedAuthority
(
role
));
}
else
{
LOG
.
error
(
"User role credentials is not set properly for "
+
username
);
throw
new
AtlasAuthenticationException
(
"User role credentials is not set properly for "
+
username
);
}
User
userDetails
=
new
User
(
username
,
password
,
grantedAuths
);
return
userDetails
;
}
}
@VisibleForTesting
@VisibleForTesting
public
void
setUserLogins
(
Properties
userLogins
)
{
public
void
setUserLogins
(
Properties
userLogins
)
{
this
.
userLogins
=
userLogins
;
this
.
userLogins
=
userLogins
;
}
}
public
static
String
getSha256Hash
(
String
base
)
throws
AtlasAuthenticationException
{
try
{
MessageDigest
digest
=
MessageDigest
.
getInstance
(
"SHA-256"
);
byte
[]
hash
=
digest
.
digest
(
base
.
getBytes
(
"UTF-8"
));
StringBuffer
hexString
=
new
StringBuffer
();
for
(
int
i
=
0
;
i
<
hash
.
length
;
i
++)
{
String
hex
=
Integer
.
toHexString
(
0xff
&
hash
[
i
]);
if
(
hex
.
length
()
==
1
)
hexString
.
append
(
'0'
);
hexString
.
append
(
hex
);
}
return
hexString
.
toString
();
}
catch
(
Exception
ex
)
{
throw
new
AtlasAuthenticationException
(
"Exception while encoding password."
,
ex
);
}
}
}
}
This diff is collapsed.
Click to expand it.
webapp/src/main/java/org/apache/atlas/web/filters/AtlasAuthenticationEntryPoint.java
View file @
34f51a2a
...
@@ -21,8 +21,6 @@ import java.io.IOException;
...
@@ -21,8 +21,6 @@ import java.io.IOException;
import
javax.servlet.ServletException
;
import
javax.servlet.ServletException
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpServletResponse
;
import
org.apache.atlas.Atlas
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.security.core.AuthenticationException
;
import
org.springframework.security.core.AuthenticationException
;
...
@@ -31,15 +29,23 @@ import org.springframework.security.web.authentication.LoginUrlAuthenticationEnt
...
@@ -31,15 +29,23 @@ import org.springframework.security.web.authentication.LoginUrlAuthenticationEnt
@SuppressWarnings
(
"deprecation"
)
@SuppressWarnings
(
"deprecation"
)
class
AtlasAuthenticationEntryPoint
extends
LoginUrlAuthenticationEntryPoint
{
class
AtlasAuthenticationEntryPoint
extends
LoginUrlAuthenticationEntryPoint
{
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
Atlas
.
class
);
private
static
final
Logger
LOG
=
LoggerFactory
.
getLogger
(
Atlas
AuthenticationEntryPoint
.
class
);
private
String
loginPath
=
"/login.jsp"
;
private
String
loginPath
=
"/login.jsp"
;
@Override
@Override
public
void
commence
(
HttpServletRequest
request
,
HttpServletResponse
response
,
AuthenticationException
authException
)
public
void
commence
(
HttpServletRequest
request
,
HttpServletResponse
response
,
AuthenticationException
authException
)
throws
IOException
,
ServletException
{
throws
IOException
,
ServletException
{
LOG
.
debug
(
"redirecting to login page loginPath"
+
loginPath
);
response
.
sendRedirect
(
loginPath
);
String
ajaxRequestHeader
=
request
.
getHeader
(
"X-Requested-With"
);
response
.
setHeader
(
"X-Frame-Options"
,
"DENY"
);
if
(
"XMLHttpRequest"
.
equals
(
ajaxRequestHeader
))
{
response
.
setStatus
(
HttpServletResponse
.
SC_UNAUTHORIZED
);
}
else
{
LOG
.
debug
(
"redirecting to login page loginPath"
+
loginPath
);
response
.
sendRedirect
(
loginPath
);
}
}
}
}
}
This diff is collapsed.
Click to expand it.
webapp/src/main/java/org/apache/atlas/web/security/AtlasADAuthenticationProvider.java
View file @
34f51a2a
...
@@ -25,16 +25,12 @@ import javax.annotation.PostConstruct;
...
@@ -25,16 +25,12 @@ import javax.annotation.PostConstruct;
import
org.apache.atlas.util.PropertiesUtil
;
import
org.apache.atlas.util.PropertiesUtil
;
import
org.apache.atlas.web.model.User
;
import
org.apache.atlas.web.model.User
;
import
org.apache.log4j.Logger
;
import
org.apache.log4j.Logger
;
import
org.springframework.ldap.core.support.LdapContextSource
;
import
org.springframework.security.authentication.UsernamePasswordAuthenticationToken
;
import
org.springframework.security.authentication.UsernamePasswordAuthenticationToken
;
import
org.springframework.security.core.Authentication
;
import
org.springframework.security.core.Authentication
;
import
org.springframework.security.core.AuthenticationException
;
import
org.springframework.security.core.AuthenticationException
;
import
org.springframework.security.core.GrantedAuthority
;
import
org.springframework.security.core.GrantedAuthority
;
import
org.springframework.security.core.userdetails.UserDetails
;
import
org.springframework.security.core.userdetails.UserDetails
;
import
org.springframework.security.ldap.DefaultSpringSecurityContextSource
;
import
org.springframework.security.ldap.authentication.ad.ActiveDirectoryLdapAuthenticationProvider
;
import
org.springframework.security.ldap.authentication.BindAuthenticator
;
import
org.springframework.security.ldap.authentication.LdapAuthenticationProvider
;
import
org.springframework.security.ldap.search.FilterBasedLdapUserSearch
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
@Component
@Component
...
@@ -44,6 +40,7 @@ public class AtlasADAuthenticationProvider extends
...
@@ -44,6 +40,7 @@ public class AtlasADAuthenticationProvider extends
.
getLogger
(
AtlasADAuthenticationProvider
.
class
);
.
getLogger
(
AtlasADAuthenticationProvider
.
class
);
private
String
adURL
;
private
String
adURL
;
private
String
adDomain
;
private
String
adBindDN
;
private
String
adBindDN
;
private
String
adBindPassword
;
private
String
adBindPassword
;
private
String
adUserSearchFilter
;
private
String
adUserSearchFilter
;
...
@@ -74,17 +71,10 @@ public class AtlasADAuthenticationProvider extends
...
@@ -74,17 +71,10 @@ public class AtlasADAuthenticationProvider extends
if
(
authentication
.
getCredentials
()
!=
null
)
{
if
(
authentication
.
getCredentials
()
!=
null
)
{
userPassword
=
authentication
.
getCredentials
().
toString
();
userPassword
=
authentication
.
getCredentials
().
toString
();
}
}
LdapContextSource
ldapContextSource
=
getLdapContextSource
();
if
(
adUserSearchFilter
==
null
ActiveDirectoryLdapAuthenticationProvider
adAuthenticationProvider
=
||
adUserSearchFilter
.
trim
().
isEmpty
())
{
new
ActiveDirectoryLdapAuthenticationProvider
(
adDomain
,
adURL
);
adUserSearchFilter
=
"(sAMAccountName={0})"
;
}
BindAuthenticator
bindAuthenticator
=
getBindAuthenticator
(
ldapContextSource
);
LdapAuthenticationProvider
ldapAuthenticationProvider
=
new
LdapAuthenticationProvider
(
bindAuthenticator
);
if
(
userName
!=
null
&&
userPassword
!=
null
if
(
userName
!=
null
&&
userPassword
!=
null
&&
!
userName
.
trim
().
isEmpty
()
&&
!
userName
.
trim
().
isEmpty
()
&&
!
userPassword
.
trim
().
isEmpty
())
{
&&
!
userPassword
.
trim
().
isEmpty
())
{
...
@@ -93,9 +83,7 @@ public class AtlasADAuthenticationProvider extends
...
@@ -93,9 +83,7 @@ public class AtlasADAuthenticationProvider extends
grantedAuths
);
grantedAuths
);
final
Authentication
finalAuthentication
=
new
UsernamePasswordAuthenticationToken
(
final
Authentication
finalAuthentication
=
new
UsernamePasswordAuthenticationToken
(
principal
,
userPassword
,
grantedAuths
);
principal
,
userPassword
,
grantedAuths
);
authentication
=
ldapAuthenticationProvider
authentication
=
adAuthenticationProvider
.
authenticate
(
finalAuthentication
);
.
authenticate
(
finalAuthentication
);
authentication
=
getAuthenticationWithGrantedAuthority
(
authentication
);
return
authentication
;
return
authentication
;
}
else
{
}
else
{
throw
new
AtlasAuthenticationException
(
throw
new
AtlasAuthenticationException
(
...
@@ -109,6 +97,7 @@ public class AtlasADAuthenticationProvider extends
...
@@ -109,6 +97,7 @@ public class AtlasADAuthenticationProvider extends
}
}
private
void
setADProperties
()
{
private
void
setADProperties
()
{
adDomain
=
PropertiesUtil
.
getProperty
(
"atlas.ad.domain"
,
adDomain
);
adURL
=
PropertiesUtil
.
getProperty
(
"atlas.ad.url"
,
adURL
);
adURL
=
PropertiesUtil
.
getProperty
(
"atlas.ad.url"
,
adURL
);
adBindDN
=
PropertiesUtil
.
getProperty
(
"atlas.ad.bind.dn"
,
adBindDN
);
adBindDN
=
PropertiesUtil
.
getProperty
(
"atlas.ad.bind.dn"
,
adBindDN
);
adBindPassword
=
PropertiesUtil
.
getProperty
(
"atlas.ad.bind.password"
,
adBindPassword
=
PropertiesUtil
.
getProperty
(
"atlas.ad.bind.password"
,
...
@@ -122,32 +111,4 @@ public class AtlasADAuthenticationProvider extends
...
@@ -122,32 +111,4 @@ public class AtlasADAuthenticationProvider extends
adDefaultRole
);
adDefaultRole
);
}
}
private
LdapContextSource
getLdapContextSource
()
throws
Exception
{
LdapContextSource
ldapContextSource
=
new
DefaultSpringSecurityContextSource
(
adURL
);
ldapContextSource
.
setUserDn
(
adBindDN
);
ldapContextSource
.
setPassword
(
adBindPassword
);
ldapContextSource
.
setReferral
(
adReferral
);
ldapContextSource
.
setCacheEnvironmentProperties
(
true
);
ldapContextSource
.
setAnonymousReadOnly
(
false
);
ldapContextSource
.
setPooled
(
true
);
ldapContextSource
.
afterPropertiesSet
();
return
ldapContextSource
;
}
private
BindAuthenticator
getBindAuthenticator
(
LdapContextSource
ldapContextSource
)
throws
Exception
{
FilterBasedLdapUserSearch
userSearch
=
new
FilterBasedLdapUserSearch
(
adBase
,
adUserSearchFilter
,
ldapContextSource
);
userSearch
.
setSearchSubtree
(
true
);
BindAuthenticator
bindAuthenticator
=
new
BindAuthenticator
(
ldapContextSource
);
bindAuthenticator
.
setUserSearch
(
userSearch
);
bindAuthenticator
.
afterPropertiesSet
();
return
bindAuthenticator
;
}
}
}
This diff is collapsed.
Click to expand it.
webapp/src/main/java/org/apache/atlas/web/security/AtlasAbstractAuthenticationProvider.java
View file @
34f51a2a
...
@@ -67,7 +67,7 @@ public abstract class AtlasAbstractAuthenticationProvider implements
...
@@ -67,7 +67,7 @@ public abstract class AtlasAbstractAuthenticationProvider implements
*/
*/
protected
List
<
GrantedAuthority
>
getAuthorities
(
String
username
)
{
protected
List
<
GrantedAuthority
>
getAuthorities
(
String
username
)
{
final
List
<
GrantedAuthority
>
grantedAuths
=
new
ArrayList
<
GrantedAuthority
>();
final
List
<
GrantedAuthority
>
grantedAuths
=
new
ArrayList
<
GrantedAuthority
>();
grantedAuths
.
add
(
new
SimpleGrantedAuthority
(
"
ROLE_USER
"
));
grantedAuths
.
add
(
new
SimpleGrantedAuthority
(
"
DATA_SCIENTIST
"
));
return
grantedAuths
;
return
grantedAuths
;
}
}
...
...
This diff is collapsed.
Click to expand it.
webapp/src/main/java/org/apache/atlas/web/security/AtlasAuthenticationProvider.java
View file @
34f51a2a
...
@@ -18,6 +18,7 @@
...
@@ -18,6 +18,7 @@
package
org
.
apache
.
atlas
.
web
.
security
;
package
org
.
apache
.
atlas
.
web
.
security
;
import
javax.annotation.PostConstruct
;
import
javax.annotation.PostConstruct
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
@@ -70,12 +71,20 @@ public class AtlasAuthenticationProvider extends
...
@@ -70,12 +71,20 @@ public class AtlasAuthenticationProvider extends
.
authenticate
(
authentication
);
.
authenticate
(
authentication
);
}
else
if
(
atlasAuthenticationMethod
.
equalsIgnoreCase
(
AUTH_METHOD
.
LDAP
}
else
if
(
atlasAuthenticationMethod
.
equalsIgnoreCase
(
AUTH_METHOD
.
LDAP
.
name
()))
{
.
name
()))
{
authentication
=
ldapAuthenticationProvider
try
{
.
authenticate
(
authentication
);
authentication
=
ldapAuthenticationProvider
.
authenticate
(
authentication
);
}
catch
(
Exception
ex
)
{
LOG
.
error
(
"Error while LDAP authentication"
,
ex
);
}
}
else
if
(
atlasAuthenticationMethod
.
equalsIgnoreCase
(
AUTH_METHOD
.
AD
}
else
if
(
atlasAuthenticationMethod
.
equalsIgnoreCase
(
AUTH_METHOD
.
AD
.
name
()))
{
.
name
()))
{
authentication
=
adAuthenticationProvider
try
{
.
authenticate
(
authentication
);
authentication
=
adAuthenticationProvider
.
authenticate
(
authentication
);
}
catch
(
Exception
ex
)
{
LOG
.
error
(
"Error while AD authentication"
,
ex
);
}
}
else
{
}
else
{
LOG
.
error
(
"Invalid authentication method :"
LOG
.
error
(
"Invalid authentication method :"
+
atlasAuthenticationMethod
);
+
atlasAuthenticationMethod
);
...
@@ -84,10 +93,20 @@ public class AtlasAuthenticationProvider extends
...
@@ -84,10 +93,20 @@ public class AtlasAuthenticationProvider extends
if
(
authentication
!=
null
&&
authentication
.
isAuthenticated
())
{
if
(
authentication
!=
null
&&
authentication
.
isAuthenticated
())
{
return
authentication
;
return
authentication
;
}
else
{
}
else
{
LOG
.
error
(
"Authentication failed."
);
// If the LDAP/AD authentication fails try the local file login method
throw
new
AtlasAuthenticationException
(
"Authentication failed."
);
if
(
atlasAuthenticationMethod
.
equalsIgnoreCase
(
AUTH_METHOD
.
AD
.
name
())
||
atlasAuthenticationMethod
.
equalsIgnoreCase
(
AUTH_METHOD
.
LDAP
.
name
()))
{
authentication
=
fileAuthenticationProvider
.
authenticate
(
authentication
);
}
if
(
authentication
!=
null
&&
authentication
.
isAuthenticated
())
{
return
authentication
;
}
else
{
LOG
.
error
(
"Authentication failed."
);
throw
new
AtlasAuthenticationException
(
"Authentication failed."
);
}
}
}
}
}
}
}
This diff is collapsed.
Click to expand it.
webapp/src/main/java/org/apache/atlas/web/security/AtlasFileAuthenticationProvider.java
View file @
34f51a2a
...
@@ -18,6 +18,7 @@ package org.apache.atlas.web.security;
...
@@ -18,6 +18,7 @@ package org.apache.atlas.web.security;
import
java.util.Collection
;
import
java.util.Collection
;
import
org.apache.atlas.web.dao.UserDao
;
import
org.apache.log4j.Logger
;
import
org.apache.log4j.Logger
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.security.authentication.BadCredentialsException
;
import
org.springframework.security.authentication.BadCredentialsException
;
...
@@ -28,6 +29,7 @@ import org.springframework.security.core.GrantedAuthority;
...
@@ -28,6 +29,7 @@ import org.springframework.security.core.GrantedAuthority;
import
org.springframework.security.core.userdetails.UserDetails
;
import
org.springframework.security.core.userdetails.UserDetails
;
import
org.springframework.security.core.userdetails.UserDetailsService
;
import
org.springframework.security.core.userdetails.UserDetailsService
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
@Component
@Component
public
class
AtlasFileAuthenticationProvider
extends
AtlasAbstractAuthenticationProvider
{
public
class
AtlasFileAuthenticationProvider
extends
AtlasAbstractAuthenticationProvider
{
...
@@ -46,6 +48,7 @@ public class AtlasFileAuthenticationProvider extends AtlasAbstractAuthentication
...
@@ -46,6 +48,7 @@ public class AtlasFileAuthenticationProvider extends AtlasAbstractAuthentication
throw
new
BadCredentialsException
(
throw
new
BadCredentialsException
(
"Username can't be null or empty."
);
"Username can't be null or empty."
);
}
}
if
(
password
==
null
||
password
.
isEmpty
())
{
if
(
password
==
null
||
password
.
isEmpty
())
{
logger
.
error
(
"Password can't be null or empty."
);
logger
.
error
(
"Password can't be null or empty."
);
throw
new
BadCredentialsException
(
throw
new
BadCredentialsException
(
...
@@ -53,16 +56,16 @@ public class AtlasFileAuthenticationProvider extends AtlasAbstractAuthentication
...
@@ -53,16 +56,16 @@ public class AtlasFileAuthenticationProvider extends AtlasAbstractAuthentication
}
}
UserDetails
user
=
userDetailsService
.
loadUserByUsername
(
username
);
UserDetails
user
=
userDetailsService
.
loadUserByUsername
(
username
);
if
(!
password
.
equals
(
user
.
getPassword
()))
{
String
encodedPassword
=
UserDao
.
getSha256Hash
(
password
);
if
(!
encodedPassword
.
equals
(
user
.
getPassword
()))
{
logger
.
error
(
"Wrong password "
+
username
);
logger
.
error
(
"Wrong password "
+
username
);
throw
new
BadCredentialsException
(
"Wrong password"
);
throw
new
BadCredentialsException
(
"Wrong password"
);
}
}
Collection
<?
extends
GrantedAuthority
>
authorities
=
getAuthorities
(
username
);
Collection
<?
extends
GrantedAuthority
>
authorities
=
user
.
getAuthorities
(
);
authentication
=
new
UsernamePasswordAuthenticationToken
(
username
,
password
,
authorities
);
authentication
=
new
UsernamePasswordAuthenticationToken
(
username
,
password
,
authorities
);
authentication
=
getAuthenticationWithGrantedAuthority
(
authentication
);
return
authentication
;
return
authentication
;
}
}
...
...
This diff is collapsed.
Click to expand it.
webapp/src/main/java/org/apache/atlas/web/security/AtlasLdapAuthenticationProvider.java
View file @
34f51a2a
...
@@ -19,9 +19,7 @@
...
@@ -19,9 +19,7 @@
package
org
.
apache
.
atlas
.
web
.
security
;
package
org
.
apache
.
atlas
.
web
.
security
;
import
java.util.List
;
import
java.util.List
;
import
javax.annotation.PostConstruct
;
import
javax.annotation.PostConstruct
;
import
org.apache.atlas.util.PropertiesUtil
;
import
org.apache.atlas.util.PropertiesUtil
;
import
org.apache.atlas.web.model.User
;
import
org.apache.atlas.web.model.User
;
import
org.apache.log4j.Logger
;
import
org.apache.log4j.Logger
;
...
@@ -107,9 +105,7 @@ public class AtlasLdapAuthenticationProvider extends
...
@@ -107,9 +105,7 @@ public class AtlasLdapAuthenticationProvider extends
grantedAuths
);
grantedAuths
);
final
Authentication
finalAuthentication
=
new
UsernamePasswordAuthenticationToken
(
final
Authentication
finalAuthentication
=
new
UsernamePasswordAuthenticationToken
(
principal
,
userPassword
,
grantedAuths
);
principal
,
userPassword
,
grantedAuths
);
authentication
=
ldapAuthenticationProvider
authentication
=
ldapAuthenticationProvider
.
authenticate
(
finalAuthentication
);
.
authenticate
(
finalAuthentication
);
authentication
=
getAuthenticationWithGrantedAuthority
(
authentication
);
return
authentication
;
return
authentication
;
}
else
{
}
else
{
throw
new
AtlasAuthenticationException
(
throw
new
AtlasAuthenticationException
(
...
@@ -168,7 +164,6 @@ public class AtlasLdapAuthenticationProvider extends
...
@@ -168,7 +164,6 @@ public class AtlasLdapAuthenticationProvider extends
defaultLdapAuthoritiesPopulator
defaultLdapAuthoritiesPopulator
.
setGroupSearchFilter
(
ldapGroupSearchFilter
);
.
setGroupSearchFilter
(
ldapGroupSearchFilter
);
defaultLdapAuthoritiesPopulator
.
setIgnorePartialResultException
(
true
);
defaultLdapAuthoritiesPopulator
.
setIgnorePartialResultException
(
true
);
return
defaultLdapAuthoritiesPopulator
;
return
defaultLdapAuthoritiesPopulator
;
}
}
...
...
This diff is collapsed.
Click to expand it.
webapp/src/main/resources/atlas-admin-site.xml
View file @
34f51a2a
...
@@ -34,7 +34,7 @@
...
@@ -34,7 +34,7 @@
<property>
<property>
<name>
atlas.ldap.group.searchfilter
</name>
<name>
atlas.ldap.group.searchfilter
</name>
<display-name>
Group Search Filter
</display-name>
<display-name>
Group Search Filter
</display-name>
<value>
(member=uid={0},ou=
People
,dc=example,dc=com)
<value>
(member=uid={0},ou=
Users
,dc=example,dc=com)
</value>
</value>
<description></description>
<description></description>
</property>
</property>
...
@@ -91,18 +91,22 @@
...
@@ -91,18 +91,22 @@
<!-- #AD info start -->
<!-- #AD info start -->
<property>
<property>
<name>
atlas.ad.url
</name>
<name>
atlas.ad.url
</name>
<value>
ldap://1
72.25.16.111
:389
</value>
<value>
ldap://1
3.76.128.185
:389
</value>
<description></description>
<description></description>
</property>
</property>
<property>
<name>
atlas.ad.domain
</name>
<value>
example.com
</value>
<description>
Ad Domain
</description>
</property>
<property>
<property>
<name>
atlas.ad.bind.dn
</name>
<name>
atlas.ad.bind.dn
</name>
<value>
CN=
team,CN=Users,DC=SME,DC=support
,DC=com
</value>
<value>
CN=
adadmin admin,CN=Users,DC=example
,DC=com
</value>
<description>
AD bind dn or manager dn
</description>
<description>
AD bind dn or manager dn
</description>
</property>
</property>
<property>
<property>
<name>
atlas.ad.bind.password
</name>
<name>
atlas.ad.bind.password
</name>
<value>
Abcd1234!!
</value>
<value>
p@ssword
</value>
<description>
AD bind password
</description>
<description>
AD bind password
</description>
</property>
</property>
<property>
<property>
...
@@ -113,7 +117,7 @@
...
@@ -113,7 +117,7 @@
</property>
</property>
<property>
<property>
<name>
atlas.ad.base.dn
</name>
<name>
atlas.ad.base.dn
</name>
<value>
DC=SME,DC=support,DC
=com
</value>
<value>
dc=example,dc
=com
</value>
<description>
AD base dn or search base
</description>
<description>
AD base dn or search base
</description>
</property>
</property>
<property>
<property>
...
...
This diff is collapsed.
Click to expand it.
webapp/src/main/resources/spring-security.xml
View file @
34f51a2a
...
@@ -11,13 +11,13 @@
...
@@ -11,13 +11,13 @@
language governing permissions and limitations under the License. -->
language governing permissions and limitations under the License. -->
<beans:beans
xmlns=
"http://www.springframework.org/schema/security"
<beans:beans
xmlns=
"http://www.springframework.org/schema/security"
xmlns:beans=
"http://www.springframework.org/schema/beans"
xmlns:beans=
"http://www.springframework.org/schema/beans"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xmlns:security=
"http://www.springframework.org/schema/security"
xmlns:security=
"http://www.springframework.org/schema/security"
xmlns:util=
"http://www.springframework.org/schema/util"
xmlns:util=
"http://www.springframework.org/schema/util"
xmlns:oauth=
"http://www.springframework.org/schema/security/oauth2"
xmlns:oauth=
"http://www.springframework.org/schema/security/oauth2"
xmlns:context=
"http://www.springframework.org/schema/context"
xmlns:context=
"http://www.springframework.org/schema/context"
xsi:schemaLocation=
"http://www.springframework.org/schema/beans
xsi:schemaLocation=
"http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security-3.1.xsd
http://www.springframework.org/schema/security/spring-security-3.1.xsd
...
@@ -28,65 +28,62 @@
...
@@ -28,65 +28,62 @@
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.1.xsd"
>
http://www.springframework.org/schema/context/spring-context-3.1.xsd"
>
<security:http
pattern=
"/login.jsp"
security=
"none"
/>
<security:http
pattern=
"/login.jsp"
security=
"none"
/>
<security:http
pattern=
"/css/**"
security=
"none"
/>
<security:http
pattern=
"/css/**"
security=
"none"
/>
<security:http
pattern=
"/lib/**"
security=
"none"
/>
<security:http
pattern=
"/lib/**"
security=
"none"
/>
<security:http
disable-url-rewriting=
"true"
<security:http
disable-url-rewriting=
"true"
use-expressions=
"true"
create-session=
"always"
use-expressions=
"true"
create-session=
"always"
entry-point-ref=
"authenticationProcessingFilterEntryPoint"
>
entry-point-ref=
"entryPoint"
>
<security:session-management
<security:session-management
session-fixation-protection=
"newSession"
/>
session-fixation-protection=
"newSession"
/>
<intercept-url
pattern=
"/**"
access=
"isAuthenticated()"
/>
<intercept-url
pattern=
"/**"
access=
"isAuthenticated()"
/>
<security:custom-filter
position=
"FORM_LOGIN_FILTER"
ref=
"atlasUsernamePasswordAuthenticationFilter"
/>
<security:logout
delete-cookies=
"JSESSIONID"
logout-url=
"/logout.html"
/>
<http-basic
entry-point-ref=
"authenticationProcessingFilterEntryPoint"
/>
</security:http>
<beans:bean
id=
"atlasUsernamePasswordAuthenticationFilter"
<form-login
class=
"org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter"
>
login-page=
"/login.jsp"
<beans:property
name=
"authenticationManager"
default-target-url=
"/index.html"
ref=
"authenticationManager"
/>
authentication-failure-url=
"/login.jsp?error=true"
<beans:property
name=
"authenticationSuccessHandler"
username-parameter=
"j_username"
ref=
"ajaxAuthSuccessHandler"
/>
password-parameter=
"j_password"
/>
<beans:property
name=
"authenticationFailureHandler"
ref=
"ajaxAuthFailureHandler"
/>
</beans:bean>
<beans:bean
id=
"authenticationProcessingFilterEntryPoint"
<security:logout
logout-success-url=
"/login.jsp"
delete-cookies=
"JSESSIONID"
logout-url=
"/logout.html"
/>
<http-basic
/>
</security:http>
<beans:bean
id=
"formAuthenticationEntryPoint"
class=
"org.apache.atlas.web.filters.AtlasAuthenticationEntryPoint"
>
class=
"org.apache.atlas.web.filters.AtlasAuthenticationEntryPoint"
>
<beans:property
name=
"loginFormUrl"
<beans:property
name=
"loginFormUrl"
value=
"/login.jsp"
/>
value=
"/login.jsp"
/>
</beans:bean>
<beans:property
name=
"forceHttps"
value=
"false"
/>
</beans:bean>
<beans:bean
id=
"authenticationEntryPoint"
class=
"org.springframework.security.web.authentication.www.BasicAuthenticationEntryPoint"
>
<beans:property
name=
"realmName"
value=
"atlas.com"
/>
</beans:bean>
<beans:bean
id=
"ajaxAuthSuccessHandler"
<beans:bean
id=
"entryPoint"
class=
"org.springframework.security.web.authentication.DelegatingAuthenticationEntryPoint"
>
class=
"org.springframework.security.web.authentication.SimpleUrlAuthenticationSuccessHandler"
>
<beans:constructor-arg>
<beans:property
name=
"defaultTargetUrl"
<beans:map>
value=
"/index.html"
/>
<beans:entry
key=
"hasHeader('User-Agent','Mozilla')"
value-ref=
"formAuthenticationEntryPoint"
/>
</beans:bean>
</beans:map>
</beans:constructor-arg>
<beans:property
name=
"defaultEntryPoint"
ref=
"authenticationEntryPoint"
/>
</beans:bean>
<beans:bean
id=
"ajaxAuthFailureHandler"
class=
"org.springframework.security.web.authentication.SimpleUrlAuthenticationFailureHandler"
>
<beans:property
name=
"defaultFailureUrl"
value=
"/login.jsp?login_error=true "
/>
</beans:bean>
<beans:bean
id=
"atlasAuthenticationProvider"
<beans:bean
id=
"atlasAuthenticationProvider"
class=
"org.apache.atlas.web.security.AtlasAuthenticationProvider"
>
class=
"org.apache.atlas.web.security.AtlasAuthenticationProvider"
>
</beans:bean>
</beans:bean>
<security:authentication-manager
alias=
"authenticationManager"
>
<security:authentication-provider
ref=
"atlasAuthenticationProvider"
/>
</security:authentication-manager>
<security:authentication-manager
<security:global-method-security
alias=
"authenticationManager"
>
pre-post-annotations=
"enabled"
/>
<security:authentication-provider
ref=
"atlasAuthenticationProvider"
/>
</security:authentication-manager>
<security:global-method-security
<context:component-scan
base-package=
"org.apache.atlas.web"
/>
pre-post-annotations=
"enabled"
/>
<context:component-scan
base-package=
"org.apache.atlas.web"
/>
</beans:beans>
</beans:beans>
This diff is collapsed.
Click to expand it.
webapp/src/main/webapp/WEB-INF/web.xml
View file @
34f51a2a
...
@@ -38,6 +38,16 @@
...
@@ -38,6 +38,16 @@
-->
-->
<filter>
<filter>
<filter-name>
springSecurityFilterChain
</filter-name>
<filter-class>
org.springframework.web.filter.DelegatingFilterProxy
</filter-class>
</filter>
<filter-mapping>
<filter-name>
springSecurityFilterChain
</filter-name>
<url-pattern>
/*
</url-pattern>
</filter-mapping>
<filter>
<filter-name>
guiceFilter
</filter-name>
<filter-name>
guiceFilter
</filter-name>
<filter-class>
com.google.inject.servlet.GuiceFilter
</filter-class>
<filter-class>
com.google.inject.servlet.GuiceFilter
</filter-class>
</filter>
</filter>
...
@@ -63,14 +73,6 @@
...
@@ -63,14 +73,6 @@
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
</listener>
<filter>
<filter-name>
springSecurityFilterChain
</filter-name>
<filter-class>
org.springframework.web.filter.DelegatingFilterProxy
</filter-class>
</filter>
<filter-mapping>
<filter-name>
springSecurityFilterChain
</filter-name>
<url-pattern>
/*
</url-pattern>
</filter-mapping>
</web-app>
</web-app>
\ No newline at end of file
This diff is collapsed.
Click to expand it.
webapp/src/test/java/org/apache/atlas/examples/QuickStartIT.java
View file @
34f51a2a
...
@@ -39,7 +39,8 @@ public class QuickStartIT extends BaseResourceIT {
...
@@ -39,7 +39,8 @@ public class QuickStartIT extends BaseResourceIT {
@BeforeClass
@BeforeClass
public
void
runQuickStart
()
throws
Exception
{
public
void
runQuickStart
()
throws
Exception
{
super
.
setUp
();
super
.
setUp
();
QuickStart
.
main
(
new
String
[]{});
QuickStart
.
runQuickstart
(
new
String
[]{},
new
String
[]{
"admin"
,
"admin"
});
}
}
@Test
@Test
...
...
This diff is collapsed.
Click to expand it.
webapp/src/test/java/org/apache/atlas/web/resources/BaseResourceIT.java
View file @
34f51a2a
...
@@ -49,6 +49,7 @@ import org.apache.atlas.typesystem.types.StructTypeDefinition;
...
@@ -49,6 +49,7 @@ import org.apache.atlas.typesystem.types.StructTypeDefinition;
import
org.apache.atlas.typesystem.types.TraitType
;
import
org.apache.atlas.typesystem.types.TraitType
;
import
org.apache.atlas.typesystem.types.TypeUtils
;
import
org.apache.atlas.typesystem.types.TypeUtils
;
import
org.apache.atlas.typesystem.types.utils.TypesUtil
;
import
org.apache.atlas.typesystem.types.utils.TypesUtil
;
import
org.apache.atlas.utils.AuthenticationUtil
;
import
org.apache.atlas.utils.ParamChecker
;
import
org.apache.atlas.utils.ParamChecker
;
import
org.apache.atlas.web.util.Servlets
;
import
org.apache.atlas.web.util.Servlets
;
import
org.apache.commons.configuration.Configuration
;
import
org.apache.commons.configuration.Configuration
;
...
@@ -87,7 +88,12 @@ public abstract class BaseResourceIT {
...
@@ -87,7 +88,12 @@ public abstract class BaseResourceIT {
client
.
resource
(
UriBuilder
.
fromUri
(
baseUrl
).
build
());
client
.
resource
(
UriBuilder
.
fromUri
(
baseUrl
).
build
());
service
=
client
.
resource
(
UriBuilder
.
fromUri
(
baseUrl
).
build
());
service
=
client
.
resource
(
UriBuilder
.
fromUri
(
baseUrl
).
build
());
serviceClient
=
new
AtlasClient
(
baseUrl
);
if
(!
AuthenticationUtil
.
isKerberosAuthicationEnabled
())
{
serviceClient
=
new
AtlasClient
(
new
String
[]{
baseUrl
},
new
String
[]{
"admin"
,
"admin"
});
}
else
{
serviceClient
=
new
AtlasClient
(
baseUrl
);
}
}
}
protected
void
createType
(
TypesDef
typesDef
)
throws
Exception
{
protected
void
createType
(
TypesDef
typesDef
)
throws
Exception
{
...
...
This diff is collapsed.
Click to expand it.
webapp/src/test/java/org/apache/atlas/web/security/FileAuthenticationTest.java
View file @
34f51a2a
...
@@ -19,6 +19,7 @@
...
@@ -19,6 +19,7 @@
package
org
.
apache
.
atlas
.
web
.
security
;
package
org
.
apache
.
atlas
.
web
.
security
;
import
java.io.File
;
import
java.io.File
;
import
java.util.Collection
;
import
org.apache.atlas.ApplicationProperties
;
import
org.apache.atlas.ApplicationProperties
;
import
org.apache.atlas.web.TestUtils
;
import
org.apache.atlas.web.TestUtils
;
import
org.apache.commons.configuration.PropertiesConfiguration
;
import
org.apache.commons.configuration.PropertiesConfiguration
;
...
@@ -31,6 +32,7 @@ import org.springframework.context.ApplicationContext;
...
@@ -31,6 +32,7 @@ import org.springframework.context.ApplicationContext;
import
org.springframework.context.support.ClassPathXmlApplicationContext
;
import
org.springframework.context.support.ClassPathXmlApplicationContext
;
import
org.springframework.security.authentication.BadCredentialsException
;
import
org.springframework.security.authentication.BadCredentialsException
;
import
org.springframework.security.core.Authentication
;
import
org.springframework.security.core.Authentication
;
import
org.springframework.security.core.GrantedAuthority
;
import
org.testng.annotations.AfterClass
;
import
org.testng.annotations.AfterClass
;
import
org.testng.annotations.BeforeClass
;
import
org.testng.annotations.BeforeClass
;
import
org.testng.annotations.Test
;
import
org.testng.annotations.Test
;
...
@@ -87,9 +89,11 @@ public class FileAuthenticationTest {
...
@@ -87,9 +89,11 @@ public class FileAuthenticationTest {
private
void
setupUserCredential
(
String
tmpDir
)
throws
Exception
{
private
void
setupUserCredential
(
String
tmpDir
)
throws
Exception
{
StringBuilder
credentialFileStr
=
new
StringBuilder
(
1024
);
StringBuilder
credentialFileStr
=
new
StringBuilder
(
1024
);
credentialFileStr
.
append
(
"admin=admin123\n"
);
credentialFileStr
.
append
(
"admin=ADMIN::8c6976e5b5410415bde908bd4dee15dfb167a9c873fc4bb8a81f6f2ab448a918\n"
);
credentialFileStr
.
append
(
"user=user123\n"
);
credentialFileStr
.
append
(
"michael=DATA_SCIENTIST::95bfb24de17d285d734b9eaa9109bfe922adc85f20d2e5e66a78bddb4a4ebddb\n"
);
credentialFileStr
.
append
(
"test=test123\n"
);
credentialFileStr
.
append
(
"paul=DATA_STEWARD::e7c0dcf5f8a93e93791e9bac1ae454a691c1d2a902fc4256d489e96c1b9ac68c\n"
);
credentialFileStr
.
append
(
"user= \n"
);
credentialFileStr
.
append
(
"user12= ::bd35283fe8fcfd77d7c05a8bf2adb85c773281927e12c9829c72a9462092f7c4\n"
);
File
credentialFile
=
new
File
(
tmpDir
,
"users-credentials"
);
File
credentialFile
=
new
File
(
tmpDir
,
"users-credentials"
);
FileUtils
.
write
(
credentialFile
,
credentialFileStr
.
toString
());
FileUtils
.
write
(
credentialFile
,
credentialFileStr
.
toString
());
}
}
...
@@ -98,7 +102,7 @@ public class FileAuthenticationTest {
...
@@ -98,7 +102,7 @@ public class FileAuthenticationTest {
public
void
testValidUserLogin
()
{
public
void
testValidUserLogin
()
{
when
(
authentication
.
getName
()).
thenReturn
(
"admin"
);
when
(
authentication
.
getName
()).
thenReturn
(
"admin"
);
when
(
authentication
.
getCredentials
()).
thenReturn
(
"admin
123
"
);
when
(
authentication
.
getCredentials
()).
thenReturn
(
"admin"
);
Authentication
auth
=
authProvider
.
authenticate
(
authentication
);
Authentication
auth
=
authProvider
.
authenticate
(
authentication
);
LOG
.
debug
(
" "
+
auth
);
LOG
.
debug
(
" "
+
auth
);
...
@@ -133,6 +137,54 @@ public class FileAuthenticationTest {
...
@@ -133,6 +137,54 @@ public class FileAuthenticationTest {
}
}
}
}
@Test
public
void
testLoginWhenRoleIsNotSet
()
{
when
(
authentication
.
getName
()).
thenReturn
(
"user12"
);
// for this user role is not set properly
when
(
authentication
.
getCredentials
()).
thenReturn
(
"user12"
);
try
{
Authentication
auth
=
authProvider
.
authenticate
(
authentication
);
LOG
.
debug
(
" "
+
auth
);
}
catch
(
AtlasAuthenticationException
uExp
)
{
Assert
.
assertTrue
(
uExp
.
getMessage
().
startsWith
(
"User role credentials is not set properly for"
));
}
}
@Test
public
void
testLoginWhenRolePasswordNotSet
()
{
when
(
authentication
.
getName
()).
thenReturn
(
"user"
);
// for this user password details are set blank
when
(
authentication
.
getCredentials
()).
thenReturn
(
"P@ssword"
);
try
{
Authentication
auth
=
authProvider
.
authenticate
(
authentication
);
LOG
.
debug
(
" "
+
auth
);
}
catch
(
UsernameNotFoundException
uExp
)
{
Assert
.
assertTrue
(
uExp
.
getMessage
().
startsWith
(
"Username not found"
));
}
}
@Test
public
void
testUserRoleMapping
()
{
when
(
authentication
.
getName
()).
thenReturn
(
"admin"
);
when
(
authentication
.
getCredentials
()).
thenReturn
(
"admin"
);
Authentication
auth
=
authProvider
.
authenticate
(
authentication
);
LOG
.
debug
(
" "
+
auth
);
Assert
.
assertTrue
(
auth
.
isAuthenticated
());
Collection
<?
extends
GrantedAuthority
>
authorities
=
auth
.
getAuthorities
();
String
role
=
""
;
for
(
GrantedAuthority
gauth
:
authorities
)
{
role
=
gauth
.
getAuthority
();
}
Assert
.
assertTrue
(
"ADMIN"
.
equals
(
role
));
}
@AfterClass
@AfterClass
public
void
tearDown
()
throws
Exception
{
public
void
tearDown
()
throws
Exception
{
...
...
This diff is collapsed.
Click to expand it.
webapp/src/test/java/org/apache/atlas/web/security/NegativeSSLAndKerberosTest.java
View file @
34f51a2a
...
@@ -60,7 +60,6 @@ public class NegativeSSLAndKerberosTest extends BaseSSLAndKerberosTest {
...
@@ -60,7 +60,6 @@ public class NegativeSSLAndKerberosTest extends BaseSSLAndKerberosTest {
// client will actually only leverage subset of these properties
// client will actually only leverage subset of these properties
final
PropertiesConfiguration
configuration
=
getSSLConfiguration
(
providerUrl
);
final
PropertiesConfiguration
configuration
=
getSSLConfiguration
(
providerUrl
);
configuration
.
setProperty
(
"atlas.http.authentication.type"
,
"kerberos"
);
TestUtils
.
writeConfiguration
(
configuration
,
persistDir
+
File
.
separator
+
TestUtils
.
writeConfiguration
(
configuration
,
persistDir
+
File
.
separator
+
ApplicationProperties
.
APPLICATION_PROPERTIES
);
ApplicationProperties
.
APPLICATION_PROPERTIES
);
...
@@ -76,6 +75,7 @@ public class NegativeSSLAndKerberosTest extends BaseSSLAndKerberosTest {
...
@@ -76,6 +75,7 @@ public class NegativeSSLAndKerberosTest extends BaseSSLAndKerberosTest {
configuration
.
setProperty
(
TLS_ENABLED
,
true
);
configuration
.
setProperty
(
TLS_ENABLED
,
true
);
configuration
.
setProperty
(
"atlas.http.authentication.enabled"
,
"true"
);
configuration
.
setProperty
(
"atlas.http.authentication.enabled"
,
"true"
);
configuration
.
setProperty
(
"atlas.http.authentication.type"
,
"kerberos"
);
configuration
.
setProperty
(
"atlas.http.authentication.kerberos.principal"
,
"HTTP/localhost@"
+
kdc
.
getRealm
());
configuration
.
setProperty
(
"atlas.http.authentication.kerberos.principal"
,
"HTTP/localhost@"
+
kdc
.
getRealm
());
configuration
.
setProperty
(
"atlas.http.authentication.kerberos.keytab"
,
httpKeytabFile
.
getAbsolutePath
());
configuration
.
setProperty
(
"atlas.http.authentication.kerberos.keytab"
,
httpKeytabFile
.
getAbsolutePath
());
configuration
.
setProperty
(
"atlas.http.authentication.kerberos.name.rules"
,
configuration
.
setProperty
(
"atlas.http.authentication.kerberos.name.rules"
,
...
@@ -84,6 +84,10 @@ public class NegativeSSLAndKerberosTest extends BaseSSLAndKerberosTest {
...
@@ -84,6 +84,10 @@ public class NegativeSSLAndKerberosTest extends BaseSSLAndKerberosTest {
TestUtils
.
writeConfiguration
(
configuration
,
persistDir
+
File
.
separator
+
TestUtils
.
writeConfiguration
(
configuration
,
persistDir
+
File
.
separator
+
ApplicationProperties
.
APPLICATION_PROPERTIES
);
ApplicationProperties
.
APPLICATION_PROPERTIES
);
// save original setting
originalConf
=
System
.
getProperty
(
"atlas.conf"
);
System
.
setProperty
(
"atlas.conf"
,
persistDir
);
dgiClient
=
new
AtlasClient
(
DGI_URL
)
{
dgiClient
=
new
AtlasClient
(
DGI_URL
)
{
@Override
@Override
protected
PropertiesConfiguration
getClientProperties
()
{
protected
PropertiesConfiguration
getClientProperties
()
{
...
@@ -91,9 +95,7 @@ public class NegativeSSLAndKerberosTest extends BaseSSLAndKerberosTest {
...
@@ -91,9 +95,7 @@ public class NegativeSSLAndKerberosTest extends BaseSSLAndKerberosTest {
}
}
};
};
// save original setting
originalConf
=
System
.
getProperty
(
"atlas.conf"
);
System
.
setProperty
(
"atlas.conf"
,
persistDir
);
secureEmbeddedServer
=
new
TestSecureEmbeddedServer
(
21443
,
getWarPath
())
{
secureEmbeddedServer
=
new
TestSecureEmbeddedServer
(
21443
,
getWarPath
())
{
@Override
@Override
public
Configuration
getConfiguration
()
{
public
Configuration
getConfiguration
()
{
...
@@ -125,7 +127,6 @@ public class NegativeSSLAndKerberosTest extends BaseSSLAndKerberosTest {
...
@@ -125,7 +127,6 @@ public class NegativeSSLAndKerberosTest extends BaseSSLAndKerberosTest {
Assert
.
fail
(
"Should have failed with GSSException"
);
Assert
.
fail
(
"Should have failed with GSSException"
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
Assert
.
assertTrue
(
e
.
getMessage
().
contains
(
"Mechanism level: Failed to find any Kerberos tgt"
));
}
}
}
}
}
}
This diff is collapsed.
Click to expand it.
webapp/src/test/java/org/apache/atlas/web/security/SSLAndKerberosTest.java
View file @
34f51a2a
...
@@ -69,7 +69,7 @@ public class SSLAndKerberosTest extends BaseSSLAndKerberosTest {
...
@@ -69,7 +69,7 @@ public class SSLAndKerberosTest extends BaseSSLAndKerberosTest {
// client will actually only leverage subset of these properties
// client will actually only leverage subset of these properties
final
PropertiesConfiguration
configuration
=
getSSLConfiguration
(
providerUrl
);
final
PropertiesConfiguration
configuration
=
getSSLConfiguration
(
providerUrl
);
configuration
.
setProperty
(
"atlas.http.authentication.type"
,
"kerberos"
);
TestUtils
.
writeConfiguration
(
configuration
,
persistDir
+
File
.
separator
+
TestUtils
.
writeConfiguration
(
configuration
,
persistDir
+
File
.
separator
+
ApplicationProperties
.
APPLICATION_PROPERTIES
);
ApplicationProperties
.
APPLICATION_PROPERTIES
);
...
@@ -83,6 +83,7 @@ public class SSLAndKerberosTest extends BaseSSLAndKerberosTest {
...
@@ -83,6 +83,7 @@ public class SSLAndKerberosTest extends BaseSSLAndKerberosTest {
configuration
.
load
(
url
);
configuration
.
load
(
url
);
configuration
.
setProperty
(
TLS_ENABLED
,
true
);
configuration
.
setProperty
(
TLS_ENABLED
,
true
);
configuration
.
setProperty
(
"atlas.http.authentication.enabled"
,
"true"
);
configuration
.
setProperty
(
"atlas.http.authentication.enabled"
,
"true"
);
configuration
.
setProperty
(
"atlas.http.authentication.type"
,
"kerberos"
);
configuration
.
setProperty
(
"atlas.http.authentication.kerberos.principal"
,
"HTTP/localhost@"
+
kdc
.
getRealm
());
configuration
.
setProperty
(
"atlas.http.authentication.kerberos.principal"
,
"HTTP/localhost@"
+
kdc
.
getRealm
());
configuration
.
setProperty
(
"atlas.http.authentication.kerberos.keytab"
,
httpKeytabFile
.
getAbsolutePath
());
configuration
.
setProperty
(
"atlas.http.authentication.kerberos.keytab"
,
httpKeytabFile
.
getAbsolutePath
());
configuration
.
setProperty
(
"atlas.http.authentication.kerberos.name.rules"
,
configuration
.
setProperty
(
"atlas.http.authentication.kerberos.name.rules"
,
...
...
This diff is collapsed.
Click to expand it.
webapp/src/test/java/org/apache/atlas/web/security/UserDaoTest.java
View file @
34f51a2a
...
@@ -16,11 +16,12 @@
...
@@ -16,11 +16,12 @@
*/
*/
package
org
.
apache
.
atlas
.
web
.
security
;
package
org
.
apache
.
atlas
.
web
.
security
;
import
java.util.Collection
;
import
java.util.Properties
;
import
java.util.Properties
;
import
org.apache.atlas.web.dao.UserDao
;
import
org.apache.atlas.web.dao.UserDao
;
import
org.apache.atlas.web.model.User
;
import
org.apache.atlas.web.model.User
;
import
org.junit.Assert
;
import
org.junit.Assert
;
import
org.springframework.security.core.GrantedAuthority
;
import
org.springframework.security.core.userdetails.UsernameNotFoundException
;
import
org.springframework.security.core.userdetails.UsernameNotFoundException
;
import
org.testng.annotations.Test
;
import
org.testng.annotations.Test
;
...
@@ -30,21 +31,27 @@ public class UserDaoTest {
...
@@ -30,21 +31,27 @@ public class UserDaoTest {
public
void
testUserDaowithValidUserLoginAndPassword
()
{
public
void
testUserDaowithValidUserLoginAndPassword
()
{
Properties
userLogins
=
new
Properties
();
Properties
userLogins
=
new
Properties
();
userLogins
.
put
(
"admin"
,
"admin123"
);
userLogins
.
put
(
"admin"
,
"
ADMIN::
admin123"
);
UserDao
user
=
new
UserDao
();
UserDao
user
=
new
UserDao
();
user
.
setUserLogins
(
userLogins
);
user
.
setUserLogins
(
userLogins
);
User
userBean
=
user
.
loadUserByUsername
(
"admin"
);
User
userBean
=
user
.
loadUserByUsername
(
"admin"
);
Assert
.
assertTrue
(
userBean
.
getPassword
().
equals
(
"admin123"
));
Assert
.
assertTrue
(
userBean
.
getPassword
().
equals
(
"admin123"
));
Collection
<?
extends
GrantedAuthority
>
authorities
=
userBean
.
getAuthorities
();
String
role
=
""
;
for
(
GrantedAuthority
gauth
:
authorities
)
{
role
=
gauth
.
getAuthority
();
}
Assert
.
assertTrue
(
"ADMIN"
.
equals
(
role
));
}
}
@Test
@Test
public
void
testUserDaowithInValidLogin
()
{
public
void
testUserDaowithInValidLogin
()
{
boolean
hadException
=
false
;
boolean
hadException
=
false
;
Properties
userLogins
=
new
Properties
();
Properties
userLogins
=
new
Properties
();
userLogins
.
put
(
"admin"
,
"admin123"
);
userLogins
.
put
(
"admin"
,
"
ADMIN::
admin123"
);
userLogins
.
put
(
"test"
,
"test123"
);
userLogins
.
put
(
"test"
,
"
DATA_STEWARD::
test123"
);
UserDao
user
=
new
UserDao
();
UserDao
user
=
new
UserDao
();
user
.
setUserLogins
(
userLogins
);
user
.
setUserLogins
(
userLogins
);
...
...
This diff is collapsed.
Click to expand it.
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