Skip to content

Register event listeners for default system access control#11632

Merged
kokosing merged 2 commits intotrinodb:masterfrom
gaurav8297:guarav8297/default_system_access_control
Mar 23, 2022
Merged

Register event listeners for default system access control#11632
kokosing merged 2 commits intotrinodb:masterfrom
gaurav8297:guarav8297/default_system_access_control

Conversation

@gaurav8297
Copy link
Copy Markdown
Member

Description

Is this change a fix, improvement, new feature, refactoring, or other?

It's a fix

Is this a change to the core query engine, a connector, client library, or the SPI interfaces? (be specific)

Its part of the core engine security

Main problem

Right now if you extend and set default access control to something else using an optional binder, then there will be a problem because event listeners won't get registered.

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.
( ) Release notes entries required with the following suggested text:

# Section
* Fix some things. ({issue}`issuenumber`)

@cla-bot cla-bot bot added the cla-signed label Mar 23, 2022
@gaurav8297 gaurav8297 requested review from kokosing and ksobolew March 23, 2022 11:25
Copy link
Copy Markdown
Contributor

@ksobolew ksobolew left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right now if you extend and set default access control to something else using an optional binder, then there will be a problem because event listeners won't get registered.

I'm not sure how the optional binders are related?

On that note, an explanation of the issue in the commit message would be appreciated :)

Comment on lines 189 to +190
@VisibleForTesting
protected void setSystemAccessControl(String name, Map<String, String> properties)
public void loadSystemAccessControl(String name, Map<String, String> properties)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it's public, does the @VisibleForTesting still make sense?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think so. It's being used only in tests other than this class itself

Comment on lines +203 to +204
systemAccessControl.getEventListeners()
.forEach(eventListenerManager::addEventListener);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would move it to the no-argument loadSystemAccessControl(), mostly because this is also where the even listeners are registered for the non-default access controls. This ways it's clearer why this has to be done.

But then you'll have to change TestingAccessControlManager to call loadSystemAccessControl() instead (and orchestrate all the configuration set-up I presume). Do you think this is feasible?

Copy link
Copy Markdown
Member Author

@gaurav8297 gaurav8297 Mar 23, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But then we would need to move out factory.create(..) from setSystemAccessControl(String name, Map<String, String> properties) to loadSystemAccessControl() because without initializing systemAccessControl, we can't register event listeners.

Also in a way setSystemAccessControl(String name...) is loading system access control from the name so I think it's fine

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK then. This was my thought from looking around the code, as I wanted to understand the context of this change.

@gaurav8297
Copy link
Copy Markdown
Member Author

I'm not sure how the optional binders are related?

Yes, It's not related. I'm just pointing out that is one of the ways someone could extend.

@kokosing kokosing merged commit c66df04 into trinodb:master Mar 23, 2022
@kokosing
Copy link
Copy Markdown
Member

@mosabua No release notes are needed here.

@kokosing
Copy link
Copy Markdown
Member

Merged, thanks!

@github-actions github-actions bot added this to the 375 milestone Mar 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

3 participants