World's most powerful open data catalog for building a high-performance, geo-distributed and federated metadata lake.
Java ai-catalogdata-catalogdatalakefederated-querylakehousemetadatametalakemodel-catalogopendatacatalogskycomputingstratosphere
[#4321] improvement(docs): Update docs for multiple authentication (#4489)
lwyangb6644d8ebb56
diff --git a/docs/security.md b/docs/security.mdindex 190a909414..87aaeed6f9 100644--- a/docs/security.md+++ b/docs/security.md@@ -7,7 +7,7 @@ license: "This software is licensed under the Apache License version 2."## Authentication-Apache Gravitino supports two kinds of authentication mechanisms: simple and OAuth.+Apache Gravitino supports three kinds of authentication mechanisms: simple, OAuth and Kerberos.### Simple mode@@ -34,7 +34,7 @@ Gravitino only supports external OAuth 2.0 servers.First, users need to guarantee that the external correctly configured OAuth 2.0 server supports Bearer JWT.-Then, on the server side, users should set `gravitino.authenticator` as `oauth` and give+Then, on the server side, users should set `gravitino.authenticators` as `oauth` and give`gravitino.authenticator.oauth.defaultSignKey`, `gravitino.authenticator.oauth.serverUri` and`gravitino.authenticator.oauth.tokenPath` a proper value.@@ -58,7 +58,7 @@ GravitinoClient client = GravitinoClient.builder(uri)Gravitino supports Kerberos mode.-For the server side, users should set `gravitino.authenticator` as `kerberos` and give+For the server side, users should set `gravitino.authenticators` as `kerberos` and give`gravitino.authenticator.kerberos.principal` and `gravitino.authenticator.kerberos.keytab` a proper value.For the client side, users can enable `kerberos` mode by the following code:@@ -88,17 +88,18 @@ The URI must use the hostname of server instead of IP.### Server configuration-| Configuration item | Description | Default value | Required | Since version |-|---------------------------------------------------|-----------------------------------------------------------------------------------------------------|-------------------|--------------------------------------------|---------------|-| `gravitino.authenticator` | The authenticator which Gravitino uses, setting as `simple`,`oauth` or `kerberos`. | `simple` | No | 0.3.0 |-| `gravitino.authenticator.oauth.serviceAudience` | The audience name when Gravitino uses OAuth as the authenticator. | `GravitinoServer` | No | 0.3.0 |-| `gravitino.authenticator.oauth.allowSkewSecs` | The JWT allows skew seconds when Gravitino uses OAuth as the authenticator. | `0` | No | 0.3.0 |-| `gravitino.authenticator.oauth.defaultSignKey` | The signing key of JWT when Gravitino uses OAuth as the authenticator. | (none) | Yes if use `oauth` as the authenticator | 0.3.0 |-| `gravitino.authenticator.oauth.signAlgorithmType` | The signature algorithm when Gravitino uses OAuth as the authenticator. | `RS256` | No | 0.3.0 |-| `gravitino.authenticator.oauth.serverUri` | The URI of the default OAuth server. | (none) | Yes if use `oauth` as the authenticator | 0.3.0 |-| `gravitino.authenticator.oauth.tokenPath` | The path for token of the default OAuth server. | (none) | Yes if use `oauth` as the authenticator | 0.3.0 |-| `gravitino.authenticator.kerberos.principal` | Indicates the Kerberos principal to be used for HTTP endpoint. Principal should start with `HTTP/`. | (none) | Yes if use `kerberos` as the authenticator | 0.4.0 |-| `gravitino.authenticator.kerberos.keytab` | Location of the keytab file with the credentials for the principal. | (none) | Yes if use `kerberos` as the authenticator | 0.4.0 |+| Configuration item | Description | Default value | Required | Since version |+|---------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------|--------------------------------------------|---------------|+| `gravitino.authenticator` | It is deprecated since Gravitino 0.6.0. Please use `gravitino.authenticators` instead. | `simple` | No | 0.3.0 |+| `gravitino.authenticators` | The authenticators which Gravitino uses, setting as `simple`,`oauth` or `kerberos`. Multiple authenticators are separated by commas. If a request is supported by multiple authenticators simultaneously, the first authenticator will be used by default | `simple` | No | 0.6.0 |+| `gravitino.authenticator.oauth.serviceAudience` | The audience name when Gravitino uses OAuth as the authenticator. | `GravitinoServer` | No | 0.3.0 |+| `gravitino.authenticator.oauth.allowSkewSecs` | The JWT allows skew seconds when Gravitino uses OAuth as the authenticator. | `0` | No | 0.3.0 |+| `gravitino.authenticator.oauth.defaultSignKey` | The signing key of JWT when Gravitino uses OAuth as the authenticator. | (none) | Yes if use `oauth` as the authenticator | 0.3.0 |+| `gravitino.authenticator.oauth.signAlgorithmType` | The signature algorithm when Gravitino uses OAuth as the authenticator. | `RS256` | No | 0.3.0 |+| `gravitino.authenticator.oauth.serverUri` | The URI of the default OAuth server. | (none) | Yes if use `oauth` as the authenticator | 0.3.0 |+| `gravitino.authenticator.oauth.tokenPath` | The path for token of the default OAuth server. | (none) | Yes if use `oauth` as the authenticator | 0.3.0 |+| `gravitino.authenticator.kerberos.principal` | Indicates the Kerberos principal to be used for HTTP endpoint. Principal should start with `HTTP/`. | (none) | Yes if use `kerberos` as the authenticator | 0.4.0 |+| `gravitino.authenticator.kerberos.keytab` | Location of the keytab file with the credentials for the principal. | (none) | Yes if use `kerberos` as the authenticator | 0.4.0 |The signature algorithms that Gravitino supports follows:@@ -150,7 +151,7 @@ You can follow the steps to set up an OAuth mode Gravitino server.6. You can refer to the [Configurations](gravitino-server-config.md) and append the configurations to the conf/gravitino.conf.```text-gravitino.authenticator = oauth+gravitino.authenticators = oauthgravitino.authenticator.oauth.serviceAudience = testgravitino.authenticator.oauth.defaultSignKey = <the default signing key>gravitino.authenticator.oauth.tokenPath = /oauth2/tokendiff --git a/docs/webui.md b/docs/webui.mdindex 94ebefa152..1fd7ef6b9b 100644--- a/docs/webui.md+++ b/docs/webui.md@@ -18,7 +18,7 @@ Currently, you can integrate [OAuth settings](./security.md) to view, add, modifThe web UI homepage displayed in Gravitino depends on the configuration parameter for OAuth mode, see the details in [Security](./security.md).-Set parameter for `gravitino.authenticator`, [`simple`](#simple-mode) or [`oauth`](#oauth-mode). Simple mode is the default authentication option.+Set parameter for `gravitino.authenticators`, [`simple`](#simple-mode) or [`oauth`](#oauth-mode). Simple mode is the default authentication option. If multiple authenticators are set, the first one is taken by default.:::tipAfter changing the configuration, make sure to restart the Gravitino server.@@ -29,10 +29,10 @@ After changing the configuration, make sure to restart the Gravitino server.### Simple mode```text-gravitino.authenticator = simple+gravitino.authenticators = simple```-Set the configuration parameter `gravitino.authenticator` to `simple`, and the web UI displays the homepage (Metalakes).+Set the configuration parameter `gravitino.authenticators` to `simple`, and the web UI displays the homepage (Metalakes).@@ -43,10 +43,10 @@ The main content displays the existing metalake list.### Oauth mode```text-gravitino.authenticator = oauth+gravitino.authenticators = oauth```-Set the configuration parameter `gravitino.authenticator` to `oauth`, and the web UI displays the login page.+Set the configuration parameter `gravitino.authenticators` to `oauth`, and the web UI displays the login page.:::cautionIf both `OAuth` and `HTTPS` are set, due to the different security permission rules of various browsers, to avoid cross-domain errors,diff --git a/server-common/src/main/java/org/apache/gravitino/server/authentication/AuthenticationFilter.java b/server-common/src/main/java/org/apache/gravitino/server/authentication/AuthenticationFilter.javaindex 3479503d49..8e376738f7 100644--- a/server-common/src/main/java/org/apache/gravitino/server/authentication/AuthenticationFilter.java+++ b/server-common/src/main/java/org/apache/gravitino/server/authentication/AuthenticationFilter.java@@ -68,6 +68,7 @@ public class AuthenticationFilter implements Filter {authData = headerData.nextElement().getBytes(StandardCharsets.UTF_8);}+ // If token is supported by multiple authenticators, use the first by default.Principal principal = null;for (Authenticator authenticator : authenticators) {if (authenticator.supportsToken(authData) && authenticator.isDataFromToken()) {