A single entry point
for the cluster's APIs and UIs.
Knox is the Hadoop application gateway: it receives the REST and HTTP requests addressed to the cluster, authenticates and authorizes whoever sends them, and forwards them to the right service, without exposing the cluster's hosts and ports. Follow a request through the gateway, break down the Knox URL, and see the single sign-on of the web interfaces.
Apache Knox is a gateway built as a reverse proxy, in which each topology describes a Hadoop cluster: the providers that apply the security policy and the services that the cluster publishes.
Clients on one side and services on the other talk only through it.
One endpoint
One entry point to the cluster
The gateway exposes a single URL hierarchy that gathers the cluster's REST APIs. The hosts and ports of the services are not visible to those who access them, and fewer network endpoints need to be opened.
At the perimeter
Policy before the service
Authentication, identity federation, service-level authorization and auditing happen at the gateway, in a chain of providers, before the request reaches the cluster.
Per topology
One descriptor per cluster
Each protected cluster has its own topology and its own context path. Writing a descriptor to the Knox topologies directory is enough for the gateway to start serving a new cluster.
On this page
- Follow a request
- Architecture
- The Knox URL
- From topology to provider
- One login, many UIs
- Why Knox
- In the TDP editions
Follow a request
Press Play or step through. The underlined names lead to the Glossary.
1 The client calls the gateway address
The client sends the REST or HTTP request to the Knox address, not to the service address. The URL carries the gateway context path, the name of the cluster topology and the requested service.
- The client calls the gateway address. The client sends the REST or HTTP request to the Knox address, not to the service address. The URL carries the gateway context path, the name of the cluster topology and the requested service.
- The gateway finds the topology. Each cluster protected by Knox has its own context path. The gateway uses it to find the topology, and the chain of providers defined in that topology applies the policy to the request.
- Authentication: who are you?. The authentication provider collects the presented credentials and validates them. The Shiro provider, which ships with Knox, checks BASIC credentials against an LDAP user repository, such as OpenLDAP, Apache DS or Microsoft Active Directory.
- Identity assertion: who the cluster will see. The identity assertion provider tells the cluster the identity that was authenticated at the gateway and applies the principal and group mapping rules that the topology defines. The Default provider, without rules, asserts the principal as it arrived.
- Authorization: can you access it?. The authorization provider compares the user's identity, groups and source IP address with the ACLs of the requested service. The ACLs protect the Hadoop services at the service level. In TDP Datacenter, the Ranger plugin can also decide the access.
- The gateway dispatches to the service. Once the request is approved, the gateway dispatches it to the service, which the topology locates by role and URL, and converts the user-facing URL into the cluster's internal URL.
- The response returns through the gateway. The service response returns to the client through the gateway. The cluster services do not know they are accessed from outside, so the URLs in REST responses usually carry internal host names. The hostmap provider replaces them with the external names.
- Everything is recorded. Knox auditing records the actions performed on behalf of each user, as well as internal gateway events, such as the deployment of a topology.
Architecture
Clients talk only to the gateway. Each topology connects the gateway to a cluster.
What the figure shows:
- The clients, which are the applications with the REST APIs, the browsers with the web interfaces and the KnoxShell with the DSL and the SDK, always talk to the gateway, over HTTP.
- The Knox Gateway works as a reverse proxy: it maintains the mapping between the URLs it exposes and the URLs of the cluster services. With the cluster isolated on the network, it is the single access point to it.
- Each topology describes a Hadoop cluster and takes the requests to it. It gathers a chain of providers, with Authentication, Identity assertion and Authorization, and the services that the cluster publishes.
- Audit records the actions performed on behalf of users and the internal gateway events.
- The corporate identity provider, such as an LDAP or an Active Directory, is queried over LDAP by the authentication provider.
- The Hadoop clusters are isolated on the network, with their REST APIs and UIs. The gateway dispatches the requests to the services of each cluster over HTTP.
Knox also complements the Kerberos-protected cluster.
The Knox URL
A gateway URL has four parts. In the example, the service is WebHDFS.
Click each part of the address.
Gateway address
The host and port where the gateway listens. It is the only address the client needs to know, and it comes from the gateway configuration.
See in the Glossary{gateway-host}:{gateway-port}— Gateway address- The host and port where the gateway listens. It is the only address the client needs to know, and it comes from the gateway configuration.
{gateway-path}— Context path- The gateway context path, also defined in its configuration. The clusters served by the gateway sit under this path.
{cluster-name}— Topology- The name of the topology, which identifies the cluster. Each protected cluster has its own context path, so a single gateway serves several clusters with a single access point.
webhdfs— Service- The cluster service that the topology publishes. Inside the cluster, the same service answers at its own URL, which the gateway converts and which is not visible to the client.
The gateway builds this URL from its configuration and from the topology descriptor, and it is through this URL that the client reaches the service.
The other cluster services, such as WebHCat, HBase and Hive, sit under the same prefix, each with its own name at the end.
From topology to provider
The gateway contains topologies, and each topology contains the providers that apply the policy.
Level 1 of 3
Gateway
The Knox server. It maintains the mapping between the URLs it exposes and the URLs of the cluster services and applies the security policy to each request.
- AuditRecords the actions performed on behalf of users and the internal gateway events. It is built on Log4j, and the implementation can be replaced by another one.
- Gateway. The Knox server. It maintains the mapping between the URLs it exposes and the URLs of the cluster services and applies the security policy to each request.
- Audit. Records the actions performed on behalf of users and the internal gateway events. It is built on Log4j, and the implementation can be replaced by another one.
- Topology. The descriptor of a Hadoop cluster: it gathers the providers that apply the policy and the services that the cluster publishes. The gateway processes the descriptor when it is written to the topologies directory.
- Service. Defines where a service is inside the cluster, through an uppercase role, such as WEBHDFS or HIVE, and a URL. Not every cluster service is exposed as a gateway endpoint.
- Provider. Configures a gateway function. It has a role, a name, the enabled or disabled state and optional params. A topology usually has one provider per role, and a disabled provider drops out of the processing chain.
- Authentication provider. Collects the credentials, validates them and communicates the result to the client or to the rest of the chain. Shiro, which ships with Knox, validates BASIC credentials against an LDAP repository.
- Federation provider. Federates the authenticated identity in an external authentication event. The KnoxSSO form-based IDP, Pac4J and HeaderPreAuth come ready to use.
- Identity assertion. Communicates to the cluster the principal that represents the authenticated identity, applying the principal and group mapping rules.
- Authorization provider. Decides whether the effective user can access the requested resource, evaluating the identity and groups against the access policies.
- Hostmap. Replaces the internal host names that appear in responses with the names by which the cluster is known from the outside.
One login, many UIs
For web interfaces, Knox offers single sign-on (SSO): KnoxSSO does the authenticating, and the UIs only need to recognize a cookie.
1 The user enters the credentials
In the default KnoxSSO configuration, the identity provider is a login form: the user types the credentials, and Knox collects them.
In the Glossary: Form-based IDP · KnoxSSO
- The user enters the credentials. In the default KnoxSSO configuration, the identity provider is a login form: the user types the credentials, and Knox collects them.
- LDAP or AD validates. Shiro authentication validates the credentials collected in the form against LDAP or Active Directory.
- KnoxSSO issues a token. KnoxSSO is an integration service that provides a normalized SSO token to represent the authenticated user, whatever the identity provider behind it.
- The token arrives as a cookie. The browser presents the token as a cookie, the KnoxSSO cookie.
- The UI validates the cookie. The web interfaces that take part in the integration cryptographically validate the token and remain independent of the SSO behind it. They only need to be aware of the KnoxSSO cookie.
- Other providers in place of the form. The federation providers bring other ways to authenticate. Pac4J adds SAML, CAS, OpenID Connect, Google, Twitter and others, and HeaderPreAuth propagates the identity through HTTP headers with the user and the group, as in SiteMinder and IBM Tivoli Access Manager. For the UIs, nothing changes: the cookie still applies.
Why Knox
Simplified access
Fewer services for the client
The client interacts with a single address, not with each cluster service, and access to several clusters sits under the same gateway, each with its own context path.
Hidden cluster
Protected hosts and ports
The cluster's hosts and ports are hidden from those who access it, and fewer network endpoints, and therefore fewer firewall openings, are needed to reach it.
Perimeter
Authentication and authorization
Authentication and token verification at the perimeter, and service-level authorization, by user, group and IP address.
Corporate identity
LDAP, AD, SSO and more
Integrates with enterprise and cloud identity systems: LDAP and Active Directory, header PreAuth, Kerberos, SAML and OAuth.
With Kerberos
Complements the protected cluster
With adequate network isolation, the gateway integrates the Kerberos-protected cluster with enterprise identity management, hides the deployment details and reduces the number of services clients interact with.
Clients
Home page and KnoxShell
The Knox home page serves as an entry point to the published resources, and KnoxShell, which brings together the Groovy shell and the Knox Shell SDK classes, allows scripts over the cluster data.
The gateway was designed as a reverse proxy with pluggability in policy enforcement, through the providers, and in the backend services it proxies. New services and UIs come in through configuration, and the policy covers authentication and federation, authorization, auditing, dispatch, host mapping and content rewrite rules.
In the TDP editions
| Edition | Version | Documentation |
|---|---|---|
| TDP Datacenter | 2.0.0 | TDP Datacenter components |
In TDP Datacenter
In TDP Datacenter, Knox is the KNOX service, installed and managed by Ambari.
KNOX_GATEWAY (master, one or more). Component category.
Topologies are Ambari configuration templates: topology holds the services that Knox publishes, admin-topology holds the administration API and UI, and knoxsso-topology holds the KnoxSSO service. Ambari manages these files, so gateway.read.only.override.topologies makes them read-only in the Knox administration UI, so that Ambari does not overwrite them on restart.
The topology template brings the roles NAMENODE, WEBHDFS, RESOURCEMANAGER, YARNUI, HIVE, WEBHBASE, ZEPPELINUI and ZEPPELINWS, for perimeter access to HDFS, YARN, Hive, HBase and Zeppelin.
The topology template brings the ShiroProvider for authentication, with the LDAP address and the user DN template as provider params, the Default for identity assertion and the AclsAuthz for authorization. The admin-topology template uses the HadoopGroupProvider for identity assertion.
The demo LDAP that ships with Knox is started and stopped in Ambari through the STARTDEMOLDAP and STOPDEMOLDAP commands of the KNOX_GATEWAY component. Its users and groups are in the users-ldif configuration, and its logs in ldap-log4j2.
The gateway port and context path are configurable in gateway.port and gateway.path, and the topologies directory in gateway.gateway.conf.dir, in the gateway-site configuration. WebSocket support can be enabled in gateway.websocket.feature.enabled, the list of allowed dispatch targets in gateway.dispatch.whitelist and gateway.dispatch.whitelist.services, and the users and groups with access to the administration UI and API in gateway.knox.admin.users and gateway.knox.admin.groups.
The gateway knows whether the cluster it protects uses Kerberos through gateway.hadoop.kerberos.secured. The Knox principal and keytab are configurable in knox_principal_name and knox_keytab_path (knox-env), and the krb5 and JAAS login files in java.security.krb5.conf and java.security.auth.login.config.
The Ranger plugin can be enabled in ranger-knox-plugin-enabled (ranger-knox-plugin-properties), and the plugin settings are in ranger-knox-security, ranger-knox-policymgr-ssl and ranger-knox-audit. See Security in TDP Datacenter.
The Knox master secret is configurable in knox_master_secret (knox-env), and the gateway log configuration in gateway-log4j2.
Next steps
TDP Datacenter
TDP Datacenter Architecture
The services of the Ambari-managed cluster and how they relate.