-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow fetching file based access provider rules via http(s) url #14008
Conversation
Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to cla@trino.io. Photos, scans, or digitally-signed PDF files are all suitable. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla |
@Praveen2112 Would you like to do a review? |
Will take a look at it |
Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to cla@trino.io. Photos, scans, or digitally-signed PDF files are all suitable. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla |
Hi @kokosing @Praveen2112 I fixed some tests so all checks except plugin/trino-elasticsearch succeeded. plugin/trino-elasticsearch got cancelled (due to exceeding the timeout I guess) but I don't think it is related to changes in this PR (previous run succeeded). Please review and give us some feedback what else should be improved to get this merged |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of reusing FileBasedAccessControl
- can we have a generic Connector/System Access Control based on JsonRules
and have different ways of injecting rules from a file or from a URI (with a specific start point).
@@ -106,12 +105,12 @@ | |||
private final List<SessionPropertyAccessControlRule> sessionPropertyRules; | |||
private final Set<AnySchemaPermissionsRule> anySchemaPermissionsRules; | |||
|
|||
public FileBasedAccessControl(CatalogName catalogName, File configFile) | |||
public FileBasedAccessControl(CatalogName catalogName, Supplier<AccessControlRules> rulesProvider) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we have a different AccessControl
implementation if they are fetched from REST APIs or maybe we could have a generic JsonBasedAccessControl
and rules can be injected from a file or a remote hosted file or using some endpoints. WDYT ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
refactored
...-plugin-toolkit/src/main/java/io/trino/plugin/base/security/FileBasedAccessControlUtils.java
Outdated
Show resolved
Hide resolved
...plugin-toolkit/src/main/java/io/trino/plugin/base/security/FileBasedAccessControlModule.java
Outdated
Show resolved
Hide resolved
plugin/trino-atop/src/main/java/io/trino/plugin/atop/AtopConnectorFactory.java
Outdated
Show resolved
Hide resolved
Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to cla@trino.io. Photos, scans, or digitally-signed PDF files are all suitable. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla |
Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to cla@trino.io. Photos, scans, or digitally-signed PDF files are all suitable. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla |
1 similar comment
Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to cla@trino.io. Photos, scans, or digitally-signed PDF files are all suitable. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you squash the commits. We could have one for preparatory changes and one with the actual set of changes.
@@ -104,12 +103,12 @@ | |||
private final List<SessionPropertyAccessControlRule> sessionPropertyRules; | |||
private final Set<AnySchemaPermissionsRule> anySchemaPermissionsRules; | |||
|
|||
public FileBasedAccessControl(CatalogName catalogName, File configFile) | |||
public FileBasedAccessControl(CatalogName catalogName, Supplier<AccessControlRules> rulesProvider) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we rename it as JsonAccessControl
or something ?
cc: @kokosing Any good names we can use here ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean rename the file/class? We have a few classes starting with FileBasedAccessControl? Do you want to rename all of them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we inject the AccessControlRules
I guess FileBasedAccessControl
makes less sense here. WDYT ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
refactored - renamed to RulesBasedAccessControl
{ | ||
this.catalogName = catalogName.toString(); | ||
|
||
AccessControlRules rules = parseJson(configFile.toPath(), AccessControlRules.class); | ||
checkArgument(!rules.hasRoleRules(), "File connector access control does not support role rules: %s", configFile); | ||
AccessControlRules rules = rulesProvider.get(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
requireNonNull check for supplier ? Any specific reason for supplier ? Can we inject AccessControlRules directly ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
refactored
} | ||
|
||
@Config(SECURITY_CONFIG_FILE) | ||
public FileBasedAccessControlConfig setConfigFile(File configFile) | ||
public FileBasedAccessControlConfig setConfigFilePath(String configFilePath) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we have it as a part of preparatory commit ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I squashed to two commits. Unfortunately this one went to the second one. I won't be able now to extract it and squash other way. If this is a problem I can create another PR with this one as initial commit
...plugin-toolkit/src/main/java/io/trino/plugin/base/security/FileBasedAccessControlConfig.java
Show resolved
Hide resolved
@@ -56,4 +69,9 @@ public FileBasedAccessControlConfig setRefreshPeriod(Duration refreshPeriod) | |||
this.refreshPeriod = refreshPeriod; | |||
return this; | |||
} | |||
|
|||
public boolean isRest() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of checking if it a file or a REST url ? Can we have have some enum which could be configured so we could have dedicated set of properties for each type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
refactored
5f4f5b3
to
b01fe55
Compare
Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to cla@trino.io. Photos, scans, or digitally-signed PDF files are all suitable. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla |
b01fe55
to
4920444
Compare
Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to cla@trino.io. Photos, scans, or digitally-signed PDF files are all suitable. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla |
4920444
to
ba82607
Compare
Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to cla@trino.io. Photos, scans, or digitally-signed PDF files are all suitable. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla |
Hi Guys, The work on this PR has been dragging on for several months. We already invested quite some time and resources to constantly rebase. We're following the same pattern that it's already used in other places when you can configure refresh via HTTP request. An example bellow:
https://trino.io/docs/current/connector/hive-s3.html?highlight=iam#s3-security-mapping We're really grateful Trino community for a such amazing piece of software, so please don't get me wrong. It feels really unproductive on our side to constantly invest more time on the PR and engage in endless discussions. @Praveen2112 @kokosing could you help us with merging this one? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the delay. Thanks for working on this and we really appreciate your effort this PR, we do have a minor concerns which we have specified. Do let us know if there are any issues in applying them.
lib/trino-plugin-toolkit/pom.xml
Outdated
<dependency> | ||
<groupId>io.airlift</groupId> | ||
<artifactId>http-client</artifactId> | ||
<exclusions> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we have to exclude them ? Can we provide a comment here - does the versions conflict ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
io.airlift.node is needed only for tests. If not excluded here dependency-scope-maven-plugin will complain
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where do we use them in tests ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of excluding this - Can we add node
as a rutime dependency
<!-- used by tests but also needed transitively -->
<dependency>
<groupId>io.airlift</groupId>
<artifactId>node</artifactId>
<scope>runtime</scope>
</dependency>
@@ -104,12 +103,12 @@ | |||
private final List<SessionPropertyAccessControlRule> sessionPropertyRules; | |||
private final Set<AnySchemaPermissionsRule> anySchemaPermissionsRules; | |||
|
|||
public FileBasedAccessControl(CatalogName catalogName, File configFile) | |||
public FileBasedAccessControl(CatalogName catalogName, Supplier<AccessControlRules> rulesProvider) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we inject the AccessControlRules
I guess FileBasedAccessControl
makes less sense here. WDYT ?
{ | ||
this.catalogName = catalogName.toString(); | ||
|
||
AccessControlRules rules = parseJson(configFile.toPath(), AccessControlRules.class); | ||
checkArgument(!rules.hasRoleRules(), "File connector access control does not support role rules: %s", configFile); | ||
AccessControlRules rules = rulesProvider.get(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
.in(Scopes.SINGLETON); | ||
httpClientBinder(innerBinder).bindHttpClient("security-http-client", ForAccessControlRules.class) | ||
.withConfigDefaults(config -> config | ||
.setRequestTimeout(Duration.succinctDuration(10, TimeUnit.SECONDS)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any specific reason for setting this configuration to 10s. We could also cofigure them via http-client config if required ?
Mentioned here - #6210 (comment)
{ | ||
} | ||
|
||
public static <R> R parseJSONString(String jsonString, String jsonPointer, Class<R> clazz) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of a static method, can we have something like a parser (S3SecurityMappingsParser
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
refactored - this util doesn't exist any more
config -> !config.isRest(), | ||
innerBinder -> { | ||
innerBinder.bind(new TypeLiteral<Supplier<AccessControlRules>>() {}) | ||
.toProvider(() -> new LocalFileAccessControlRulesProvider<>(configuration, AccessControlRules.class)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we inject this Supplier
instead of specifying a Provider
implementation ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this case we don't have to build the configuration here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
refactored
...plugin-toolkit/src/main/java/io/trino/plugin/base/security/FileBasedAccessControlModule.java
Show resolved
Hide resolved
...plugin-toolkit/src/main/java/io/trino/plugin/base/security/FileBasedAccessControlModule.java
Show resolved
Hide resolved
try { | ||
refreshPeriod = config.getRefreshPeriod(); | ||
} | ||
catch (IllegalArgumentException e) { | ||
throw invalidRefreshPeriodException(config, configFilePath); | ||
} | ||
if (refreshPeriod.toMillis() == 0) { | ||
throw invalidRefreshPeriodException(config, configFilePath); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we move this validation part of the config like public Optional<@MinDuration("1ms") Duration>
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can use Optional
too. Maybe it could go as a preparatory commit. WDYT ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
refactored - actually it was dead code - refreshperiod validation are based on annotations and included in config class
public RulesProvider(FileBasedAccessControlConfig config, Class<R> clazz) | ||
{ | ||
this.clazz = requireNonNull(clazz); | ||
this.jsonPointer = requireNonNull(config.getJsonPointer()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need this jsonPointer
for LocalFileBasedImpl
since in the docs it has been restricted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
jsonPointer is only for rest based config now
Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to cla@trino.io. Photos, scans, or digitally-signed PDF files are all suitable. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla |
Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to cla@trino.io. Photos, scans, or digitally-signed PDF files are all suitable. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla |
Can you please squash the commits. |
Thank you for your pull request and welcome to the Trino community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. Continue to work with us on the review and improvements in this PR, and submit the signed CLA to cla@trino.io. Photos, scans, or digitally-signed PDF files are all suitable. Processing may take a few days. The CLA needs to be on file before we merge your changes. For more information, see https://github.com/trinodb/cla |
@Praveen2112 please trigger the checks. Actually the code was refactored quite a lot so most of the comment shouldn't be relevant any more. Please review. |
4f6ed63
to
4d522da
Compare
@Praveen2112 I applied the comments. Please review |
.initialize(); | ||
|
||
lifeCycleManager = injector.getInstance(LifeCycleManager.class); | ||
baseUri = injector.getInstance(io.airlift.http.server.testing.TestingHttpServer.class).getBaseUrl(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of getting instance of TestingHttpServer
- can we fetch HttpServerInfo
and get the Url based on it ? So we don't specify a class name with package.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
.setRequestTimeout(Duration.succinctDuration(10, TimeUnit.SECONDS)) | ||
.setSelectorCount(1) | ||
.setMinThreads(1)); | ||
binder.bind(AccessControlRulesRestExtractor.class); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to specify the scope as Singleton
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
return () -> parseJson(readFile(configFile), config.getJsonPointer(), FileBasedSystemAccessControlRules.class); | ||
} | ||
|
||
private String readFile(File configFile) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JsonUtils
has a method to read input from file - can we use that implementation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
refactored
configBinder(binder).bindConfig(FileBasedAccessControlConfig.class); | ||
install(conditionalModule( | ||
FileBasedAccessControlConfig.class, | ||
systemAccessControlConfig -> systemAccessControlConfig.isHttp(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use lambda here ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
{ | ||
configBinder(binder).bindConfig(FileBasedAccessControlConfig.class); | ||
install(conditionalModule( | ||
FileBasedAccessControlConfig.class, | ||
accessControlConfig -> accessControlConfig.isHttp(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can use lambda here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
|
||
public boolean isHttp() | ||
{ | ||
if (configFile.startsWith("https://") || configFile.startsWith("http://")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we something like this - return configFile.startsWith("https://") || configFile.startsWith("http://"))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@AssertTrue(message = "Config file does not exist.") | ||
public boolean isConfigFileValid() | ||
{ | ||
if (Objects.nonNull(configFile) && !isHttp() && !new File(configFile).exists()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't have to add non-null check here - Can we move it to the end of class ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm not sure if we don't need non-null check here. We have NotNull validation for configFile field. You shouldn't relay on order of validations, If I remove this non-null check we might (and will in this case) end up with NPE instead of NotNull validation failure
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Custom validation happens after the getter/setter validation happens - so NotNull
will be checked already. I think this non-null check would be redundant
return accessControlRulesProvider; | ||
} | ||
|
||
private String readFile(File configFile) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
FileBasedAccessControlConfig fileBasedAccessControlConfig = injector.getInstance(FileBasedAccessControlConfig.class); | ||
String configFileName = fileBasedAccessControlConfig.getConfigFile().getPath(); | ||
String configFile = fileBasedAccessControlConfig.getConfigFile(); | ||
Supplier<FileBasedSystemAccessControlRules> rulesProvider = injector.getInstance(Key.get(new TypeLiteral<Supplier<FileBasedSystemAccessControlRules>>() {})); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can make it to be in-sync with FileBasedConnectorAccessControl
implementation - Like we can we have a prep commit - which would introduce this a new FileBasedSystemAccessControlModule()
which would inject a SystemAccessControl
(wrapped with refresh option if required) and here we could configure the injector - to get an instance of the SystemAccessControl
- this would make the design uniform and simple. WDYT ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added prep commit with this refactoring before applying any new changes
8df2a0f
to
31c9159
Compare
Hi @Praveen2112 I applied the comments. please review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor changes
} | ||
|
||
@Inject | ||
@Provides |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@singleton annotation is missing.
@@ -15,6 +15,7 @@ | |||
|
|||
import com.google.common.collect.ImmutableMap; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we rename the commit message as Extract new module for FileBasedSystemAccessControl
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@@ -819,23 +820,23 @@ public void testRefreshing() | |||
public void testAllowModeIsRequired() | |||
{ | |||
assertThatThrownBy(() -> newAccessControlManager(createTestTransactionManager(), "catalog_allow_unset.json")) | |||
.isInstanceOf(IllegalArgumentException.class) | |||
.hasMessageStartingWith("Invalid JSON file"); | |||
.isInstanceOf(ProvisionException.class) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need this change in this commit ?
@@ -0,0 +1,714 @@ | |||
/* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Try to keep the commit message less than 75 character length.
import static java.lang.String.format; | ||
import static java.util.Objects.requireNonNull; | ||
|
||
public class AccessControlRulesRestExtractor |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit : Can we rename it as RestBasedAccessControlRulesProvider
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
HttpBasedAccessControlRulesProvider? to stick to the convention and avoid rest?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
public <R> R extract(Class<R> clazz) | ||
{ | ||
String body = getRawJsonString(); | ||
return parseJson(body, jsonPointer, clazz); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we inline body
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@AssertTrue(message = "Config file does not exist.") | ||
public boolean isConfigFileValid() | ||
{ | ||
if (Objects.nonNull(configFile) && !isHttp() && !new File(configFile).exists()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Custom validation happens after the getter/setter validation happens - so NotNull
will be checked already. I think this non-null check would be redundant
|
||
public class FileBasedAccessControlConfig | ||
{ | ||
public static final String SECURITY_CONFIG_FILE = "security.config-file"; | ||
public static final String SECURITY_REFRESH_PERIOD = "security.refresh-period"; | ||
public static final String SECURITY_JSON_POINTER = "security.json-pointer"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we inline this string
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
.setConfigFile(securityConfigUrl) | ||
.setRefreshPeriod(Duration.valueOf("1ms")) | ||
.setJsonPointer("/data")); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test for non-existing file ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it was already added in testValidationWithLocalFile
@Praveen2112 Regarding this one #14008 (comment) we need to change the test in this commit. After refactoring FileBasedSystemAccessControl they failed (different exception thrown) |
31c9159
to
79be898
Compare
@Praveen2112 comments applied |
79be898
to
4d8dce0
Compare
Hi @mosabua could you please have a look at docs change? |
4d8dce0
to
e99cb89
Compare
e99cb89
to
eedbc7f
Compare
eedbc7f
to
05ce7ae
Compare
Merged !! Thanks for working on this |
Thanks!! |
Description
This is actually replacement for #11491
The changes are integrated with the newest trino code
New fork created as we don't have write permission to https://github.com/clemensvonschwerin/presto/tree/file-system-based-access-provider-via-rest
Would like to move it forward and finally get merged to official trino codebase
Related issues, pull requests, and links
Documentation
( ) No documentation is needed.
( ) Sufficient documentation is included in this PR.
( ) Documentation PR is available with #prnumber.
( ) Documentation issue #issuenumber is filed, and can be handled later.
Release notes
( ) No release notes entries required.
(x) Release notes entries required with the following suggested text: