Skip to content

[#561] implementation: get_maximum_permissions_for_path - #602

Open
d-w-moore wants to merge 5 commits into
irods:mainfrom
d-w-moore:561.m
Open

d-w-moore wants to merge 5 commits into
irods:mainfrom
d-w-moore:561.m

Conversation

@d-w-moore

Copy link
Copy Markdown
Collaborator

Check if the user named (may be a user or group) has privilege at or above the given access_level to the collection or data object named by path

@d-w-moore

Copy link
Copy Markdown
Collaborator Author

Needs test.

@d-w-moore
d-w-moore marked this pull request as draft August 2, 2024 04:59
@d-w-moore

Copy link
Copy Markdown
Collaborator Author

Looks as if we won't implement this, at least not in this way. close?

@alanking

alanking commented Dec 2, 2024

Copy link
Copy Markdown
Contributor

I vote we leave it open / in draft until an alternative implementation presents itself. Is there a reason you want to close this?

@d-w-moore

Copy link
Copy Markdown
Collaborator Author

I vote we leave it open / in draft until an alternative implementation presents itself. Is there a reason you want to close this?

No reason. I think we decided it's best implemented as a specific query.

@korydraughn

Copy link
Copy Markdown
Contributor

We need to do more investigative work for #561.

Let's keep this in draft for now. We can circle back once the 3.0.0 milestone is complete.

@d-w-moore

Copy link
Copy Markdown
Collaborator Author

Hm. Looks like I force-pushed over the old branch. Note for the future, don't do that. (Look for pre-existence of the branch name in GitHub. Duh.)

Well, luckily I am very confident of the new code being better....

@d-w-moore d-w-moore self-assigned this Oct 25, 2026
@d-w-moore d-w-moore changed the title [#561] experimental implementation: user_has_access [#561] implementation: get_maximum_permissions_for_path Oct 25, 2026
@d-w-moore

Copy link
Copy Markdown
Collaborator Author

Will mark ready for review once I've run the tests through with rudra's changes included

A query is done to determine the highest permission level the given user
(or group) has on the target collection/data_object.

A specific query will be used if the calling user has the availability,
otherwise a reasonably efficient general query is used instead.
@d-w-moore
d-w-moore marked this pull request as ready for review October 26, 2026 17:12

# Find out if the query is already registered.
try:
specific_query = SpecificQuery(ses, alias='findQueryByAlias', args=('getMaximumPermissionForPath',))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

i think we've leaned into snake case...

Suggested change
specific_query = SpecificQuery(ses, alias='findQueryByAlias', args=('getMaximumPermissionForPath',))
specific_query = SpecificQuery(ses, alias='findQueryByAlias', args=('get_maximum_permission_for_path',))

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

i think we've leaned into snake case...

maybe. It will be the first one using snake case, I guess.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

i think we've done it before. certainly for other policy work that needed them...

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.

Noting here that the SpecificQueries used by the logical quotas REP use snake case. I like snake case, but I don't feel strongly about it either way.

Comment on lines +42 to +50
SQL='''
WITH target_user AS (
SELECT user_id
FROM r_user_main
WHERE user_name = ?
AND zone_name = ?
),
resolved_object AS (
-- The path names a collection

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.

Is there a reason this specific query isn't part of irods/irods rather than the PRC?

@d-w-moore d-w-moore Oct 27, 2026 •

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

It will be. Meanwhile, things work whether or not there is a pre-packaged query. Baby steps I think - as we also haven't yet discussed and definitively decided an alias name for this query.

Is there a reason this specific query isn't part of irods/irods rather than the PRC?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

if it's going to work regardless of whether it's already in the server... then the client code doesn't have to define the specific query... right?

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.

That's correct. We typically do not make clients add SpecificQueries even if it's possible.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I'm down with that.

Comment on lines +121 to +132
# Find out if the query is already registered.
try:
specific_query = SpecificQuery(ses, alias='findQueryByAlias', args=('getMaximumPermissionForPath',))
specific_query.execute()
except CAT_NO_ROWS_FOUND:
specific_query = None
else:
specific_query = SpecificQuery(ses, alias='getUserAccessType', args=specific_query_args)

# If there is no canned query available, and we are a rodsadmin, then install our own:
if not specific_query and ses.users.get(ses.username).type == 'rodsadmin':
specific_query = UserAccessTypeQuery(ses, args=specific_query_args)

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.

Auto-installing a specific query is not how we've done things in the past.

We should just try to use it and if it's there, we're good. If not, use the fallback implementation. No need to test for existence.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

but this is better for testing, in the mean time, so it might be better to leave it there until an iRODS release containing the new specific query.

@korydraughn korydraughn Oct 27, 2026 •

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 for test purposes, have the test explicitly add/remove the SpecificQuery. It's fine if the test tests for existence of the SpecificQuery before adding/removing it.


class AccessManager(Manager):

def get_maximum_permission_for_path(self,

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.

Missing documentation.

Comment thread irods/manager/access_manager.py
Comment on lines +91 to +92
coll=None,
data=None,

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.

Consider using more letters for the parameter names.

coll is pretty obvious, but data isn't.

Comment on lines +93 to +95
force_genquery=False,
feedback=None,
return_type = irods.access.return_type.INTEGER

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.

What do these parameters mean/do?

@d-w-moore d-w-moore Oct 27, 2026 •

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

force_genquery - use genquery regardless of the availability or permissions for using a specific query (good for testing, at present)

feedback - gives caller the method of query used. ('general', 'specific')

return_type - determines whether eg. 'own' or 1200 is returned.

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.

Are feedback and return_type meant for users or testing? Can you explain when someone might use those?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

feedback is of utility for thorough testing , use is only important if the calling application is interested which query type was used. Otherwise we could replace it with logging.

return_type converts the integer to a string such as modify_object or own before returning. I don't know if this is preferable to letting the application do the conversion instead. Thoughts?

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.

feedback is of utility for thorough testing , use is only important if the calling application is interested which query type was used. Otherwise we could replace it with logging.

If it's purely for testing, logging or thorough manual testing is sufficient. You can leave a big fat comment in the code for the next developer to be careful not to break the implementation.

return_type converts the integer to a string such as modify_object or own before returning. I don't know if this is preferable to letting the application do the conversion instead. Thoughts?

Hmm. If the SpecificQuery returns both the symbolic name and integer, then we can return a tuple containing them. Otherwise, I think we should pick one. If we have to pick one, I think the symbolic name is slightly stronger since it's used through out our docs and APIs.

Comment thread irods/access.py
Comment on lines +24 to +26
class return_type(enum.Enum):
INTEGER = 1
STRING = 2

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.

Needs documentation.

Comment thread irods/query.py
return response

def execute(self, limit=MAX_SQL_ROWS, offset=0, options=0, conditions=None):
def execute(self, limit=MAX_SQL_ROWS, offset=0, options=0, conditions=None, instance=None):

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.

What does instance do?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

executes from an alternative instance of the class, other than self. I will review this and make a more complete answer later. Ideally this shouldn't have been necessary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants