SLA:Service Level Authorization(服务层授权)

  1. sla 通过配置访问策略来控制哪些用户、哪些用户组、哪些机器可以访问特定的服务。
  2. 如果启用了sla (hadoop.security.authorization=true),则每次服务端收到rpc请求后,都会对请求做权限检测。RPCServer在收到客户端的rpc请求后会对该请求做sla检测。

  3. 核心代码:

    流程:
    processRpcOutOfBandRequest(RpcRequestHeaderProto header, DataInputStream dis)
    -->org.apache.hadoop.ipc.Server.Connection.processConnectionContext(DataInputStream dis)
    -->org.apache.hadoop.ipc.Server.Connection.authorizeConnection()
    -->org.apache.hadoop.ipc.Server.authorize(UserGroupInformation user, String protocolName, InetAddress addr)
    -->org.apache.hadoop.security.authorize.ServiceAuthorizationManager.authorize(UserGroupInformation user, Class<?> protocol, Configuration conf, InetAddress addr)
        /*** Authorize proxy users to access this server* @throws WrappedRpcServerException - user is not allowed to proxy*/private void authorizeConnection() throws WrappedRpcServerException {try {// If auth method is TOKEN, the token was obtained by the// real user for the effective user, therefore not required to// authorize real user. doAs is allowed only for simple or kerberos// authenticationif (user != null && user.getRealUser() != null&& (authMethod != AuthMethod.TOKEN)) {ProxyUsers.authorize(user, this.getHostAddress());}//用户user从主机(getHostInetAddress())发起了协议protocolName的访问,此处对该访问进行授权authorize(user, protocolName, getHostInetAddress());if (LOG.isDebugEnabled()) {LOG.debug("Successfully authorized " + connectionContext);}rpcMetrics.incrAuthorizationSuccesses();} catch (AuthorizationException ae) {LOG.info("Connection from " + this+ " for protocol " + connectionContext.getProtocol()+ " is unauthorized for user " + user);rpcMetrics.incrAuthorizationFailures();throw new WrappedRpcServerException(RpcErrorCodeProto.FATAL_UNAUTHORIZED, ae);}}/*** Authorize the incoming client connection.* * @param user client user* @param protocolName - the protocol* @param addr InetAddress of incoming connection* @throws AuthorizationException when the client isn't authorized to talk the protocol*/private void authorize(UserGroupInformation user, String protocolName,InetAddress addr) throws AuthorizationException {if (authorize) {if (protocolName == null) {throw new AuthorizationException("Null protocol not authorized");}Class<?> protocol = null;try {protocol = getProtocolClass(protocolName, getConf());} catch (ClassNotFoundException cfne) {throw new AuthorizationException("Unknown protocol: " + protocolName);}serviceAuthorizationManager.authorize(user, protocol, getConf(), addr);}}/*** Authorize the user to access the protocol being used.* * @param user user accessing the service * @param protocol service being accessed* @param conf configuration to use* @param addr InetAddress of the client* @throws AuthorizationException on authorization failure*/public void authorize(UserGroupInformation user, Class<?> protocol,Configuration conf,InetAddress addr) throws AuthorizationException {AccessControlList[] acls = protocolToAcls.get(protocol);MachineList[] hosts = protocolToMachineLists.get(protocol);if (acls == null || hosts == null) {throw new AuthorizationException("Protocol " + protocol + " is not known.");}// get client principal key to verify (if available)KerberosInfo krbInfo = SecurityUtil.getKerberosInfo(protocol, conf);String clientPrincipal = null; if (krbInfo != null) {String clientKey = krbInfo.clientPrincipal();if (clientKey != null && !clientKey.isEmpty()) {try {clientPrincipal = SecurityUtil.getServerPrincipal(conf.get(clientKey), addr);} catch (IOException e) {throw (AuthorizationException) new AuthorizationException("Can't figure out Kerberos principal name for connection from "+ addr + " for user=" + user + " protocol=" + protocol).initCause(e);}}}if((clientPrincipal != null && !clientPrincipal.equals(user.getUserName())) || acls.length != 2  || !acls[0].isUserAllowed(user) || acls[1].isUserAllowed(user)) {AUDITLOG.warn(AUTHZ_FAILED_FOR + user + " for protocol=" + protocol+ ", expected client Kerberos principal is " + clientPrincipal);throw new AuthorizationException("User " + user + " is not authorized for protocol " + protocol + ", expected client Kerberos principal is " + clientPrincipal);}if (addr != null) {String hostAddress = addr.getHostAddress();if (hosts.length != 2 || !hosts[0].includes(hostAddress) ||hosts[1].includes(hostAddress)) {AUDITLOG.warn(AUTHZ_FAILED_FOR + " for protocol=" + protocol+ " from host = " +  hostAddress);throw new AuthorizationException("Host " + hostAddress +" is not authorized for protocol " + protocol) ;}}AUDITLOG.info(AUTHZ_SUCCESSFUL_FOR + user + " for protocol="+protocol);}

    ServiceAuthorizationManager维护了 协议与用户、主机的映射关系,包括白名单和黑名单,支持动态刷新。

转载于:https://my.oschina.net/u/3987818/blog/3093732

hadoop SLA相关推荐

  1. 服务器搭建hue_Hue安装配置实践

    Hue是一个开源的Apache Hadoop UI系统,最早是由Cloudera Desktop演化而来,由Cloudera贡献给开源社区,它是基于Python Web框架Django实现的.通过使用 ...

  2. 大数据开发hadoop核心的分布式消息系统:Apache Kafka 你知道吗

    简介 Apache Kafka是分布式发布-订阅消息系统.它最初由LinkedIn公司开发,之后成为Apache项目的一部分.Kafka是一种快速.可扩展的.设计内在就是分布式的,分区的和可复制的提交 ...

  3. Hadoop—常见面试题

    Hadoop面试中6个常见的问题及答案 准备好面试了吗?呀,需要Hadoop的知识!!?不要慌!这里有一些可能会问到的问题以及你应该给出的答案. Q1.什么是Hadoop? Hadoop是一个开源软件 ...

  4. hadoop常见面试题

    Q1.什么是 Hadoop? Hadoop 是一个开源软件框架,用于存储大量数据,并发处理/查询在具有多个商用硬件(即低成本硬件)节点的集群上的那些数据.总之,Hadoop 包括以下内容: HDFS( ...

  5. hadoop 传感器数据_读取模式错误,计算引擎操作复杂……面对Hadoop这些问题该如何应对?...

    作者 | Monte Zweben 译者 | 天道酬勤,责编 | Carol 封图 | CSDN 付费下载自视觉中国 Apache Hadoop于2006年出现在IT领域,它使用商品硬件,为组织提供前 ...

  6. Snowflake如日中天是否代表Hadoop已死?大数据体系到底是什么?

    简介: 本文作者关涛是大数据系统领域的资深专家,在微软(互联网/Azure云事业群)和阿里巴巴(阿里云)经历了大数据发展20年过程中的后15年.本文试从系统架构的角度,就大数据架构热点,每条技术线的发 ...

  7. 读取模式错误,计算引擎操作复杂……面对Hadoop这些问题该如何应对?

    作者 | Monte Zweben 译者 | 天道酬勤,责编 | Carol 封图 | CSDN 付费下载自视觉中国 Apache Hadoop于2006年出现在IT领域,它使用商品硬件,为组织提供前 ...

  8. 云小课 | MRS和自建Hadoop相比,有哪些优势?

    大数据时代企业要发展就必须进行数字化转型,要完成转型,企业需要利用大数据技术打破现有数据孤岛,构建数据分析和运营能力,才能达到降本增效.企业构建大数据平台时会面临如下两种选择:一种是大量购买机器及Ha ...

  9. Hadoop、spark、Flink、Blink、storm介绍

    1.什么是hadoop(搭建集群) Hadoop是由java语言编写的,在分布式服务器集群上存储海量数据并运行分布式分析应用的开源框架,其核心部件是HDFS与MapReduce. HDFS是一个分布式 ...

  10. 大数据Hadoop集群中常用的任务调度框架

    在大数据的集群环境中,经常用到的任务调度框架有如下几个,根据公司的业务的需要选择适合自己的业务调度的框架, 调度框架anzkaban,crontab(Linux自带).zeus(Alibaba).Oo ...

最新文章

  1. CSDN湘苗培优|火热报名中
  2. 虚幻4 控制台_鹅厂新手机游戏开测,虚幻4引擎开发战略游戏,能否超过率土之滨...
  3. Split字符串分割函数
  4. 长按不响应_长周期物料的预测:需求预测的一大难点
  5. Python实训day03am【sort、函数式编程、过滤器、lambda、文本文件读写】
  6. solaris 中挂载usb移动硬盘
  7. 程序员面试金典 - 面试题 16.26. 计算器(栈)
  8. json对象合并的方法
  9. PHP、mysql面试题 (附答案+实现代码)
  10. Activiti工作流(三)——流程变量
  11. C语言十进制转二进制
  12. java list 数据分离_Java(Android)数据结构汇总(一)-- List(下)
  13. 关闭rlogin服务linux,Linux rlogin命令
  14. Python之Eclipse环境下安装与配置
  15. python如何寻找两个相似的文件_如何计算两个文档的相似度(二)
  16. 无土栽培中的物联网技术应用
  17. outlook邮箱显示一直启动中_[转载]Outlook 2016 显示正在启动... 无法进入Outlook的解决方案...
  18. 张孝祥javascript视频教程
  19. BlackBerry Internet Service故障:公司内部同事无法互通邮件,对外联络没有问题
  20. 【年终总结】你好2021,再见2020。

热门文章

  1. word自定义多级编号列表
  2. 美国11月PMI现回落 市场关注10月PCE通膨数据
  3. Linux下Firefox安装flash操作
  4. 肯德尔相关性分析_肯德尔的Tau机器学习相关性
  5. 北大pkuseg分词 和 jieba 分词对比测试,结果出乎意料...
  6. 打开360浏览器显示无法连接服务器错误,最近360浏览器老是无法打开网页,提示错误如图,但是只要刷新就可以打开了,这是怎么回事?...
  7. linux dns权重设置,权重及权重配置
  8. 工作流:如何将Word尾注转换为普通文本格式
  9. 聚名商学院:近六百元在聚名网抢注域名,两年不到卖了八万八千八百八十八元,这就是域名投资的魅力!
  10. 电脑串口延迟/缓冲设置方法