Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
151 commits
Select commit Hold shift + click to select a range
5cee194
RANGER-1494: Policy engine updates to support tag-based masking polic…
Jun 21, 2017
3e504e8
RANGER-1494: Policy engine updates to support tag-based masking polic…
Jun 22, 2017
a219604
RANGER-1665: provide a way to get list of policies associated with gi…
Jun 23, 2017
6a953db
RANGER-1651 : Improve Ranger and Ranger KMS REST Api documentation
mehulbparikh Jun 20, 2017
8675a24
RANGER-1653 : Proxying Ranger UI does not work with Ranger-KnoxSSO
ankitasinha Jun 19, 2017
98da922
RANGER-1638 : Improve the password validation from Ranger API
gautamborad Jun 23, 2017
50ef5f0
RANGER-1639 : Ranger KMS should validate key name before importing in…
ankitasinha Jun 23, 2017
496fc23
RANGER-1666-Ranger UI should consider recursiveSupported attribute va…
ni3galave Jul 3, 2017
97b80aa
RANGER-1679 : Export Policy not working when Knox proxy is Enabled
ni3galave Jul 7, 2017
87b78f9
RANGER-1689: Enabling recursive policy only for relativepath
Jul 11, 2017
61d352f
RANGER-1638 : Improve the password validation from Ranger API
ankitasinha Jul 15, 2017
992e318
RANGER-1696: Request to get all policies for hive or hbase service-ty…
Jul 25, 2017
5c8b45c
RANGER-1695:Optimize Ranger code for authorization of HDFS 'getConten…
Jul 26, 2017
b844289
RANGER-1714:Disable dynamic sorting of policies when trie pre-filter …
Jul 28, 2017
694ff57
RANGER-1708 : Remove tag services from service type and service name …
ni3galave Jul 24, 2017
99abbcf
RANGER-1491:Automatically map group of external users to Administrato…
bhavikpatel9977 Aug 8, 2017
41da451
RANGER-1737: Fixed RANGER-1181 by providing correct set of parameters…
Aug 16, 2017
9beaebf
RANGER-1674:IMPORT START audit is not appearing on audit page
bhavikpatel9977 Jul 21, 2017
5905297
RANGER-1724: On Report listing page for masking/row filter policies s…
ni3galave Aug 18, 2017
e2f94d2
RANGER-1676: Policy Details popup from Access audit page not displayi…
ni3galave Aug 21, 2017
852d326
RANGER-1632: Fixed issue where Users are not sync'd when sAMAccountNa…
spolavarapu1 Aug 22, 2017
b85c312
RANGER-1705 : Good coding practice in Ranger recommended by static co…
ankitasinha Jul 21, 2017
146c236
RANGER-1736 : Good coding practice in Ranger recommended by static co…
fatimaawez Aug 16, 2017
b65f3e8
RANGER-1747: Usersync: LDAP Paged results seems to be ignored in Ranger
spolavarapu1 Aug 23, 2017
364529c
RANGER-1717:User with KEYADMIN role is not able to see Audit => Admin…
bhavikpatel9977 Aug 11, 2017
4bfb29a
RANGER-1748 : User is unable to update existing policy while importin…
bhavikpatel9977 Aug 23, 2017
8747e78
RANGER-1726 : Users are not getting deleted when Knox proxy is Enabled
NikhilPurbhe Aug 22, 2017
ab0fa6f
RANGER-1754: correcting group deletion message
deepakrgr Aug 30, 2017
f780aba
RANGER-1735: Support representing nested group memberships in Ranger …
spolavarapu1 Sep 7, 2017
1d0e8af
RANGER-1771: Improve performance of merging lists of policyEvaluators…
Sep 11, 2017
adc3819
RANGER-1750 : In Nifi default policy is getting created with policyit…
NikhilPurbhe Aug 30, 2017
a0f43d8
RANGER 1697 : Update NiFi service def and handle upgrade scenario
NikhilPurbhe Sep 5, 2017
44b8769
RANGER-1732 Collection added to itsel
pengjianhua Sep 12, 2017
309abef
RANGER-1765:Add unique key constraint in x_group and x_group_users table
bhavikpatel9977 Sep 8, 2017
dbe1a3a
RANGER-1647: Allow Ranger policy conditions to use tag attributes and…
spolavarapu1 Sep 13, 2017
109f221
RANGER-1647: Missed upgrade patch file from previous checkin
spolavarapu1 Sep 13, 2017
3bf2d33
RANGER-1651 : Improve Ranger and Ranger KMS REST Api documentation
mehulbparikh Sep 15, 2017
106a1f4
RANGER-1682: Clicking on export service after session timeout gets st…
ni3galave Sep 14, 2017
5a77c8c
RANGER-1730 : Utility script that will list the users with a given role
fatimaawez Sep 15, 2017
29f8918
RANGER-1786: Need warning on external user role change.
ni3galave Sep 14, 2017
fd6047c
RANGER-1787: User has to fill up all the allow and deny conditions it…
ni3galave Sep 18, 2017
9381159
RANGER-1788:Install Ranger admin failure.
pengjianhua Sep 18, 2017
0abed0e
RANGER-1800: Usersync fails to update users and groups during increme…
spolavarapu1 Sep 26, 2017
bd0e825
RANGER-1801: group user mapping updates to ranger admin fail when the…
spolavarapu1 Sep 26, 2017
90ed702
RANGER-1748 : User is unable to update existing policy while importin…
bhavikpatel9977 Sep 25, 2017
78ffe3f
RANGER-1806 : Good coding practice in Ranger recommended by static co…
fatimaawez Sep 26, 2017
6134db8
RANGER-1727 : Ranger allows user to change an external user's passwor…
fatimaawez Sep 26, 2017
997d7c3
RANGER-1779 : last resource gets duplicated during update policy if p…
NikhilPurbhe Sep 27, 2017
186233c
RANGER-1756: Handle role related restrictions for users having User r…
ni3galave Sep 29, 2017
2d1d5c0
RANGER-1820: Duplicate entries should be deleted before creation of u…
pradeepagrawal8184 Sep 30, 2017
dd03e8c
RANGER-1818 : Good coding practice in Ranger recommended by static co…
fatimaawez Sep 30, 2017
f0a90a8
RANGER-1817 : Audit to Solr fails to log when the number of columns a…
fatimaawez Sep 30, 2017
2ce742c
RANGER-1819: Not able to delete group that is having special characte…
ni3galave Oct 4, 2017
e656b9a
RANGER-1826: Import of bulk policies is causing OOM and Apparent Dead…
pradeepagrawal8184 Oct 9, 2017
9ac7767
RANGER-1176: Ranger admin does not allow to create / update a policy …
ni3galave Oct 10, 2017
c2e1ec9
RANGER-1832: Export REST API should return exact matching results if …
pradeepagrawal8184 Oct 13, 2017
448182c
RANGER-1834: row filter policies are not being returned by policy search
Oct 12, 2017
8fe42a8
RANGER-1832: Export REST API should return exact matching results if …
pradeepagrawal8184 Oct 16, 2017
49f874f
RANGER-1838: Refactor Jisql dependencies
pradeepagrawal8184 Oct 16, 2017
eb81295
RANGER-1795: Service should not be renamed if tagged service resource…
Oct 16, 2017
616a646
RANGER-1841: Audit log record for 'use dbName' hive command contains …
Oct 16, 2017
d352754
RANGER-1820: Update consolidated db schema script for SQLServer DB
pradeepagrawal8184 Oct 18, 2017
3968c7f
RANGER-1843: Tag enricher performance improvement in identifying tags…
Oct 18, 2017
8c92df6
RANGER-1853: Masking functions based on custom masking of string type…
ni3galave Oct 23, 2017
e5a272c
RANGER-1828 : Good coding practice-add additional headers in ranger
NikhilPurbhe Oct 17, 2017
8320f08
RANGER-1868 : Good coding practice in Ranger recommended by static co…
NikhilPurbhe Nov 10, 2017
02e2c7d
RANGER-1883: TagSync should reuse kerberos ticket in REST calls to Ra…
Nov 11, 2017
8ebad64
RANGER-1883: Part 2 - All tag sources and sinks should use the same k…
Nov 14, 2017
30b1188
RANGER-1897: tagsync update to replace Atlas V1 API usage with Atlas …
mneethiraj Nov 21, 2017
29cd16c
RANGER-1937: Ranger tagsync should process ENTITY_CREATE notification…
Dec 21, 2017
7acbe78
RANGER-1943:Ranger Solr authorization is skipped when collection is e…
Dec 21, 2017
07333fd
RANGER-1938: Enable DocValues for more fields in Solr
risdenk Dec 20, 2017
bcc1412
RANGER-1944: Action filter for Admin Audit is not working
ni3galave Jan 2, 2018
bfac532
RANGER-1952: Allow user's email Address to be blank on emailchange AP…
pradeepagrawal8184 Jan 12, 2018
3c1f7e2
RANGER-1957: Fixed code to sync all the users during periodic sync wh…
spolavarapu1 Jan 19, 2018
4f2737b
RANGER-1956: Update CredentialBuilder module
pradeepagrawal8184 Jan 22, 2018
0fa9266
RANGER-1960: Take snapshot's table name into consideration for deletion
tsokorai Jan 22, 2018
27829af
RANGER-1966: Policy engine initialization does not create context enr…
Jan 30, 2018
07fd693
RANGER-1805: Code improvement to follow best practices in js
ni3galave Jan 25, 2018
42c996a
Ignoring Kafka SASL/SSL test
coheigea Feb 12, 2018
0c94811
RANGER-1980: Build failure for Ranger 0.7 branch
pradeepagrawal8184 Feb 12, 2018
21b8802
RANGER-2035: backport to 0.7 - fix the null implClass handling, which…
gzsombor Mar 23, 2018
9e7760c
RANGER-2066: Hbase column family access is authorized by a tagged col…
Apr 13, 2018
7e3963b
RANGER-2066: Fix regression
Apr 18, 2018
126ff6e
RANGER-2104: Ranger tagsync should ignore ENTITY_UPDATE events if the…
May 17, 2018
28733f0
RANGER-1436: Turn Ranger deny policy & except condition blocks ON by …
Apr 27, 2017
49d2962
RANGER-1553: Audit log record for 'show databases' hive command conta…
May 2, 2017
1c68d4f
RANGER-1648 : Ranger Kafka Plugin now should use the Short name from …
Jun 16, 2017
fdf8551
RANGER-1631 : create temp function failing with permission issues
Jun 5, 2017
73b8c6e
RANGER-1580 - Update Kafka tests to work with 0.10.1.1
Sep 26, 2018
302c20a
RANGER-1502: Solr shutdown does not cause the audit log file to be fl…
yzhou2001 Apr 7, 2017
a3be239
RANGER-1501: Audit Flush to HDFS does not actually cause the audit lo…
Sep 26, 2018
637f01a
RANGER-1415:The ranger can be opened when the user enters http://loca…
pengjianhua Mar 16, 2017
48fd258
RANGER-1408:When the error occurs, the system does not record the err…
zhangqiang2 Feb 27, 2017
13f1795
RANGER-1505 - Remove KeyProtector code in KMS
coheigea Apr 10, 2017
8a8bcd1
RANGER-1402 - NPE if there is a problem with the HiveClient driverCla…
coheigea Feb 21, 2017
1de5cab
RANGER-1403:There is a problem in buildks class when delete invalid k…
zhangqiang2 Feb 22, 2017
9f43810
RANGER-1731: Exclude old guava versions which could cause build problems
Sep 26, 2018
a582316
RANGER-1953 : improvement on user-group page listing
NikhilPurbhe Jan 19, 2018
bb5e859
RANGER-1797:Tomcat Security Vulnerability Alert. The version of the t…
pengjianhua Dec 5, 2017
8257bc9
RANGER-1867 - Update nimbus-jose-jwt to 4.41.2
coheigea Oct 31, 2017
d1e8a31
RANGER-1976: Upgrade Apache POI to 3.15
pradeepagrawal8184 Feb 12, 2018
38a3157
RANGER-1977: Upgrade Apache commons-beanutils to 1.9.3
pradeepagrawal8184 Feb 12, 2018
20daa74
RANGER-1979: Upgrade Spring-LDAP to 2.3.2
pradeepagrawal8184 Feb 12, 2018
a6ea029
RANGER-2060 : Knox proxy with knox-sso is not working for ranger.
Apr 9, 2018
10d3513
RANGER-1988: Fix insecure randomness
Feb 21, 2018
977a161
RANGER-1984: Hbase audit log records may not show all tags associated…
Sep 26, 2018
c344918
RANGER-1982i:Error Improvement for Analytics Metric of Ranger Admin a…
fatimaawez Feb 21, 2018
508d347
RANGER-1982 : Error Improvement for Analytics Metric of Ranger Admin …
fatimaawez Feb 26, 2018
3d43020
RANGER-2008: Policy evaluation is failing for multiline policy condit…
ni3galave Mar 6, 2018
92bdc78
RANGER-2007: ranger-tagsync's Kerberos ticket fails to renew
Mar 6, 2018
00f0ac2
RANGER-2076 : Handle proxy users for Kerberos based authentication
mehulbparikh May 14, 2018
2b1b923
RANGER-2080: Add json-smart explicitly to security-admin/pom.xml
vperiasamy Apr 24, 2018
b47faac
RANGER-2162: Upgrade c3p0 libraries
pradeepagrawal8184 Jul 26, 2018
475b529
RANGER-2158: Performance improvement to REST API call to update policy
Sep 27, 2018
320169a
RANGER-2165: Address JPA Cache issue when policies Create, Update and…
Jul 31, 2018
dddcf01
RANGER-2165: Address JPA Cache issue when policies Create, Update and…
Aug 14, 2018
6a6e955
RANGER-2173: Optimize Trie constuction and Policy lookup
Jul 31, 2018
4bdfbd6
RANGER-2173: Optimize Trie constuction and Policy lookup
Aug 5, 2018
8040bf3
RANGER-2172: Fixing minor issue with the no. of characters read using…
spolavarapu1 Aug 2, 2018
2d35834
RANGER-2010 : Ranger Tagsync should use cookie based authentication f…
NikhilPurbhe Mar 14, 2018
29801e0
RANGER-2183: Use INodeAttribute information to authorize HDFS access
Aug 9, 2018
660707e
RANGER-2188: Support multiple threads to build Trie and on-lookup pos…
Aug 14, 2018
d533e10
RANGER-2188: Support multiple threads to build Trie and on-lookup pos…
Aug 21, 2018
ca2e13b
RANGER-2196:Ensure that any explicit threads used by Ranger are marke…
Aug 23, 2018
53a7acd
RANGER-2191: Update ranger-tool with new options to control Trie
Aug 17, 2018
822e764
RANGER-2172: Good coding practices for unix authentication Service in…
Sep 27, 2018
678bf58
RANGER-1990: Support one-way SSL connection to DB
pradeepagrawal8184 Feb 22, 2018
21c5608
RANGER-2187 : External Group search fails on Ranger UI when installed…
bhavikpatel9977 Aug 16, 2018
7d40b35
RANGER-2204: Fixed issue where audit log values for policy service ar…
Sep 24, 2018
ac456e8
RANGER-2218: Added validations for names duing service def updates
Sep 28, 2018
46c6cf8
RANGER-2168: Add service admin user through service config
pradeepagrawal8184 Sep 19, 2018
b050618
RANGER-2181 : Code Improvement To Follow Best Practices for saving se…
bhavikpatel9977 Aug 10, 2018
7deed8e
RANGER-2169: Create unique index on service and name column of x_poli…
pradeepagrawal8184 Oct 9, 2018
1686d47
RANGER-2242: JiSQL utility is failing Oracle UDF
Oct 11, 2018
2fe9797
RANGER-2249:Ranger Audit not flushed immediately to hdfs
Oct 12, 2018
63ed5fe
RANGER-2209: Added service definition for ABFS
gayua523 Aug 17, 2018
8ac86f2
RANGER-2253: Unable to get dashboard page after login
pradeepagrawal8184 Oct 17, 2018
9890a90
RANGER-2247:
Oct 17, 2018
c84b98f
RANGER-2203, RANGER-2219: Review and update database schema for range…
Oct 19, 2018
f16e581
RANGER-2203, RANGER-2219: Review and update database schema for range…
Oct 19, 2018
61b6973
RANGER-2251 : Need to provide options for making java heap size memor…
Oct 23, 2018
37b1e1c
RANGER-2262 : Improvement of export to excel from report listing page…
NikhilPurbhe Oct 23, 2018
d81a744
RANGER-2268: Optimize policy and tags migration to new schema
Oct 27, 2018
216704a
RANGER-2272: Ensure that case of resource-definition names and access…
Oct 30, 2018
39df85e
RANGER-2049: Added support for doAs for Ranger REST APIs with Kerberi…
spolavarapu1 Nov 14, 2018
ad9ae76
RANGER-2049: Fixed an issue where doAs User role is not set properly
spolavarapu1 Nov 16, 2018
40746ad
RANGER-2074: Update netty version in ranger - ranger-0.7 branch
spolavarapu1 Dec 17, 2018
df1eb58
RANGER-2331 Ranger-KMS - KeySecure HSM Integration
gautamborad Feb 21, 2019
b661ac4
RANGER-2208: Code improvement to fetch User/Group information and Ser…
bhavikpatel9977 Nov 27, 2018
c1b6341
RANGER-2273 : Allow service admin and delegated admin user to view li…
bhavikpatel9977 Nov 27, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public class HDFSAuditDestination extends AuditDestination {
private String logFolder;

private PrintWriter logWriter = null;
volatile FSDataOutputStream ostream = null; // output stream wrapped in logWriter

private String currentFileName;

Expand Down Expand Up @@ -169,6 +170,7 @@ public PrintWriter run() throws Exception {
addDeferredCount(events.size());
out.close();
logWriter = null;
ostream = null;
return false;
}
} catch (Throwable t) {
Expand All @@ -178,7 +180,7 @@ public PrintWriter run() throws Exception {
} finally {
logger.info("Flushing HDFS audit. Event Size:" + events.size());
if (out != null) {
out.flush();
flush();
}
}
addSuccessCount(events.size());
Expand All @@ -187,10 +189,22 @@ public PrintWriter run() throws Exception {

@Override
public void flush() {
if ( logWriter != null) {
logWriter.flush();
logger.info("Flush HDFS audit logs completed.....");
}
logger.info("Flush called. name=" + getName());
if (ostream != null) {
try {
synchronized (this) {
if (ostream != null)
// 1) PrinterWriter does not have bufferring of its own so
// we need to flush its underlying stream
// 2) HDFS flush() does not really flush all the way to disk.
ostream.hflush();
logger.info("Flush HDFS audit logs completed.....");
}
} catch (IOException e) {
logger.error("Error on flushing log writer: " + e.getMessage() +
"\nException will be ignored. name=" + getName() + ", fileName=" + currentFileName);
}
}
}

/*
Expand Down Expand Up @@ -246,6 +260,7 @@ synchronized public void stop() {
+ getName() + ", fileName=" + currentFileName);
}
logWriter = null;
ostream = null;
}
logStatus();
}
Expand Down Expand Up @@ -290,7 +305,7 @@ synchronized private PrintWriter getLogFileStream() throws Exception {

// Create the file to write
logger.info("Creating new log file. hdfPath=" + fullPath);
FSDataOutputStream ostream = fileSystem.create(hdfPath);
ostream = fileSystem.create(hdfPath);
logWriter = new PrintWriter(ostream);
currentFileName = fullPath;
}
Expand Down Expand Up @@ -341,6 +356,7 @@ private void closeFileIfNeeded() throws FileNotFoundException, IOException {
}

logWriter = null;
ostream = null;
currentFileName = null;

if (!rollOverByDuration) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import java.util.Properties;
import java.util.concurrent.Semaphore;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
Expand Down Expand Up @@ -73,6 +74,7 @@ public class AuditProviderFactory {
private AuditHandler mProvider = null;
private String componentAppType = "";
private boolean mInitDone = false;
private JVMShutdownHook jvmShutdownHook = null;

private AuditProviderFactory() {
LOG.info("AuditProviderFactory: creating..");
Expand Down Expand Up @@ -106,6 +108,16 @@ public boolean isInitDone() {
return mInitDone;
}

/**
* call shutdown hook to provide a way to
* shutdown gracefully in addition to the ShutdownHook mechanism
*/
public void shutdown() {
if (isInitDone() && jvmShutdownHook != null) {
jvmShutdownHook.run();
}
}

public synchronized void init(Properties props, String appType) {
LOG.info("AuditProviderFactory: initializing..");

Expand Down Expand Up @@ -463,7 +475,7 @@ private AuditHandler getDefaultProvider() {

private void installJvmSutdownHook(Properties props) {
int shutdownHookMaxWaitSeconds = MiscUtil.getIntProperty(props, AUDIT_SHUTDOWN_HOOK_MAX_WAIT_SEC, AUDIT_SHUTDOWN_HOOK_MAX_WAIT_SEC_DEFAULT);
JVMShutdownHook jvmShutdownHook = new JVMShutdownHook(mProvider, shutdownHookMaxWaitSeconds);
jvmShutdownHook = new JVMShutdownHook(mProvider, shutdownHookMaxWaitSeconds);
ShutdownHookManager.get().addShutdownHook(jvmShutdownHook, RANGER_AUDIT_SHUTDOWN_HOOK_PRIORITY);
}

Expand Down Expand Up @@ -503,6 +515,7 @@ private static class JVMShutdownHook extends Thread {
final Semaphore doneCleanup = new Semaphore(0);
final Thread cleanupThread;
final int maxWait;
final AtomicBoolean done = new AtomicBoolean(false);

public JVMShutdownHook(AuditHandler provider, int maxWait) {
this.maxWait = maxWait;
Expand All @@ -513,6 +526,10 @@ public JVMShutdownHook(AuditHandler provider, int maxWait) {
}

public void run() {
if (!done.compareAndSet(false, true)) {
LOG.info("==> JVMShutdownHook.run() already done by another thread");
return;
}
LOG.info("==> JVMShutdownHook.run()");
LOG.info("JVMShutdownHook: Signalling async audit cleanup to start.");
startCleanup.release();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ public void start(LogDestination<T> destination) {

mDispatcherThread = new DestinationDispatcherThread<T>(this, destination, mLogger);

mDispatcherThread.setDaemon(true);

mDispatcherThread.start();

mLogger.debug("<== LocalFileLogBuffer.start()");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public synchronized static Subject loginUserFromKeytab(String user, String path)
SecureClientLoginConfiguration loginConf = new SecureClientLoginConfiguration(true, user, path);
LoginContext login = new LoginContext("hadoop-keytab-kerberos", subject, null, loginConf);
subject.getPrincipals().add(new User(user, AuthenticationMethod.KERBEROS, login));
login.logout();
login.login();
return login.getSubject();
} catch (LoginException le) {
Expand All @@ -63,6 +64,7 @@ public synchronized static Subject loginUserFromKeytab(String user, String path,
LoginContext login = new LoginContext("hadoop-keytab-kerberos", subject, null, loginConf);
KerberosName.setRules(nameRules);
subject.getPrincipals().add(new User(user, AuthenticationMethod.KERBEROS, login));
login.logout();
login.login();
return login.getSubject();
} catch (LoginException le) {
Expand All @@ -71,16 +73,16 @@ public synchronized static Subject loginUserFromKeytab(String user, String path,
}

public synchronized static Subject loginUserWithPassword(String user, String password) throws IOException {
String tmpPass = password;
try {
Subject subject = new Subject();
SecureClientLoginConfiguration loginConf = new SecureClientLoginConfiguration(false, user, password);
LoginContext login = new LoginContext("hadoop-keytab-kerberos", subject, null, loginConf);
subject.getPrincipals().add(new User(user, AuthenticationMethod.KERBEROS, login));
login.logout();
login.login();
return login.getSubject();
} catch (LoginException le) {
throw new IOException("Login failure for " + user + " using password " + tmpPass.replaceAll(".","*"), le);
throw new IOException("Login failure for " + user + " using password ****", le);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.apache.ranger.admin.client.datatype.RESTResponse;
import org.apache.ranger.audit.provider.MiscUtil;
import org.apache.ranger.authorization.hadoop.config.RangerConfiguration;
import org.apache.ranger.authorization.utils.StringUtil;
import org.apache.ranger.plugin.util.GrantRevokeRequest;
import org.apache.ranger.plugin.util.RangerRESTClient;
import org.apache.ranger.plugin.util.RangerRESTUtils;
Expand Down Expand Up @@ -80,11 +81,18 @@ public void init(String serviceName, String appId, String propertyPrefix) {
this.serviceName = serviceName;
this.pluginId = restUtils.getPluginId(serviceName, appId);

String url = RangerConfiguration.getInstance().get(propertyPrefix + ".policy.rest.url");
String url = "";
String tmpUrl = RangerConfiguration.getInstance().get(propertyPrefix + ".policy.rest.url");
String sslConfigFileName = RangerConfiguration.getInstance().get(propertyPrefix + ".policy.rest.ssl.config.file");
clusterName = RangerConfiguration.getInstance().get(propertyPrefix + ".ambari.cluster.name", "");
int restClientConnTimeOutMs = RangerConfiguration.getInstance().getInt(propertyPrefix + ".policy.rest.client.connection.timeoutMs", 120 * 1000);
int restClientReadTimeOutMs = RangerConfiguration.getInstance().getInt(propertyPrefix + ".policy.rest.client.read.timeoutMs", 30 * 1000);
if (!StringUtil.isEmpty(tmpUrl)) {
url = tmpUrl.trim();
}
if (url.endsWith("/")) {
url = url.substring(0, url.length() - 1);
}

init(url, sslConfigFileName, restClientConnTimeOutMs , restClientReadTimeOutMs);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
public class RangerHadoopConstants {

public static final String RANGER_ADD_HDFS_PERMISSION_PROP = "xasecure.add-hadoop-authorization";
public static final String RANGER_OPTIMIZE_SUBACCESS_AUTHORIZATION_PROP = "ranger.optimize-subaccess-authorization" ;
public static final boolean RANGER_ADD_HDFS_PERMISSION_DEFAULT = false;
public static final boolean RANGER_OPTIMIZE_SUBACCESS_AUTHORIZATION_DEFAULT = false ;
public static final String READ_ACCCESS_TYPE = "read";
public static final String WRITE_ACCCESS_TYPE = "write";
public static final String EXECUTE_ACCCESS_TYPE = "execute";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
/*
* 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.ranger.authorization.utils;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.reflect.TypeToken;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import java.lang.reflect.Type;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class JsonUtils {
private static final Log LOG = LogFactory.getLog(JsonUtils.class);

private static final HashMap<String, String> MAP_STRING_STRING = new HashMap<>();

private static final Gson gson;

static {
gson = new GsonBuilder().setDateFormat("yyyyMMdd-HH:mm:ss.SSS-Z")
.create();
}

public static String mapToJson(Map<?, ?> map) {
String ret = null;
if (MapUtils.isNotEmpty(map)) {
try {
ret = gson.toJson(map);
} catch (Exception e) {
LOG.error("Invalid input data: ", e);
}
}
return ret;
}

public static String listToJson(List<?> list) {
String ret = null;
if (CollectionUtils.isNotEmpty(list)) {
try {
ret = gson.toJson(list);
} catch (Exception e) {
LOG.error("Invalid input data: ", e);
}
}
return ret;
}

public static String objectToJson(Object object) {
String ret = null;

if(object != null) {
try {
ret = gson.toJson(object);
} catch(Exception excp) {
LOG.warn("objectToJson() failed to convert object to Json", excp);
}
}

return ret;
}

public static <T> T jsonToObject(String jsonStr, Class<T> clz) {
T ret = null;

if(StringUtils.isNotEmpty(jsonStr)) {
try {
ret = gson.fromJson(jsonStr, clz);
} catch(Exception excp) {
LOG.warn("jsonToObject() failed to convert json to object: " + jsonStr, excp);
}
}

return ret;
}

public static Map<String, String> jsonToMapStringString(String jsonStr) {
Map<String, String> ret = null;

if(StringUtils.isNotEmpty(jsonStr)) {
try {
ret = gson.fromJson(jsonStr, MAP_STRING_STRING.getClass());
} catch(Exception excp) {
LOG.warn("jsonToObject() failed to convert json to object: " + jsonStr, excp);
}
}

return ret;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public void logAuthzAudit(AuthzAuditEvent auditEvent) {

@Override
public void logAuthzAudits(Collection<AuthzAuditEvent> auditEvents) {
auditEvents.addAll(auditEvents);
this.auditEvents.addAll(auditEvents);
}

public void flushAudit() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,14 @@
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.ranger.plugin.contextenricher.RangerTagForEval;
import org.apache.ranger.plugin.policyengine.RangerAccessRequest;

import javax.script.Bindings;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;
import java.util.Collections;
import java.util.List;
import java.util.Map;

Expand Down Expand Up @@ -90,11 +92,15 @@ public boolean isMatched(RangerAccessRequest request) {

RangerAccessRequest readOnlyRequest = request.getReadOnlyCopy();

RangerScriptExecutionContext context = new RangerScriptExecutionContext(readOnlyRequest);
RangerScriptExecutionContext context = new RangerScriptExecutionContext(readOnlyRequest);
RangerTagForEval currentTag = context.getCurrentTag();
Map<String, String> tagAttribs = currentTag != null ? currentTag.getAttributes() : Collections.<String, String>emptyMap();

Bindings bindings = scriptEngine.createBindings();

bindings.put("ctx", context);
bindings.put("tag", currentTag);
bindings.put("tagAttr", tagAttribs);

if (LOG.isDebugEnabled()) {
LOG.debug("RangerScriptConditionEvaluator.isMatched(): script={" + script + "}");
Expand Down
Loading