Skip to main content

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​

Press Play or step through. The underlined names lead to the Glossary.

ClientApplication, browser or KnoxShell
ClientSends the request
Knox GatewayApplies the topology policy
GatewayPicks the topology
AuthenticationValidates the credentials
Identity assertionAsserts the identity
AuthorizationDecides the access
Corporate identityWhere credentials are validated
LDAP/ADHolds the users
Hadoop clusterWhere the service runs
ServiceWebHDFS, for example
Step 1 of 8

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.

  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.
  2. 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.
  3. 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.
  4. 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.
  5. 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.
  6. 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.
  7. 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.
  8. 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.
Figure 1 - A REST request from the client to the cluster service. The gateway identifies the topology from the URL path, and the chain of providers authenticates, asserts the identity and authorizes before dispatching the request to the service.

Architecture​

Clients talk only to the gateway. Each topology connects the gateway to a cluster.

Knox architecture: clients, Gateway with topologies, identity provider and Hadoop clustersREST applications, browsers and KnoxShell send HTTP requests to the Knox Gateway. Each gateway topology describes a Hadoop cluster: a chain of providers (Authentication, Identity assertion and Authorization) and the services the cluster publishes. The authentication provider queries the enterprise identity provider (LDAP/AD) over LDAP. The gateway dispatches the requests over HTTP to the services of each Hadoop cluster, isolated on the network, and records the actions in the audit.ClientsApplicationsREST APIsBrowserWeb interfaces (UIs)KnoxShellDSL and SDKKnox GatewayTopologyCluster 1AuthenticationIdentity assertionAuthorizationServicesWEBHDFSHIVEWEBHBASETopologyCluster 2AuthenticationIdentity assertionAuthorizationServicesWEBHDFSWEBHCATRESOURCEMANAGERAuditEnterprise identityprovider (LDAP/AD)Cluster networkHadoop Cluster 1REST APIs and UIsHadoop Cluster 2REST APIs and UIsHTTPHTTPLDAP
Figure 2 - Knox architecture: clients, Knox Gateway with one topology per cluster, corporate identity provider and Hadoop clusters isolated on the network. The underlined terms lead to the Glossary.

What the figure shows:

  1. 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.
  2. 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.
  3. 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.
  4. Audit records the actions performed on behalf of users and the internal gateway events.
  5. The corporate identity provider, such as an LDAP or an Active Directory, is queried over LDAP by the authentication provider.
  6. 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.
  1. 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.
  2. 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.
  3. 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.
Figure 3 - The Knox configuration levels. The terms beside each level go with that level.

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.

UserIn the browser
BrowserPresents the cookie
KnoxSSOAuthenticates and issues the token
Form-based IDPCollects the credentials
KnoxSSOIssues the SSO token
Corporate identityWhere credentials are validated
LDAP/ADValidates the users
Web interfaceTakes part in the SSO
Participating UIValidates the token
Step 1 of 6

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.

  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.
  2. LDAP or AD validates. Shiro authentication validates the credentials collected in the form against LDAP or Active Directory.
  3. 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.
  4. The token arrives as a cookie. The browser presents the token as a cookie, the KnoxSSO cookie.
  5. 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.
  6. 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.
Figure 4 - KnoxSSO issues a normalized token after authenticating the user, and the participating web interfaces validate the cookie with the token without knowing the identity provider.

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.

How it extends

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​

Available in the TDP editions
EditionVersionDocumentation
TDP Datacenter2.0.0TDP Datacenter components

In TDP Datacenter​

In TDP Datacenter, Knox is the KNOX service, installed and managed by Ambari.

Service components

KNOX_GATEWAY (master, one or more). Component category.

Topologies

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.

Published services

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.

Template providers

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.

Demo LDAP

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.

Gateway

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.

Kerberos

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.

Authorization in Ranger

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.

Secret and logs

The Knox master secret is configurable in knox_master_secret (knox-env), and the gateway log configuration in gateway-log4j2.

Next steps​

Sources​

Apache Knox

Apache Knox - User's Guide

Apache Knox - GitHub