From ac575f5245c024a31658cfc994177106d9545aa5 Mon Sep 17 00:00:00 2001 From: Justin Mclean Date: Thu, 5 Dec 2024 14:55:44 +1100 Subject: [PATCH] [#5384] Added simple authentication to the Gravitino CLI (#5610) ### What changes were proposed in this pull request? Added simple authentication to the Gravitino CLI ### Why are the changes needed? To support authentication. Fix: #5384 ### Does this PR introduce _any_ user-facing change? No, but adds authentication to the CLI. ### How was this patch tested? Tested locally. --- .../gravitino/cli/GravitinoCommandLine.java | 92 ++++++++++++++++++- .../apache/gravitino/cli/GravitinoConfig.java | 18 +++- .../gravitino/cli/GravitinoOptions.java | 4 + .../gravitino/cli/TestableCommandLine.java | 8 +- .../cli/commands/CatalogDetails.java | 5 +- .../gravitino/cli/commands/Command.java | 61 ++++++++++-- .../cli/commands/MetalakeDetails.java | 4 +- .../gravitino/cli/TestCatalogCommands.java | 2 +- .../gravitino/cli/TestMetalakeCommands.java | 2 +- .../apache/gravitino/cli/TestTagCommands.java | 2 +- docs/cli.md | 32 ++++++- 11 files changed, 206 insertions(+), 24 deletions(-) diff --git a/clients/cli/src/main/java/org/apache/gravitino/cli/GravitinoCommandLine.java b/clients/cli/src/main/java/org/apache/gravitino/cli/GravitinoCommandLine.java index 683efe9f37c..1cfcb97f6e2 100644 --- a/clients/cli/src/main/java/org/apache/gravitino/cli/GravitinoCommandLine.java +++ b/clients/cli/src/main/java/org/apache/gravitino/cli/GravitinoCommandLine.java @@ -30,6 +30,7 @@ import org.apache.commons.cli.CommandLine; import org.apache.commons.cli.HelpFormatter; import org.apache.commons.cli.Options; +import org.apache.gravitino.cli.commands.Command; /* Gravitino Command line */ public class GravitinoCommandLine extends TestableCommandLine { @@ -43,6 +44,8 @@ public class GravitinoCommandLine extends TestableCommandLine { private boolean ignore = false; private String ignoreEnv; private boolean ignoreSet = false; + private String authEnv; + private boolean authSet = false; public static final String CMD = "gcli"; // recommended name public static final String DEFAULT_URL = "http://localhost:8090"; @@ -151,15 +154,19 @@ private void executeCommand() { */ private void handleMetalakeCommand() { String url = getUrl(); + String auth = getAuth(); + String userName = line.getOptionValue(GravitinoOptions.LOGIN); FullName name = new FullName(line); String metalake = name.getMetalakeName(); String outputFormat = line.getOptionValue(GravitinoOptions.OUTPUT); + Command.setAuthenicationMode(auth, userName); + if (CommandActions.DETAILS.equals(command)) { if (line.hasOption(GravitinoOptions.AUDIT)) { newMetalakeAudit(url, ignore, metalake).handle(); } else { - newMetalakeDetails(url, ignore, metalake, outputFormat).handle(); + newMetalakeDetails(url, ignore, outputFormat, metalake).handle(); } } else if (CommandActions.LIST.equals(command)) { newListMetalakes(url, ignore, outputFormat).handle(); @@ -196,10 +203,14 @@ private void handleMetalakeCommand() { */ private void handleCatalogCommand() { String url = getUrl(); + String auth = getAuth(); + String userName = line.getOptionValue(GravitinoOptions.LOGIN); FullName name = new FullName(line); String metalake = name.getMetalakeName(); String outputFormat = line.getOptionValue(GravitinoOptions.OUTPUT); + Command.setAuthenicationMode(auth, userName); + if (CommandActions.LIST.equals(command)) { newListCatalogs(url, ignore, metalake).handle(); return; @@ -211,7 +222,7 @@ private void handleCatalogCommand() { if (line.hasOption(GravitinoOptions.AUDIT)) { newCatalogAudit(url, ignore, metalake, catalog).handle(); } else { - newCatalogDetails(url, ignore, metalake, catalog, outputFormat).handle(); + newCatalogDetails(url, ignore, outputFormat, metalake, catalog).handle(); } } else if (CommandActions.CREATE.equals(command)) { String comment = line.getOptionValue(GravitinoOptions.COMMENT); @@ -248,10 +259,14 @@ private void handleCatalogCommand() { */ private void handleSchemaCommand() { String url = getUrl(); + String auth = getAuth(); + String userName = line.getOptionValue(GravitinoOptions.LOGIN); FullName name = new FullName(line); String metalake = name.getMetalakeName(); String catalog = name.getCatalogName(); + Command.setAuthenicationMode(auth, userName); + if (CommandActions.LIST.equals(command)) { newListSchema(url, ignore, metalake, catalog).handle(); return; @@ -288,11 +303,15 @@ private void handleSchemaCommand() { */ private void handleTableCommand() { String url = getUrl(); + String auth = getAuth(); + String userName = line.getOptionValue(GravitinoOptions.LOGIN); FullName name = new FullName(line); String metalake = name.getMetalakeName(); String catalog = name.getCatalogName(); String schema = name.getSchemaName(); + Command.setAuthenicationMode(auth, userName); + if (CommandActions.LIST.equals(command)) { newListTables(url, ignore, metalake, catalog, schema).handle(); return; @@ -345,10 +364,14 @@ private void handleTableCommand() { /** Handles the command execution for Users based on command type and the command line options. */ protected void handleUserCommand() { String url = getUrl(); + String auth = getAuth(); + String userName = line.getOptionValue(GravitinoOptions.LOGIN); FullName name = new FullName(line); String metalake = name.getMetalakeName(); String user = line.getOptionValue(GravitinoOptions.USER); + Command.setAuthenicationMode(auth, userName); + if (CommandActions.DETAILS.equals(command)) { newUserDetails(url, ignore, metalake, user).handle(); } else if (CommandActions.LIST.equals(command)) { @@ -376,10 +399,14 @@ protected void handleUserCommand() { /** Handles the command execution for Group based on command type and the command line options. */ protected void handleGroupCommand() { String url = getUrl(); + String auth = getAuth(); + String userName = line.getOptionValue(GravitinoOptions.LOGIN); FullName name = new FullName(line); String metalake = name.getMetalakeName(); String group = line.getOptionValue(GravitinoOptions.GROUP); + Command.setAuthenicationMode(auth, userName); + if (CommandActions.DETAILS.equals(command)) { newGroupDetails(url, ignore, metalake, group).handle(); } else if (CommandActions.LIST.equals(command)) { @@ -407,9 +434,13 @@ protected void handleGroupCommand() { /** Handles the command execution for Tags based on command type and the command line options. */ protected void handleTagCommand() { String url = getUrl(); + String auth = getAuth(); + String userName = line.getOptionValue(GravitinoOptions.LOGIN); FullName name = new FullName(line); String metalake = name.getMetalakeName(); + Command.setAuthenicationMode(auth, userName); + String[] tags = line.getOptionValues(GravitinoOptions.TAG); if (tags != null) { tags = Arrays.stream(tags).distinct().toArray(String[]::new); @@ -465,10 +496,14 @@ private String getOneTag(String[] tags) { /** Handles the command execution for Roles based on command type and the command line options. */ protected void handleRoleCommand() { String url = getUrl(); + String auth = getAuth(); + String userName = line.getOptionValue(GravitinoOptions.LOGIN); FullName name = new FullName(line); String metalake = name.getMetalakeName(); String role = line.getOptionValue(GravitinoOptions.ROLE); + Command.setAuthenicationMode(auth, userName); + if (CommandActions.DETAILS.equals(command)) { newRoleDetails(url, ignore, metalake, role).handle(); } else if (CommandActions.LIST.equals(command)) { @@ -486,6 +521,8 @@ protected void handleRoleCommand() { */ private void handleColumnCommand() { String url = getUrl(); + String auth = getAuth(); + String userName = line.getOptionValue(GravitinoOptions.LOGIN); FullName name = new FullName(line); String metalake = name.getMetalakeName(); String catalog = name.getCatalogName(); @@ -493,6 +530,8 @@ private void handleColumnCommand() { String table = name.getTableName(); String column = name.getColumnName(); + Command.setAuthenicationMode(auth, userName); + if (CommandActions.LIST.equals(command)) { newListColumns(url, ignore, metalake, catalog, schema, table).handle(); } else if (CommandActions.CREATE.equals(command)) { @@ -599,10 +638,14 @@ private void handleHelpCommand() { */ private void handleOwnerCommand() { String url = getUrl(); + String auth = getAuth(); + String userName = line.getOptionValue(GravitinoOptions.LOGIN); FullName name = new FullName(line); String metalake = name.getMetalakeName(); String entityName = line.getOptionValue(GravitinoOptions.NAME); + Command.setAuthenicationMode(auth, userName); + if (CommandActions.DETAILS.equals(command)) { newOwnerDetails(url, ignore, metalake, entityName, entity).handle(); } else if (CommandActions.SET.equals(command)) { @@ -626,12 +669,16 @@ private void handleOwnerCommand() { */ private void handleTopicCommand() { String url = getUrl(); + String auth = getAuth(); + String userName = line.getOptionValue(GravitinoOptions.LOGIN); FullName name = new FullName(line); String metalake = name.getMetalakeName(); String catalog = name.getCatalogName(); String schema = name.getSchemaName(); String topic = name.getTopicName(); + Command.setAuthenicationMode(auth, userName); + if (CommandActions.LIST.equals(command)) { newListTopics(url, ignore, metalake, catalog, schema).handle(); } else if (CommandActions.DETAILS.equals(command)) { @@ -664,12 +711,16 @@ private void handleTopicCommand() { */ private void handleFilesetCommand() { String url = getUrl(); + String auth = getAuth(); + String userName = line.getOptionValue(GravitinoOptions.LOGIN); FullName name = new FullName(line); String metalake = name.getMetalakeName(); String catalog = name.getCatalogName(); String schema = name.getSchemaName(); String fileset = name.getFilesetName(); + Command.setAuthenicationMode(auth, userName); + if (CommandActions.DETAILS.equals(command)) { newFilesetDetails(url, ignore, metalake, catalog, schema, fileset).handle(); } else if (CommandActions.LIST.equals(command)) { @@ -742,4 +793,41 @@ public String getUrl() { // Return the default localhost URL return DEFAULT_URL; } + + /** + * Retrieves the Gravitinno authentication from the command line options or the GRAVITINO_AUTH + * environment variable or the Gravitio config file. + * + * @return The Gravitinno authentication, or null if not found. + */ + public String getAuth() { + + // If specified on the command line use that + if (line.hasOption(GravitinoOptions.SIMPLE)) { + return GravitinoOptions.SIMPLE; + } + + // Cache the Gravitino URL environment variable + if (authEnv == null && !authSet) { + authEnv = System.getenv("GRAVITINO_AUTH"); + authSet = true; + } + + // If set return the Gravitino URL environment variable + if (authEnv != null) { + return authEnv; + } + + // Check if the metalake name is specified in the configuration file + GravitinoConfig config = new GravitinoConfig(null); + if (config.fileExists()) { + config.read(); + String configAuth = config.getGravitinoAuth(); + if (configAuth != null) { + return configAuth; + } + } + + return null; + } } diff --git a/clients/cli/src/main/java/org/apache/gravitino/cli/GravitinoConfig.java b/clients/cli/src/main/java/org/apache/gravitino/cli/GravitinoConfig.java index da837c21e56..375073d2cb2 100644 --- a/clients/cli/src/main/java/org/apache/gravitino/cli/GravitinoConfig.java +++ b/clients/cli/src/main/java/org/apache/gravitino/cli/GravitinoConfig.java @@ -36,6 +36,7 @@ public class GravitinoConfig { private String metalake; private String url; private boolean ignore; + private String authentication; /** * Creates a GravitinoConfig object with a specified config file. If no file is provided, it @@ -62,13 +63,14 @@ public boolean fileExists() { } /** - * Reads the configuration file and loads the 'metalake' and 'URL' properties. If the file is not - * found, it is ignored as the config file is optional. + * Reads the configuration file and loads the 'metalake', 'URL' and other properties. If the file + * is not found, it is ignored as the config file is optional. */ public void read() { String metalakeKey = "metalake"; String urlKey = "URL"; String ignoreKey = "ignore"; + String authKey = "auth"; Properties prop = new Properties(); try (FileInputStream stream = new FileInputStream(configFile)) { @@ -89,6 +91,9 @@ public void read() { if (prop.containsKey(ignoreKey)) { ignore = prop.getProperty(ignoreKey).equals("true"); } + if (prop.containsKey(authKey)) { + authentication = prop.getProperty(authKey); + } } /** @@ -126,4 +131,13 @@ public boolean getIgnore() { public String getConfigFile() { return configFile; } + + /** + * Retrieves the Gravitino authentication stored in the configuration. + * + * @return The Gravitino authentication or null if not set. + */ + public String getGravitinoAuth() { + return authentication; + } } diff --git a/clients/cli/src/main/java/org/apache/gravitino/cli/GravitinoOptions.java b/clients/cli/src/main/java/org/apache/gravitino/cli/GravitinoOptions.java index fe09380d40e..aa04fb2f800 100644 --- a/clients/cli/src/main/java/org/apache/gravitino/cli/GravitinoOptions.java +++ b/clients/cli/src/main/java/org/apache/gravitino/cli/GravitinoOptions.java @@ -50,6 +50,8 @@ public class GravitinoOptions { public static final String ROLE = "role"; public static final String AUDIT = "audit"; public static final String FORCE = "force"; + public static final String SIMPLE = "simple"; + public static final String LOGIN = "login"; public static final String COLUMNFILE = "columnfile"; public static final String INDEX = "index"; public static final String DISTRIBUTION = "distribution"; @@ -74,6 +76,8 @@ public Options options() { options.addOption(createArgOption("m", METALAKE, "metalake name")); options.addOption(createSimpleOption("i", IGNORE, "ignore client/sever version check")); options.addOption(createSimpleOption("a", AUDIT, "display audit information")); + options.addOption(createSimpleOption(null, SIMPLE, "simple authentication")); + options.addOption(createArgOption(null, LOGIN, "user name")); options.addOption(createSimpleOption("x", INDEX, "display index information")); options.addOption(createSimpleOption("d", DISTRIBUTION, "display distribution information")); options.addOption(createSimpleOption(PARTITION, "display partition information")); diff --git a/clients/cli/src/main/java/org/apache/gravitino/cli/TestableCommandLine.java b/clients/cli/src/main/java/org/apache/gravitino/cli/TestableCommandLine.java index ac285804e73..47150fe8c36 100644 --- a/clients/cli/src/main/java/org/apache/gravitino/cli/TestableCommandLine.java +++ b/clients/cli/src/main/java/org/apache/gravitino/cli/TestableCommandLine.java @@ -143,8 +143,8 @@ protected MetalakeAudit newMetalakeAudit(String url, boolean ignore, String meta } protected MetalakeDetails newMetalakeDetails( - String url, boolean ignore, String metalake, String outputFormat) { - return new MetalakeDetails(url, ignore, metalake, outputFormat); + String url, boolean ignore, String outputFormat, String metalake) { + return new MetalakeDetails(url, ignore, outputFormat, metalake); } protected ListMetalakes newListMetalakes(String url, boolean ignore, String outputFormat) { @@ -192,8 +192,8 @@ protected CatalogAudit newCatalogAudit( } protected CatalogDetails newCatalogDetails( - String url, boolean ignore, String metalake, String catalog, String outputFormat) { - return new CatalogDetails(url, ignore, metalake, catalog, outputFormat); + String url, boolean ignore, String outputFormat, String metalake, String catalog) { + return new CatalogDetails(url, ignore, outputFormat, metalake, catalog); } protected ListCatalogs newListCatalogs(String url, boolean ignore, String metalake) { diff --git a/clients/cli/src/main/java/org/apache/gravitino/cli/commands/CatalogDetails.java b/clients/cli/src/main/java/org/apache/gravitino/cli/commands/CatalogDetails.java index bebe536fa1c..3f0e758f47e 100644 --- a/clients/cli/src/main/java/org/apache/gravitino/cli/commands/CatalogDetails.java +++ b/clients/cli/src/main/java/org/apache/gravitino/cli/commands/CatalogDetails.java @@ -35,12 +35,13 @@ public class CatalogDetails extends Command { * * @param url The URL of the Gravitino server. * @param ignoreVersions If true don't check the client/server versions match. + * @param outputFormat The output format. * @param metalake The name of the metalake. * @param catalog The name of the catalog. - * @param outputFormat The output format. */ public CatalogDetails( - String url, boolean ignoreVersions, String metalake, String catalog, String outputFormat) { + String url, boolean ignoreVersions, String outputFormat, String metalake, String catalog) { + super(url, ignoreVersions, outputFormat); this.metalake = metalake; this.catalog = catalog; diff --git a/clients/cli/src/main/java/org/apache/gravitino/cli/commands/Command.java b/clients/cli/src/main/java/org/apache/gravitino/cli/commands/Command.java index 1753e574300..2bedc37a08f 100644 --- a/clients/cli/src/main/java/org/apache/gravitino/cli/commands/Command.java +++ b/clients/cli/src/main/java/org/apache/gravitino/cli/commands/Command.java @@ -19,6 +19,8 @@ package org.apache.gravitino.cli.commands; +import static org.apache.gravitino.client.GravitinoClientBase.Builder; + import org.apache.gravitino.cli.outputs.PlainFormat; import org.apache.gravitino.cli.outputs.TableFormat; import org.apache.gravitino.client.GravitinoAdminClient; @@ -33,6 +35,9 @@ public abstract class Command { public static String OUTPUT_FORMAT_TABLE = "table"; public static String OUTPUT_FORMAT_PLAIN = "plain"; + protected static String authentication = null; + protected static String userName = null; + /** * Command constructor. * @@ -40,15 +45,35 @@ public abstract class Command { * @param ignoreVersions If true don't check the client/server versions match. */ public Command(String url, boolean ignoreVersions) { - this(url, ignoreVersions, null); + this.url = url; + this.ignoreVersions = ignoreVersions; + this.outputFormat = OUTPUT_FORMAT_PLAIN; } + /** + * Command constructor. + * + * @param url The URL of the Gravitino server. + * @param ignoreVersions If true don't check the client/server versions match. + * @param outputFormat output format used in some commands + */ public Command(String url, boolean ignoreVersions, String outputFormat) { this.url = url; this.ignoreVersions = ignoreVersions; this.outputFormat = outputFormat; } + /** + * Sets the authentication mode and user credentials for the command. + * + * @param authentication the authentication mode to be used (e.g. "simple") + * @param userName the username associated with the authentication mode + */ + public static void setAuthenicationMode(String authentication, String userName) { + Command.authentication = authentication; + Command.userName = userName; + } + /** All commands have a handle method to handle and run the required command. */ public abstract void handle(); @@ -60,11 +85,22 @@ public Command(String url, boolean ignoreVersions, String outputFormat) { * @throws NoSuchMetalakeException if the specified metalake does not exist. */ protected GravitinoClient buildClient(String metalake) throws NoSuchMetalakeException { + Builder client = GravitinoClient.builder(url).withMetalake(metalake); + if (ignoreVersions) { - return GravitinoClient.builder(url).withMetalake(metalake).withVersionCheckDisabled().build(); - } else { - return GravitinoClient.builder(url).withMetalake(metalake).build(); + client = client.withVersionCheckDisabled(); + } + if (authentication != null) { + if (authentication.equals("simple")) { + if (userName != null && !userName.isEmpty()) { + client = client.withSimpleAuth(userName); + } else { + client = client.withSimpleAuth(); + } + } } + + return client.build(); } /** @@ -73,11 +109,22 @@ protected GravitinoClient buildClient(String metalake) throws NoSuchMetalakeExce * @return A configured {@link GravitinoAdminClient} instance. */ protected GravitinoAdminClient buildAdminClient() { + Builder client = GravitinoAdminClient.builder(url); + if (ignoreVersions) { - return GravitinoAdminClient.builder(url).withVersionCheckDisabled().build(); - } else { - return GravitinoAdminClient.builder(url).build(); + client = client.withVersionCheckDisabled(); } + if (authentication != null) { + if (authentication.equals("simple")) { + if (userName != null && !userName.isEmpty()) { + client = client.withSimpleAuth(userName); + } else { + client = client.withSimpleAuth(); + } + } + } + + return client.build(); } /** diff --git a/clients/cli/src/main/java/org/apache/gravitino/cli/commands/MetalakeDetails.java b/clients/cli/src/main/java/org/apache/gravitino/cli/commands/MetalakeDetails.java index 127b9a5846c..592317af4e6 100644 --- a/clients/cli/src/main/java/org/apache/gravitino/cli/commands/MetalakeDetails.java +++ b/clients/cli/src/main/java/org/apache/gravitino/cli/commands/MetalakeDetails.java @@ -33,10 +33,10 @@ public class MetalakeDetails extends Command { * * @param url The URL of the Gravitino server. * @param ignoreVersions If true don't check the client/server versions match. - * @param metalake The name of the metalake. * @param outputFormat The output format. + * @param metalake The name of the metalake. */ - public MetalakeDetails(String url, boolean ignoreVersions, String metalake, String outputFormat) { + public MetalakeDetails(String url, boolean ignoreVersions, String outputFormat, String metalake) { super(url, ignoreVersions, outputFormat); this.metalake = metalake; } diff --git a/clients/cli/src/test/java/org/apache/gravitino/cli/TestCatalogCommands.java b/clients/cli/src/test/java/org/apache/gravitino/cli/TestCatalogCommands.java index c337a342cf8..10c25f8f898 100644 --- a/clients/cli/src/test/java/org/apache/gravitino/cli/TestCatalogCommands.java +++ b/clients/cli/src/test/java/org/apache/gravitino/cli/TestCatalogCommands.java @@ -82,7 +82,7 @@ void testCatalogDetailsCommand() { doReturn(mockDetails) .when(commandLine) .newCatalogDetails( - GravitinoCommandLine.DEFAULT_URL, false, "metalake_demo", "catalog", null); + GravitinoCommandLine.DEFAULT_URL, false, null, "metalake_demo", "catalog"); commandLine.handleCommandLine(); verify(mockDetails).handle(); } diff --git a/clients/cli/src/test/java/org/apache/gravitino/cli/TestMetalakeCommands.java b/clients/cli/src/test/java/org/apache/gravitino/cli/TestMetalakeCommands.java index 2b94a80a9b8..b7468b635a4 100644 --- a/clients/cli/src/test/java/org/apache/gravitino/cli/TestMetalakeCommands.java +++ b/clients/cli/src/test/java/org/apache/gravitino/cli/TestMetalakeCommands.java @@ -78,7 +78,7 @@ void testMetalakeDetailsCommand() { mockCommandLine, mockOptions, CommandEntities.METALAKE, CommandActions.DETAILS)); doReturn(mockDetails) .when(commandLine) - .newMetalakeDetails(GravitinoCommandLine.DEFAULT_URL, false, "metalake_demo", null); + .newMetalakeDetails(GravitinoCommandLine.DEFAULT_URL, false, null, "metalake_demo"); commandLine.handleCommandLine(); verify(mockDetails).handle(); } diff --git a/clients/cli/src/test/java/org/apache/gravitino/cli/TestTagCommands.java b/clients/cli/src/test/java/org/apache/gravitino/cli/TestTagCommands.java index 91a809fbcfd..ebf87bbba8e 100644 --- a/clients/cli/src/test/java/org/apache/gravitino/cli/TestTagCommands.java +++ b/clients/cli/src/test/java/org/apache/gravitino/cli/TestTagCommands.java @@ -74,7 +74,7 @@ void testListTagsCommand() { } @Test - void testMetalakeDetailsCommand() { + void testTagDetailsCommand() { TagDetails mockDetails = mock(TagDetails.class); when(mockCommandLine.hasOption(GravitinoOptions.METALAKE)).thenReturn(true); when(mockCommandLine.getOptionValue(GravitinoOptions.METALAKE)).thenReturn("metalake_demo"); diff --git a/docs/cli.md b/docs/cli.md index 825267b50a1..c8702ce1132 100644 --- a/docs/cli.md +++ b/docs/cli.md @@ -42,6 +42,7 @@ The general structure for running commands with the Gravitino CLI is `gcli entit -h,--help command help information -i,--ignore ignore client/sever version check -l,--user user name + --login user name -m,--metalake metalake name -n,--name full entity name (dot separated) --null column value can be null (true/false) @@ -54,6 +55,8 @@ The general structure for running commands with the Gravitino CLI is `gcli entit -r,--role role name --rename new entity name -s,--server Gravitino server version + --simple simple authentication + --sortorder display sortorder information -t,--tag tag name -u,--url Gravitino URL (default: http://localhost:8090) -v,--version Gravitino client version @@ -96,6 +99,14 @@ As you need to set the Gravitino URL for every command, you can set the URL in s The command line option overrides the environment variable and the environment variable overrides the configuration file. +### Setting the Gravitino Authentication Type + +The authentication type can also be set in several ways. + +1. Passed in on the command line via the `--simple` flag. +2. Set via the 'GRAVITINO_AUTH' environment variable. +3. Stored in the Gravitino CLI configuration file. + ### Gravitino CLI configuration file The gravitino CLI can read commonly used CLI options from a configuration file. By default, the file is `.gravitino` in the user's home directory. The metalake, URL and ignore parameters can be set in this file. @@ -114,6 +125,9 @@ URL=http://localhost:8090 # Ignore client/server version mismatch ignore=true +# Authentication +auth=simple + ``` ### Potentially unsafe operations @@ -773,7 +787,7 @@ gcli fileset set --name hadoop.schema.fileset --property test --value value gcli fileset remove --name hadoop.schema.fileset --property test ``` -### column commands +### Column commands Note that some commands are not supported depending on what the database supports. @@ -803,5 +817,19 @@ gcli column delete --name catalog_postgres.hr.departments.money gcli column update --name catalog_postgres.hr.departments.value --rename values gcli column update --name catalog_postgres.hr.departments.values --datatype "varchar(500)" gcli column update --name catalog_postgres.hr.departments.values --position name -gcli column update --name catalog_postgres.hr.departments.name --null=true +gcli column update --name catalog_postgres.hr.departments.name --null true +``` + +#### Simple authentication + +```bash +gcli --simple +``` + +### Authentication + +#### Simple authentication with user name + +```bash +gcli --simple --login userName ``` \ No newline at end of file