-
Notifications
You must be signed in to change notification settings - Fork 0
/
RangerAuthorizationCoprocessor.java
1573 lines (1398 loc) · 66.5 KB
/
RangerAuthorizationCoprocessor.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* 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.hbase;
import java.io.IOException;
import java.net.InetAddress;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CoprocessorEnvironment;
import org.apache.hadoop.hbase.HColumnDescriptor;
import org.apache.hadoop.hbase.HRegionInfo;
import org.apache.hadoop.hbase.HTableDescriptor;
import org.apache.hadoop.hbase.NamespaceDescriptor;
import org.apache.hadoop.hbase.ProcedureInfo;
import org.apache.hadoop.hbase.ServerName;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.Append;
import org.apache.hadoop.hbase.client.Delete;
import org.apache.hadoop.hbase.client.Durability;
import org.apache.hadoop.hbase.client.Get;
import org.apache.hadoop.hbase.client.Increment;
import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.client.Result;
import org.apache.hadoop.hbase.client.Scan;
import org.apache.hadoop.hbase.coprocessor.CoprocessorException;
import org.apache.hadoop.hbase.coprocessor.CoprocessorService;
import org.apache.hadoop.hbase.coprocessor.MasterCoprocessorEnvironment;
import org.apache.hadoop.hbase.coprocessor.ObserverContext;
import org.apache.hadoop.hbase.coprocessor.RegionCoprocessorEnvironment;
import org.apache.hadoop.hbase.coprocessor.RegionServerCoprocessorEnvironment;
import org.apache.hadoop.hbase.filter.ByteArrayComparable;
import org.apache.hadoop.hbase.filter.CompareFilter.CompareOp;
import org.apache.hadoop.hbase.filter.Filter;
import org.apache.hadoop.hbase.filter.FilterList;
import org.apache.hadoop.hbase.ipc.RpcServer;
import org.apache.hadoop.hbase.master.procedure.MasterProcedureEnv;
import org.apache.hadoop.hbase.procedure2.ProcedureExecutor;
import org.apache.hadoop.hbase.protobuf.ProtobufUtil;
import org.apache.hadoop.hbase.protobuf.ResponseConverter;
import org.apache.hadoop.hbase.protobuf.generated.AccessControlProtos;
import org.apache.hadoop.hbase.protobuf.generated.AccessControlProtos.AccessControlService;
import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.SnapshotDescription;
import org.apache.hadoop.hbase.protobuf.generated.QuotaProtos.Quotas;
import org.apache.hadoop.hbase.protobuf.generated.SecureBulkLoadProtos.CleanupBulkLoadRequest;
import org.apache.hadoop.hbase.protobuf.generated.SecureBulkLoadProtos.PrepareBulkLoadRequest;
import org.apache.hadoop.hbase.regionserver.InternalScanner;
import org.apache.hadoop.hbase.regionserver.Region;
import org.apache.hadoop.hbase.regionserver.RegionScanner;
import org.apache.hadoop.hbase.regionserver.ScanType;
import org.apache.hadoop.hbase.regionserver.Store;
import org.apache.hadoop.hbase.regionserver.StoreFile;
import org.apache.hadoop.hbase.regionserver.wal.WALEdit;
import org.apache.hadoop.hbase.security.AccessDeniedException;
import org.apache.hadoop.hbase.security.User;
import org.apache.hadoop.hbase.security.access.Permission;
import org.apache.hadoop.hbase.security.access.Permission.Action;
import org.apache.hadoop.hbase.security.access.RangerAccessControlLists;
import org.apache.hadoop.hbase.security.access.TablePermission;
import org.apache.hadoop.hbase.security.access.UserPermission;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.util.Pair;
import org.apache.hadoop.security.AccessControlException;
import org.apache.ranger.audit.model.AuthzAuditEvent;
import org.apache.ranger.authorization.hadoop.config.RangerConfiguration;
import org.apache.ranger.authorization.hadoop.constants.RangerHadoopConstants;
import org.apache.ranger.authorization.utils.StringUtil;
import org.apache.ranger.plugin.audit.RangerDefaultAuditHandler;
import org.apache.ranger.plugin.policyengine.RangerAccessRequest;
import org.apache.ranger.plugin.policyengine.RangerAccessResultProcessor;
import org.apache.ranger.plugin.service.RangerBasePlugin;
import org.apache.ranger.plugin.util.GrantRevokeRequest;
import com.google.common.base.Objects;
import com.google.common.collect.Lists;
import com.google.common.collect.MapMaker;
import com.google.protobuf.RpcCallback;
import com.google.protobuf.RpcController;
import com.google.protobuf.Service;
import org.apache.ranger.plugin.util.RangerPerfTracer;
public class RangerAuthorizationCoprocessor extends RangerAuthorizationCoprocessorBase implements AccessControlService.Interface, CoprocessorService {
private static final Log LOG = LogFactory.getLog(RangerAuthorizationCoprocessor.class.getName());
private static final Log PERF_HBASEAUTH_REQUEST_LOG = RangerPerfTracer.getPerfLogger("hbaseauth.request");
private static boolean UpdateRangerPoliciesOnGrantRevoke = RangerHadoopConstants.HBASE_UPDATE_RANGER_POLICIES_ON_GRANT_REVOKE_DEFAULT_VALUE;
private static final String GROUP_PREFIX = "@";
private static final String WILDCARD = "*";
private static final String NAMESPACE_SEPARATOR = ":";
private final String messageTemplate = "evaluateAccess: exiting: user[%s], Operation[%s], access[%s], families[%s], verdict[%s]";
private RegionCoprocessorEnvironment regionEnv;
private Map<InternalScanner, String> scannerOwners = new MapMaker().weakKeys().makeMap();
/*
* These are package level only for testability and aren't meant to be exposed outside via getters/setters or made available to derived classes.
*/
final HbaseFactory _factory = HbaseFactory.getInstance();
final HbaseUserUtils _userUtils = _factory.getUserUtils();
final HbaseAuthUtils _authUtils = _factory.getAuthUtils();
private static volatile RangerHBasePlugin hbasePlugin = null;
//KEY:RegionNode+User+Operation+Action+ColumnFamily.
private static Map<String, ColumnFamilyAccessResult> globColumnFamilyAccessResultCache = new HashMap<String, ColumnFamilyAccessResult>();
private static Map<String, HbaseAccessCache> globhBaseAccessCache = new HashMap<String, HbaseAccessCache>();
private static RangerAuthorizationCoprocessor instance = null;
private static String hbaseAccessCachelock = "baseAccessCachelock";
private static final String timeFormat = "yyyy-MM-dd HH:mm:ss";
public void startUpdatePoliciesTask() {
instance = this;
Timer timer = new Timer();
timer.schedule(new UpdatePoliciesTask(), 2*1000, hbasePlugin.getPollingIntervalMs());//在
}
// Utilities Methods
protected byte[] getTableName(RegionCoprocessorEnvironment e) {
Region region = e.getRegion();
byte[] tableName = null;
if (region != null) {
HRegionInfo regionInfo = region.getRegionInfo();
if (regionInfo != null) {
tableName = regionInfo.getTable().getName();
}
}
return tableName;
}
protected void requireSystemOrSuperUser(Configuration conf) throws IOException {
User user = User.getCurrent();
if (user == null) {
throw new IOException("Unable to obtain the current user, authorization checks for internal operations will not work correctly!");
}
String systemUser = user.getShortName();
User activeUser = getActiveUser();
if (!Objects.equal(systemUser, activeUser.getShortName()) && !_userUtils.isSuperUser(activeUser)) {
throw new AccessDeniedException("User '" + user.getShortName() + "is not system or super user.");
}
}
protected boolean isSpecialTable(HRegionInfo regionInfo) {
return isSpecialTable(regionInfo.getTable().getName());
}
protected boolean isSpecialTable(byte[] tableName) {
return isSpecialTable(Bytes.toString(tableName));
}
protected boolean isSpecialTable(String input) {
final String[] specialTables = new String[] { "hbase:meta", "-ROOT-", ".META."};
for (String specialTable : specialTables ) {
if (specialTable.equals(input)) {
return true;
}
}
return false;
}
protected boolean isAccessForMetaTables(RegionCoprocessorEnvironment env) {
HRegionInfo hri = env.getRegion().getRegionInfo();
if (hri.isMetaTable() || hri.isMetaRegion()) {
return true;
} else {
return false;
}
}
private User getActiveUser() {
User user = RpcServer.getRequestUser();
if (user == null) {
// for non-rpc handling, fallback to system user
try {
user = User.getCurrent();
} catch (IOException e) {
LOG.error("Unable to find the current user");
user = null;
}
}
return user;
}
private String getRemoteAddress() {
InetAddress remoteAddr = RpcServer.getRemoteAddress();
if(remoteAddr == null) {
remoteAddr = RpcServer.getRemoteIp();
}
String strAddr = remoteAddr != null ? remoteAddr.getHostAddress() : null;
return strAddr;
}
// Methods that are used within the CoProcessor
private void requireScannerOwner(InternalScanner s) throws AccessDeniedException {
if (!RpcServer.isInRpcCallContext()) {
return;
}
String requestUserName = RpcServer.getRequestUserName();
String owner = scannerOwners.get(s);
if (owner != null && !owner.equals(requestUserName)) {
throw new AccessDeniedException("User '"+ requestUserName +"' is not the scanner owner!");
}
}
/**
* @param families
* @return empty map if families is null, would never have empty or null keys, would never have null values, values could be empty (non-null) set
*/
Map<String, Set<String>> getColumnFamilies(Map<byte[], ? extends Collection<?>> families) {
if (families == null) {
// null families map passed. Ok, returning empty map.
return Collections.<String, Set<String>>emptyMap();
}
Map<String, Set<String>> result = new HashMap<String, Set<String>>();
for (Map.Entry<byte[], ? extends Collection<?>> anEntry : families.entrySet()) {
byte[] familyBytes = anEntry.getKey();
String family = Bytes.toString(familyBytes);
if (family == null || family.isEmpty()) {
LOG.error("Unexpected Input: got null or empty column family (key) in families map! Ignoring...");
} else {
Collection<?> columnCollection = anEntry.getValue();
if (CollectionUtils.isEmpty(columnCollection)) {
// family points to null map, OK.
result.put(family, Collections.<String> emptySet());
} else {
Iterator<String> columnIterator = new ColumnIterator(columnCollection);
Set<String> columns = new HashSet<String>();
try {
while (columnIterator.hasNext()) {
String column = columnIterator.next();
columns.add(column);
}
} catch (Throwable t) {
LOG.error("Exception encountered when converting family-map to set of columns. Ignoring and returning empty set of columns for family[" + family + "]", t);
LOG.error("Ignoring exception and returning empty set of columns for family[" + family +"]");
columns.clear();
}
result.put(family, columns);
}
}
}
return result;
}
static class ColumnFamilyAccessResult {
final boolean _everythingIsAccessible;
final boolean _somethingIsAccessible;
final List<AuthzAuditEvent> _accessAllowedEvents;
final List<AuthzAuditEvent> _familyLevelAccessEvents;
final AuthzAuditEvent _accessDeniedEvent;
final String _denialReason;
final RangerAuthorizationFilter _filter;
final String _clusterName;
ColumnFamilyAccessResult(boolean everythingIsAccessible, boolean somethingIsAccessible,
List<AuthzAuditEvent> accessAllowedEvents, List<AuthzAuditEvent> familyLevelAccessEvents, AuthzAuditEvent accessDeniedEvent, String denialReason,
RangerAuthorizationFilter filter, String clusterName) {
_everythingIsAccessible = everythingIsAccessible;
_somethingIsAccessible = somethingIsAccessible;
// WARNING: we are just holding on to reference of the collection. Potentially risky optimization
_accessAllowedEvents = accessAllowedEvents;
_familyLevelAccessEvents = familyLevelAccessEvents;
_accessDeniedEvent = accessDeniedEvent;
_denialReason = denialReason;
// cached values of access results
_filter = filter;
_clusterName = clusterName;
}
@Override
public String toString() {
return Objects.toStringHelper(getClass())
.add("everythingIsAccessible", _everythingIsAccessible)
.add("somethingIsAccessible", _somethingIsAccessible)
.add("accessAllowedEvents", _accessAllowedEvents)
.add("familyLevelAccessEvents", _familyLevelAccessEvents)
.add("accessDeniedEvent", _accessDeniedEvent)
.add("denialReason", _denialReason)
.add("filter", _filter)
.add("clusterName", _clusterName)
.toString();
}
}
ColumnFamilyAccessResult evaluateAccess(String operation, Action action, final RegionCoprocessorEnvironment env,
final Map<byte[], ? extends Collection<?>> familyMap) throws AccessDeniedException {
String access = _authUtils.getAccess(action);
User user = getActiveUser();
String userName = _userUtils.getUserAsString(user);
if (LOG.isDebugEnabled()) {
LOG.debug(String.format("evaluateAccess: entered: user[%s], Operation[%s], access[%s], families[%s]",
userName, operation, access, getColumnFamilies(familyMap).toString()));
}
byte[] tableBytes = getTableName(env);
if (tableBytes == null || tableBytes.length == 0) {
String message = "evaluateAccess: Unexpected: Couldn't get table from RegionCoprocessorEnvironment. Access denied, not audited";
LOG.debug(message);
throw new AccessDeniedException("Insufficient permissions for operation '" + operation + "',action: " + action);
}
String table = Bytes.toString(tableBytes);
String clusterName = hbasePlugin.getClusterName();
ColumnFamilyAccessResult result;
if (canSkipAccessCheck(operation, access, table) || canSkipAccessCheck(operation, access, env)) {
LOG.debug("evaluateAccess: exiting: isKnownAccessPattern returned true: access allowed, not audited");
result = new ColumnFamilyAccessResult(true, true, null, null, null, null, null, null);
if (LOG.isDebugEnabled()) {
Map<String, Set<String>> families = getColumnFamilies(familyMap);
String message = String.format(messageTemplate, userName, operation, access, families.toString(), result.toString());
LOG.debug(message);
}
return result;
}
String cacheKey = operation + getRemoteAddress() + userName + access + table + clusterName + getColumnFamilyKey(familyMap);
result = getGlobalHbaseAccessFromCache(cacheKey);
if (result == null) {
Map<String, Set<String>> families = getColumnFamilies(familyMap);
HbaseAccessCache hbaseAC = new HbaseAccessCache();
hbaseAC.setOperation(operation);
hbaseAC.setClusterName(clusterName);
hbaseAC.setAccess(access);
hbaseAC.setFamilies(families);
hbaseAC.setRemoteAddr(getRemoteAddress());
hbaseAC.setTable(table);
hbaseAC.setUserName(userName);
SimpleDateFormat sdf = new SimpleDateFormat( timeFormat );
hbaseAC.setUser(user);
String updateTime = sdf.format(new Date());
hbaseAC.setUpdateTime(updateTime);
result = getColumnFamilyAccessResult(user, operation, getRemoteAddress(), access, table, clusterName, families);
putGlobHbaseAccessToCache(cacheKey, result,hbaseAC);
}
else {
updateGlobBaseAccessCache(cacheKey);
}
return result;
// let's create a session that would be reused. Set things on it that won't change.
}
private ColumnFamilyAccessResult getColumnFamilyAccessResult(User user, String operation, String remoteIp, String access,
String table, String clusterName,
Map<String, Set<String>> families){
ColumnFamilyAccessResult result;
HbaseAuditHandler auditHandler = _factory.getAuditHandler();
AuthorizationSession session = new AuthorizationSession(hbasePlugin)
.operation(operation)
.remoteAddress(remoteIp)
.auditHandler(auditHandler)
.user(user)
.access(access)
.table(table)
.clusterName(clusterName);
if (LOG.isDebugEnabled()) {
LOG.debug("evaluateAccess: families to process: " + families.toString());
}
if (families == null || families.isEmpty()) {
LOG.debug("evaluateAccess: Null or empty families collection, ok. Table level access is desired");
session.buildRequest()
.authorize();
boolean authorized = session.isAuthorized();
String reason = "";
if (authorized) {
if (LOG.isDebugEnabled()) {
LOG.debug("evaluateAccess: table level access granted [" + table + "]");
}
} else {
reason = String.format("Insufficient permissions for user ‘%s',action: %s, tableName:%s, no column families found.", user.getName(), operation, table);
}
AuthzAuditEvent event = auditHandler.getAndDiscardMostRecentEvent(); // this could be null, of course, depending on audit settings of table.
// if authorized then pass captured events as access allowed set else as access denied set.
result = new ColumnFamilyAccessResult(authorized, authorized,
authorized ? Collections.singletonList(event) : null,
null, authorized ? null : event, reason, null, clusterName);
if (LOG.isDebugEnabled()) {
String message = String.format(messageTemplate, _userUtils.getUserAsString(user), operation, access, families.toString(), result.toString());
LOG.debug(message);
}
return result;
} else {
LOG.debug("evaluateAccess: Families collection not null. Skipping table-level check, will do finer level check");
}
boolean everythingIsAccessible = true;
boolean somethingIsAccessible = false;
/*
* we would have to accumulate audits of all successful accesses and any one denial (which in our case ends up being the last denial)
* We need to keep audit events for family level access check seperate because we don't want them logged in some cases.
*/
List<AuthzAuditEvent> authorizedEvents = new ArrayList<AuthzAuditEvent>();
List<AuthzAuditEvent> familyLevelAccessEvents = new ArrayList<AuthzAuditEvent>();
AuthzAuditEvent deniedEvent = null;
String denialReason = null;
// we need to cache the auths results so that we can create a filter, if needed
Map<String, Set<String>> columnsAccessAllowed = new HashMap<String, Set<String>>();
Set<String> familesAccessAllowed = new HashSet<String>();
Set<String> familesAccessDenied = new HashSet<String>();
Set<String> familesAccessIndeterminate = new HashSet<String>();
for (Map.Entry<String, Set<String>> anEntry : families.entrySet()) {
String family = anEntry.getKey();
session.columnFamily(family);
if (LOG.isDebugEnabled()) {
LOG.debug("evaluateAccess: Processing family: " + family);
}
Set<String> columns = anEntry.getValue();
if (columns == null || columns.isEmpty()) {
LOG.debug("evaluateAccess: columns collection null or empty, ok. Family level access is desired.");
session.column(null) // zap stale column from prior iteration of this loop, if any
.buildRequest()
.authorize();
AuthzAuditEvent auditEvent = auditHandler.getAndDiscardMostRecentEvent(); // capture it only for success
if (session.isAuthorized()) {
if (LOG.isDebugEnabled()) {
LOG.debug("evaluateAccess: has family level access [" + family + "]");
}
// we need to do 3 things: housekeeping, decide about audit events, building the results cache for filter
somethingIsAccessible = true;
familesAccessAllowed.add(family);
if (auditEvent != null) {
LOG.debug("evaluateAccess: adding to family-level-access-granted-event-set");
familyLevelAccessEvents.add(auditEvent);
}
} else {
everythingIsAccessible = false;
if (auditEvent != null && deniedEvent == null) { // we need to capture just one denial event
LOG.debug("evaluateAccess: Setting denied access audit event with last auth failure audit event.");
deniedEvent = auditEvent;
}
if (LOG.isDebugEnabled()) {
LOG.debug("evaluateAccess: no family level access [" + family + "]. Checking if has partial access (of any type)...");
}
session.resourceMatchingScope(RangerAccessRequest.ResourceMatchingScope.SELF_OR_DESCENDANTS)
.buildRequest()
.authorize();
auditEvent = auditHandler.getAndDiscardMostRecentEvent(); // capture it only for failure
if (session.isAuthorized()) {
if (LOG.isDebugEnabled()) {
LOG.debug("evaluateAccess: has partial access (of some type) in family [" + family + "]");
}
// we need to do 3 things: housekeeping, decide about audit events, building the results cache for filter
somethingIsAccessible = true;
familesAccessIndeterminate.add(family);
} else {
if (LOG.isDebugEnabled()) {
LOG.debug("evaluateAccess: has no access of ["+ access + "] type in family [" + family + "]");
}
familesAccessDenied.add(family);
denialReason = String.format("Insufficient permissions for user ‘%s',action: %s, tableName:%s, family:%s.", user.getName(), operation, table, family);
if (auditEvent != null && deniedEvent == null) { // we need to capture just one denial event
LOG.debug("evaluateAccess: Setting denied access audit event with last auth failure audit event.");
deniedEvent = auditEvent;
}
}
// Restore the headMatch setting
session.resourceMatchingScope(RangerAccessRequest.ResourceMatchingScope.SELF);
}
} else {
LOG.debug("evaluateAccess: columns collection not empty. Skipping Family level check, will do finer level access check.");
Set<String> accessibleColumns = new HashSet<String>(); // will be used in to populate our results cache for the filter
for (String column : columns) {
if (LOG.isDebugEnabled()) {
LOG.debug("evaluateAccess: Processing column: " + column);
}
session.column(column)
.buildRequest()
.authorize();
AuthzAuditEvent auditEvent = auditHandler.getAndDiscardMostRecentEvent();
if (session.isAuthorized()) {
if (LOG.isDebugEnabled()) {
LOG.debug("evaluateAccess: has column level access [" + family + ", " + column + "]");
}
// we need to do 3 things: housekeeping, capturing audit events, building the results cache for filter
somethingIsAccessible = true;
accessibleColumns.add(column);
if (auditEvent != null) {
LOG.debug("evaluateAccess: adding to access-granted-audit-event-set");
authorizedEvents.add(auditEvent);
}
} else {
if (LOG.isDebugEnabled()) {
LOG.debug("evaluateAccess: no column level access [" + family + ", " + column + "]");
}
everythingIsAccessible = false;
denialReason = String.format("Insufficient permissions for user ‘%s',action: %s, tableName:%s, family:%s, column: %s", user.getName(), operation, table, family, column);
if (auditEvent != null && deniedEvent == null) { // we need to capture just one denial event
LOG.debug("evaluateAccess: Setting denied access audit event with last auth failure audit event.");
deniedEvent = auditEvent;
}
}
if (!accessibleColumns.isEmpty()) {
columnsAccessAllowed.put(family, accessibleColumns);
}
}
}
}
// Cache of auth results are encapsulated the in the filter. Not every caller of the function uses it - only preGet and preOpt will.
RangerAuthorizationFilter filter = new RangerAuthorizationFilter(session, familesAccessAllowed, familesAccessDenied, familesAccessIndeterminate, columnsAccessAllowed);
result = new ColumnFamilyAccessResult(everythingIsAccessible, somethingIsAccessible, authorizedEvents, familyLevelAccessEvents, deniedEvent, denialReason, filter, clusterName);
if (LOG.isDebugEnabled()) {
String message = String.format(messageTemplate, _userUtils.getUserAsString(user), operation, access, families.toString(), result.toString());
LOG.debug(message);
}
return result;
}
Filter authorizeAccess(String operation, Action action, final RegionCoprocessorEnvironment env, final Map<byte[], NavigableSet<byte[]>> familyMap) throws AccessDeniedException {
if (LOG.isDebugEnabled()) {
LOG.debug("==> authorizeAccess");
}
RangerPerfTracer perf = null;
try {
perf = RangerPerfTracer.getPerfTracer(PERF_HBASEAUTH_REQUEST_LOG, "RangerAuthorizationCoprocessor.authorizeAccess(request=Operation[" + operation + "]");
ColumnFamilyAccessResult accessResult = evaluateAccess(operation, action, env, familyMap);
RangerDefaultAuditHandler auditHandler = new RangerDefaultAuditHandler();
if (accessResult._everythingIsAccessible) {
auditHandler.logAuthzAudits(accessResult._accessAllowedEvents);
auditHandler.logAuthzAudits(accessResult._familyLevelAccessEvents);
LOG.debug("authorizeAccess: exiting: No filter returned since all access was allowed");
return null; // no filter needed since we are good to go.
} else if (accessResult._somethingIsAccessible) {
// NOTE: audit logging is split beween logging here (in scope of preOp/preGet) and logging in the filter component for those that couldn't be determined
auditHandler.logAuthzAudits(accessResult._accessAllowedEvents);
LOG.debug("authorizeAccess: exiting: Filter returned since some access was allowed");
return accessResult._filter;
} else {
// If we are here then it means nothing was accessible! So let's log one denial (in our case, the last denial) and throw an exception
auditHandler.logAuthzAudit(accessResult._accessDeniedEvent);
LOG.debug("authorizeAccess: exiting: Throwing exception since nothing was accessible");
throw new AccessDeniedException(accessResult._denialReason);
}
} finally {
RangerPerfTracer.log(perf);
if (LOG.isDebugEnabled()) {
LOG.debug("<== authorizeAccess");
}
}
}
Filter combineFilters(Filter filter, Filter existingFilter) {
Filter combinedFilter = filter;
if (existingFilter != null) {
combinedFilter = new FilterList(FilterList.Operator.MUST_PASS_ALL, Lists.newArrayList(filter, existingFilter));
}
return combinedFilter;
}
void requirePermission(final String operation, final Action action, final RegionCoprocessorEnvironment regionServerEnv, final Map<byte[], ? extends Collection<?>> familyMap)
throws AccessDeniedException {
RangerPerfTracer perf = null;
try {
if (RangerPerfTracer.isPerfTraceEnabled(PERF_HBASEAUTH_REQUEST_LOG)) {
perf = RangerPerfTracer.getPerfTracer(PERF_HBASEAUTH_REQUEST_LOG, "RangerAuthorizationCoprocessor.requirePermission(request=Operation[" + operation + "]");
}
ColumnFamilyAccessResult accessResult = evaluateAccess(operation, action, regionServerEnv, familyMap);
RangerDefaultAuditHandler auditHandler = new RangerDefaultAuditHandler();
if (accessResult._everythingIsAccessible) {
auditHandler.logAuthzAudits(accessResult._accessAllowedEvents);
auditHandler.logAuthzAudits(accessResult._familyLevelAccessEvents);
LOG.debug("requirePermission: exiting: all access was allowed");
return;
} else {
auditHandler.logAuthzAudit(accessResult._accessDeniedEvent);
LOG.debug("requirePermission: exiting: throwing exception as everything wasn't accessible");
throw new AccessDeniedException(accessResult._denialReason);
}
} finally {
RangerPerfTracer.log(perf);
}
}
/**
* This could run s
* @param operation
* @param otherInformation
* @param table
* @param columnFamily
* @param column
* @return
* @throws AccessDeniedException
*/
void authorizeAccess(String operation, String otherInformation, Action action, String table, String columnFamily, String column) throws AccessDeniedException {
String access = _authUtils.getAccess(action);
if (LOG.isDebugEnabled()) {
final String format = "authorizeAccess: %s: Operation[%s], Info[%s], access[%s], table[%s], columnFamily[%s], column[%s]";
String message = String.format(format, "Entering", operation, otherInformation, access, table, columnFamily, column);
LOG.debug(message);
}
final String format = "authorizeAccess: %s: Operation[%s], Info[%s], access[%s], table[%s], columnFamily[%s], column[%s], allowed[%s], reason[%s]";
if (canSkipAccessCheck(operation, access, table)) {
if (LOG.isDebugEnabled()) {
String message = String.format(format, "Exiting", operation, otherInformation, access, table, columnFamily, column, true, "can skip auth check");
LOG.debug(message);
}
return;
}
User user = getActiveUser();
String clusterName = hbasePlugin.getClusterName();
HbaseAuditHandler auditHandler = _factory.getAuditHandler();
AuthorizationSession session = new AuthorizationSession(hbasePlugin)
.operation(operation)
.otherInformation(otherInformation)
.remoteAddress(getRemoteAddress())
.auditHandler(auditHandler)
.user(user)
.access(access)
.table(table)
.columnFamily(columnFamily)
.column(column)
.clusterName(clusterName)
.buildRequest()
.authorize();
if (LOG.isDebugEnabled()) {
boolean allowed = session.isAuthorized();
String reason = session.getDenialReason();
String message = String.format(format, "Exiting", operation, otherInformation, access, table, columnFamily, column, allowed, reason);
LOG.debug(message);
}
session.publishResults();
}
boolean canSkipAccessCheck(final String operation, String access, final String table)
throws AccessDeniedException {
User user = getActiveUser();
boolean result = false;
if (user == null) {
String message = "Unexpeceted: User is null: access denied, not audited!";
LOG.warn("canSkipAccessCheck: exiting" + message);
throw new AccessDeniedException("No user associated with request (" + operation + ") for action: " + access + "on table:" + table);
} else if (isAccessForMetadataRead(access, table)) {
LOG.debug("canSkipAccessCheck: true: metadata read access always allowed, not audited");
result = true;
} else {
LOG.debug("Can't skip access checks");
}
return result;
}
boolean canSkipAccessCheck(final String operation, String access, final RegionCoprocessorEnvironment regionServerEnv) throws AccessDeniedException {
String clusterName = hbasePlugin.getClusterName();
User user = getActiveUser();
// read access to metadata tables is always allowed and isn't audited.
if (isAccessForMetaTables(regionServerEnv) && _authUtils.isReadAccess(access)) {
LOG.debug("isKnownAccessPattern: exiting: Read access for metadata tables allowed, not audited!");
return true;
}
// if write access is desired to metatables then global create access is sufficient
if (_authUtils.isWriteAccess(access) && isAccessForMetaTables(regionServerEnv)) {
String createAccess = _authUtils.getAccess(Action.CREATE);
AuthorizationSession session = new AuthorizationSession(hbasePlugin)
.operation(operation)
.remoteAddress(getRemoteAddress())
.user(user)
.access(createAccess)
.clusterName(clusterName)
.buildRequest()
.authorize();
if (session.isAuthorized()) {
// NOTE: this access isn't logged
LOG.debug("isKnownAccessPattern: exiting: User has global create access, allowed!");
return true;
}
}
return false;
}
boolean isAccessForMetadataRead(String access, String table) {
if (_authUtils.isReadAccess(access) && isSpecialTable(table)) {
LOG.debug("isAccessForMetadataRead: Metadata tables read: access allowed!");
return true;
}
return false;
}
// Check if the user has global permission ...
protected void requireGlobalPermission(String request, String objName, Permission.Action action) throws AccessDeniedException {
authorizeAccess(request, objName, action, null, null, null);
}
protected void requirePermission(String request, Permission.Action action) throws AccessDeniedException {
requirePermission(request, null, action);
}
protected void requirePermission(String request, byte[] tableName, Permission.Action action) throws AccessDeniedException {
String table = Bytes.toString(tableName);
authorizeAccess(request, null, action, table, null, null);
}
protected void requirePermission(String request, byte[] aTableName, byte[] aColumnFamily, byte[] aQualifier, Permission.Action action) throws AccessDeniedException {
String table = Bytes.toString(aTableName);
String columnFamily = Bytes.toString(aColumnFamily);
String column = Bytes.toString(aQualifier);
authorizeAccess(request, null, action, table, columnFamily, column);
}
protected void requirePermission(String request, Permission.Action perm, RegionCoprocessorEnvironment env, Collection<byte[]> families) throws IOException {
HashMap<byte[], Set<byte[]>> familyMap = new HashMap<byte[], Set<byte[]>>();
if(families != null) {
for (byte[] family : families) {
familyMap.put(family, null);
}
}
requirePermission(request, perm, env, familyMap);
}
@Override
public void postScannerClose(ObserverContext<RegionCoprocessorEnvironment> c, InternalScanner s) throws IOException {
scannerOwners.remove(s);
}
@Override
public RegionScanner postScannerOpen(ObserverContext<RegionCoprocessorEnvironment> c, Scan scan, RegionScanner s) throws IOException {
User user = getActiveUser();
if (user != null && user.getShortName() != null) {
scannerOwners.put(s, user.getShortName());
}
return s;
}
@Override
public void postStartMaster(ObserverContext<MasterCoprocessorEnvironment> ctx) throws IOException {
if(UpdateRangerPoliciesOnGrantRevoke) {
RangerAccessControlLists.init(ctx.getEnvironment().getMasterServices());
}
}
@Override
public void preAddColumn(ObserverContext<MasterCoprocessorEnvironment> c, TableName tableName, HColumnDescriptor column) throws IOException {
requirePermission("addColumn", tableName.getName(), null, null, Action.CREATE);
}
@Override
public Result preAppend(ObserverContext<RegionCoprocessorEnvironment> c, Append append) throws IOException {
requirePermission("append", TablePermission.Action.WRITE, c.getEnvironment(), append.getFamilyCellMap());
return null;
}
@Override
public void preAssign(ObserverContext<MasterCoprocessorEnvironment> c, HRegionInfo regionInfo) throws IOException {
requirePermission("assign", regionInfo.getTable().getName(), null, null, Action.ADMIN);
}
@Override
public void preBalance(ObserverContext<MasterCoprocessorEnvironment> c) throws IOException {
requirePermission("balance", Permission.Action.ADMIN);
}
@Override
public boolean preBalanceSwitch(ObserverContext<MasterCoprocessorEnvironment> c, boolean newValue) throws IOException {
requirePermission("balanceSwitch", Permission.Action.ADMIN);
return newValue;
}
@Override
public void preBulkLoadHFile(ObserverContext<RegionCoprocessorEnvironment> ctx, List<Pair<byte[], String>> familyPaths) throws IOException {
List<byte[]> cfs = new LinkedList<byte[]>();
for (Pair<byte[], String> el : familyPaths) {
cfs.add(el.getFirst());
}
requirePermission("bulkLoadHFile", Permission.Action.WRITE, ctx.getEnvironment(), cfs);
}
@Override
public boolean preCheckAndDelete(ObserverContext<RegionCoprocessorEnvironment> c, byte[] row, byte[] family, byte[] qualifier, CompareOp compareOp, ByteArrayComparable comparator, Delete delete, boolean result) throws IOException {
Collection<byte[]> familyMap = Arrays.asList(new byte[][] { family });
requirePermission("checkAndDelete", TablePermission.Action.READ, c.getEnvironment(), familyMap);
requirePermission("checkAndDelete", TablePermission.Action.WRITE, c.getEnvironment(), familyMap);
return result;
}
@Override
public boolean preCheckAndPut(ObserverContext<RegionCoprocessorEnvironment> c, byte[] row, byte[] family, byte[] qualifier, CompareOp compareOp, ByteArrayComparable comparator, Put put, boolean result) throws IOException {
Collection<byte[]> familyMap = Arrays.asList(new byte[][] { family });
requirePermission("checkAndPut", TablePermission.Action.READ, c.getEnvironment(), familyMap);
requirePermission("checkAndPut", TablePermission.Action.WRITE, c.getEnvironment(), familyMap);
return result;
}
@Override
public void preCloneSnapshot(ObserverContext<MasterCoprocessorEnvironment> ctx, SnapshotDescription snapshot, HTableDescriptor hTableDescriptor) throws IOException {
requirePermission("cloneSnapshot", hTableDescriptor.getTableName().getName(), Permission.Action.ADMIN);
}
@Override
public void preClose(ObserverContext<RegionCoprocessorEnvironment> e, boolean abortRequested) throws IOException {
requirePermission("close", getTableName(e.getEnvironment()), Permission.Action.ADMIN);
}
@Override
public InternalScanner preCompact(ObserverContext<RegionCoprocessorEnvironment> e, Store store, InternalScanner scanner,ScanType scanType) throws IOException {
requirePermission("compact", getTableName(e.getEnvironment()), null, null, Action.CREATE);
return scanner;
}
@Override
public void preCompactSelection(ObserverContext<RegionCoprocessorEnvironment> e, Store store, List<StoreFile> candidates) throws IOException {
requirePermission("compactSelection", getTableName(e.getEnvironment()), null, null, Action.CREATE);
}
@Override
public void preCreateTable(ObserverContext<MasterCoprocessorEnvironment> c, HTableDescriptor desc, HRegionInfo[] regions) throws IOException {
requirePermission("createTable", desc.getTableName().getName(), Permission.Action.CREATE);
}
@Override
public void preDelete(ObserverContext<RegionCoprocessorEnvironment> c, Delete delete, WALEdit edit, Durability durability) throws IOException {
requirePermission("delete", TablePermission.Action.WRITE, c.getEnvironment(), delete.getFamilyCellMap());
}
@Override
public void preDeleteColumn(ObserverContext<MasterCoprocessorEnvironment> c, TableName tableName, byte[] col) throws IOException {
requirePermission("deleteColumn", tableName.getName(), null, null, Action.CREATE);
}
@Override
public void preDeleteSnapshot(ObserverContext<MasterCoprocessorEnvironment> ctx, SnapshotDescription snapshot) throws IOException {
requirePermission("deleteSnapshot", Permission.Action.ADMIN);
}
@Override
public void preDeleteTable(ObserverContext<MasterCoprocessorEnvironment> c, TableName tableName) throws IOException {
requirePermission("deleteTable", tableName.getName(), null, null, Action.CREATE);
}
@Override
public void preDisableTable(ObserverContext<MasterCoprocessorEnvironment> c, TableName tableName) throws IOException {
requirePermission("disableTable", tableName.getName(), null, null, Action.CREATE);
}
@Override
public void preEnableTable(ObserverContext<MasterCoprocessorEnvironment> c, TableName tableName) throws IOException {
requirePermission("enableTable", tableName.getName(), null, null, Action.CREATE);
}
@Override
public boolean preExists(ObserverContext<RegionCoprocessorEnvironment> c, Get get, boolean exists) throws IOException {
requirePermission("exists", TablePermission.Action.READ, c.getEnvironment(), get.familySet());
return exists;
}
@Override
public void preFlush(ObserverContext<RegionCoprocessorEnvironment> e) throws IOException {
requirePermission("flush", getTableName(e.getEnvironment()), null, null, Action.CREATE);
}
@Override
public void preGetClosestRowBefore(ObserverContext<RegionCoprocessorEnvironment> c, byte[] row, byte[] family, Result result) throws IOException {
requirePermission("getClosestRowBefore", TablePermission.Action.READ, c.getEnvironment(), (family != null ? Lists.newArrayList(family) : null));
}
@Override
public Result preIncrement(ObserverContext<RegionCoprocessorEnvironment> c, Increment increment) throws IOException {
requirePermission("increment", TablePermission.Action.WRITE, c.getEnvironment(), increment.getFamilyCellMap().keySet());
return null;
}
@Override
public long preIncrementColumnValue(ObserverContext<RegionCoprocessorEnvironment> c, byte[] row, byte[] family, byte[] qualifier, long amount, boolean writeToWAL) throws IOException {
requirePermission("incrementColumnValue", TablePermission.Action.READ, c.getEnvironment(), Arrays.asList(new byte[][] { family }));
requirePermission("incrementColumnValue", TablePermission.Action.WRITE, c.getEnvironment(), Arrays.asList(new byte[][] { family }));
return -1;
}
@Override
public void preModifyColumn(ObserverContext<MasterCoprocessorEnvironment> c, TableName tableName, HColumnDescriptor descriptor) throws IOException {
requirePermission("modifyColumn", tableName.getName(), null, null, Action.CREATE);
}
@Override
public void preModifyTable(ObserverContext<MasterCoprocessorEnvironment> c, TableName tableName, HTableDescriptor htd) throws IOException {
requirePermission("modifyTable", tableName.getName(), null, null, Action.CREATE);
}
@Override
public void preMove(ObserverContext<MasterCoprocessorEnvironment> c, HRegionInfo region, ServerName srcServer, ServerName destServer) throws IOException {
requirePermission("move", region.getTable().getName() , null, null, Action.ADMIN);
}
@Override
public void preAbortProcedure(ObserverContext<MasterCoprocessorEnvironment> observerContext, ProcedureExecutor<MasterProcedureEnv> procEnv, long procId) throws IOException {
if(!procEnv.isProcedureOwner(procId, this.getActiveUser())) {
requirePermission("abortProcedure", Action.ADMIN);
}
}
@Override
public void postListProcedures(ObserverContext<MasterCoprocessorEnvironment> observerContext, List<ProcedureInfo> procInfoList) throws IOException {
if(!procInfoList.isEmpty()) {
Iterator<ProcedureInfo> itr = procInfoList.iterator();
User user = this.getActiveUser();
while(itr.hasNext()) {
ProcedureInfo procInfo = itr.next();
try {
if(!ProcedureInfo.isProcedureOwner(procInfo, user)) {
requirePermission("listProcedures", Action.ADMIN);
}
} catch (AccessDeniedException var7) {
itr.remove();
}
}
}
}
@Override
public void preOpen(ObserverContext<RegionCoprocessorEnvironment> e) throws IOException {
RegionCoprocessorEnvironment env = e.getEnvironment();
final Region region = env.getRegion();
if (region == null) {
LOG.error("NULL region from RegionCoprocessorEnvironment in preOpen()");
} else {
HRegionInfo regionInfo = region.getRegionInfo();
if (isSpecialTable(regionInfo)) {
requireSystemOrSuperUser(regionEnv.getConfiguration());
} else {
requirePermission("open", getTableName(e.getEnvironment()), Action.ADMIN);
}
}
}
@Override
public void preRestoreSnapshot(ObserverContext<MasterCoprocessorEnvironment> ctx, SnapshotDescription snapshot, HTableDescriptor hTableDescriptor) throws IOException {
requirePermission("restoreSnapshot", hTableDescriptor.getTableName().getName(), Permission.Action.ADMIN);
}
@Override
public void preScannerClose(ObserverContext<RegionCoprocessorEnvironment> c, InternalScanner s) throws IOException {
requireScannerOwner(s);
}
@Override
public boolean preScannerNext(ObserverContext<RegionCoprocessorEnvironment> c, InternalScanner s, List<Result> result, int limit, boolean hasNext) throws IOException {
requireScannerOwner(s);
return hasNext;
}
@Override
public RegionScanner preScannerOpen(ObserverContext<RegionCoprocessorEnvironment> c, Scan scan, RegionScanner s) throws IOException {
if (LOG.isDebugEnabled()) {
LOG.debug("==> preScannerOpen");
}
try {
RegionCoprocessorEnvironment e = c.getEnvironment();
Map<byte[], NavigableSet<byte[]>> familyMap = scan.getFamilyMap();
String operation = "scannerOpen";
Filter filter = authorizeAccess(operation, Action.READ, e, familyMap);
if (filter == null) {
if (LOG.isDebugEnabled()) {
LOG.debug("preScannerOpen: Access allowed for all families/column. No filter added");
}
} else {
if (LOG.isDebugEnabled()) {
LOG.debug("preScannerOpen: Access allowed for some of the families/column. New filter added.");
}
Filter existingFilter = scan.getFilter();
Filter combinedFilter = combineFilters(filter, existingFilter);
scan.setFilter(combinedFilter);
}
return s;
} finally {
if (LOG.isDebugEnabled()) {
LOG.debug("<== preScannerOpen");
}
}
}
@Override
public void preShutdown(ObserverContext<MasterCoprocessorEnvironment> c) throws IOException {
requirePermission("shutdown", Permission.Action.ADMIN);
}
@Override
public void preSnapshot(ObserverContext<MasterCoprocessorEnvironment> ctx, SnapshotDescription snapshot, HTableDescriptor hTableDescriptor) throws IOException {
requirePermission("snapshot", hTableDescriptor.getTableName().getName(), Permission.Action.ADMIN);
}
@Override
public void preSplit(ObserverContext<RegionCoprocessorEnvironment> e) throws IOException {
requirePermission("split", getTableName(e.getEnvironment()), null, null, Action.ADMIN);
}
@Override
public void preStopMaster(ObserverContext<MasterCoprocessorEnvironment> c) throws IOException {
requirePermission("stopMaster", Permission.Action.ADMIN);
}
@Override
public void preStopRegionServer(ObserverContext<RegionServerCoprocessorEnvironment> env) throws IOException {
requirePermission("stop", Permission.Action.ADMIN);
}
@Override