Skip to content
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

Make user search GDPR compliant #927

Merged

Conversation

eljulians
Copy link
Contributor

The username field is deprecated and Jira is gradually removing it
from the cloud instances. This is the second time such changes break
our integrations; until now, our workaround consisted of first searching
for the user based on the email, and then use the account id from the
response for the other requests. But now we cannot search anymore for
users based on the email, and we need to use the query field. Even if
we just pass the same exact value we passed to username.

I can imagine there're several places in the code that would require of
being changed for being completely GDPR compliant, but I have no time
at the moment to fix all of them :(

Thanks for your work!

@eliaschneider
Copy link

LGTM, A great pull request!

eliaschneider
eliaschneider previously approved these changes Apr 16, 2020
Copy link

@eliaschneider eliaschneider left a comment

Choose a reason for hiding this comment

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

LGTM

@eljulians
Copy link
Contributor Author

@eliaschneider Many thanks for such a quick feedback!

Although, I've just noticed the failing Travis build, and from the error message, looks like we won't be able to make it backwards compatible keeping the username field because it's complaining specifically about that: https://travis-ci.com/github/pycontribs/jira/jobs/319921094

How should we proceed here? I'm seeing that the recent PRs that got merged also had failed checks, but the merge is currently blocked. Do you manually sign off on these checks to allow the merges?

jira/client.py Outdated
Comment on lines 2848 to 2849
if user:
params["username"] = user

Choose a reason for hiding this comment

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

@julenpardo Thanks for your efforts on this stuff! We are looking forward for it will be merged! ❤️
Just one question about changes, isn't it redundant to add this check if the username parameter is already in params dictionary ?

"username": user,

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hey @darlev91, thanks for your feedback! You're absolutely right, thanks for the catch! I'll push the change asap

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@darlev91 I've already made the changes, thanks again for the feedback!

Copy link

@darlev91 darlev91 Apr 22, 2020

Choose a reason for hiding this comment

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

@julienadriano Thanks a lot!
What's about query parameter ? It is compatible with both JIRA API versions. I think it's better to keep things simple. Have you had a chance to check this comment?
#927 (comment)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@darlev91 is it? This is actually what @ngenovictor pointed out above. So we can just use the query parameter right away and keep it backwards compatible?

I did it this way just to be 100% sure that it was compatible with both versions, as I can only test it with the latest one, so I would not be sure about replacing the username parameter. But if that's the case, then I can just apply @ngenovictor's suggestion

Choose a reason for hiding this comment

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

@julienadriano yes, if checking JIRA API docs, it says that query parameter is required (can contain not only emailAddress as a value, and displayName too), but it shouldn't replace username because it is separate one:
Link on JIRA API v3
Link on JIRA API v2
I've checked it already and it really works fine for both API versions, so I think it will be better to add it directly in parameters like separate parameter that should be send on API.

Copy link

@darlev91 darlev91 Apr 22, 2020

Choose a reason for hiding this comment

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

@julienadriano @ngenovictor I think this point of view make sense in this case:

def search_users(self, query, username=None, startAt=0, maxResults=50, includeActive=True, includeInactive=False):
     ...
     params = {
            "query": query,
            "username": username,
            "includeActive": includeActive,
            "includeInactive": includeInactive,
        }
     ...

In this case the client code shouldn't be broken if it uses displayName or emailAddress as a query
What do you think about it, guys ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@darlev91 Makes sense to me, I've already pushed the changes

@studioj
Copy link
Collaborator

studioj commented May 14, 2021

likely a duplicate of #940

@studioj
Copy link
Collaborator

studioj commented May 14, 2021

@julenpardo please black jira/client.py and merge in changes from master

@eljulians eljulians force-pushed the julenpardo/gdpr-compliant-user-search branch from 241daa3 to 23ace30 Compare May 14, 2021 08:50
@eljulians
Copy link
Contributor Author

@studioj Thanks for the feedback, I've already pushed the changes, is there something I should do now to trigger the checks?

@studioj
Copy link
Collaborator

studioj commented May 14, 2021

im not too aquianted with jira api but as stated in above review => why add query, if you can query for user ?

i think PR https://github.com/pycontribs/jira/pull/940/files suggests to do this ... would that be ok? or is there a reason not to?

@eljulians
Copy link
Contributor Author

@studioj I probably did it that way to still keep the other parameter for backward compatibility, as the change appeared to be a canary release affecting only some servers

I'm fine with either approach; I did it this way back then in a rush to fix broken production systems :)

The thing is that we pinned the changes made on my branch as dependency, and it's been that way since the PR was open, so I'm aware that change may break some stuff. Let me test this on Monday

@adehad
Copy link
Contributor

adehad commented May 14, 2021

Checking the documentation of

Self-hosted:
https://docs.atlassian.com/software/jira/docs/api/REST/8.13.6/#api/2/user-findUsers
query is not present

Cloud:
https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-user-search/#api-rest-api-2-user-search-get
query and username are present

It seems that query is only really available on Cloud. That would explain the current failures seen on #940 - no users are returned according to the logs:
image

That also explains why this PR passes those same checks.

It seems like the API doesn't have a problem with passing in incorrect parameters, as discussed in other threads on this PR. So I'm happy approving the approach for this PR.

jira/client.py Outdated Show resolved Hide resolved
eljulians and others added 4 commits May 17, 2021 11:00
The `username` field is deprecated and Jira is gradually removing it
from the cloud instances. This is the second time such changes break
our integrations; until now, our workaround consisted of first searching
for the user based on the email, and then use the account id from the
response for the other requests. But now we cannot search anymore for
users based on the email, and we need to use the `query` field. Even if
we just pass the same exact value we passed to `username`.

I can imagine there're several places in the code that would require of
being changed for being completely GDPR compliant, but I have no time
at the moment to fix all of them :(

Thanks for your work!
The payload object was already initialized with the `username` value,
so there's no need to check whether is specified or not.
`query` is a different parameter from `username` so it shouldn't replace
it actually. Tested with v3 API and it's working.
Co-authored-by: adehad <26027314+adehad@users.noreply.github.com>
@eljulians eljulians force-pushed the julenpardo/gdpr-compliant-user-search branch from b69bad7 to 8abc16f Compare May 17, 2021 09:01
@eljulians
Copy link
Contributor Author

Many thanks @adehad! I've already committed the suggestion and rebased the head branch with latest master.

@eljulians eljulians requested a review from adehad May 17, 2021 11:21
@eljulians eljulians force-pushed the julenpardo/gdpr-compliant-user-search branch from fd1bf01 to f42acd3 Compare May 17, 2021 14:54
Copy link
Contributor

@adehad adehad left a comment

Choose a reason for hiding this comment

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

just a few minor comments on the docstring and the typehint docstring format, glad you managed to get through the rebase alright, it was quite a hefty one !

jira/client.py Outdated Show resolved Hide resolved
jira/client.py Outdated Show resolved Hide resolved
jira/client.py Outdated Show resolved Hide resolved
eljulians and others added 3 commits May 17, 2021 18:23
Co-authored-by: adehad <26027314+adehad@users.noreply.github.com>
Co-authored-by: adehad <26027314+adehad@users.noreply.github.com>
Co-authored-by: adehad <26027314+adehad@users.noreply.github.com>
@eljulians
Copy link
Contributor Author

@adehad applied, thank you!

@eljulians
Copy link
Contributor Author

Thanks @adehad for your patience and for approving, what's the process now to merge the PR?

@adehad
Copy link
Contributor

adehad commented May 18, 2021

@julenpardo as I've approved I've requested a review from @ssbarnea who has the permissions for the merge.

We have a somewhat weekly cadence for merging stuff in, most happens on the weekend. But I'm sure this time it won't take a year !

@adehad adehad requested a review from ssbarnea May 18, 2021 09:00
@ssbarnea ssbarnea merged commit b360dcc into pycontribs:master May 18, 2021
@eljulians
Copy link
Contributor Author

Many thanks guys!

@adehad
Copy link
Contributor

adehad commented May 18, 2021

and thank you @julenpardo for your patience ! Hope you contribute in the future too !

@lucasolinden
Copy link

When will this be included in a proper PIP release?

svermeulen pushed a commit to svermeulen/jira that referenced this pull request Oct 31, 2021
* Make user search GDPR compliant

The `username` field is deprecated and Jira is gradually removing it
from the cloud instances. This is the second time such changes break
our integrations; until now, our workaround consisted of first searching
for the user based on the email, and then use the account id from the
response for the other requests. But now we cannot search anymore for
users based on the email, and we need to use the `query` field. Even if
we just pass the same exact value we passed to `username`.

I can imagine there're several places in the code that would require of
being changed for being completely GDPR compliant, but I have no time
at the moment to fix all of them :(

Thanks for your work!

* Remove redundant check

The payload object was already initialized with the `username` value,
so there's no need to check whether is specified or not.

* Init payload iwth both username and query

`query` is a different parameter from `username` so it shouldn't replace
it actually. Tested with v3 API and it's working.

* Update docblock regarding Jira cloud parameters

Co-authored-by: adehad <26027314+adehad@users.noreply.github.com>

* Fix optional `user` param

* Update docblock

Co-authored-by: adehad <26027314+adehad@users.noreply.github.com>

* Update docblock

Co-authored-by: adehad <26027314+adehad@users.noreply.github.com>

* Update docblock

Co-authored-by: adehad <26027314+adehad@users.noreply.github.com>

Co-authored-by: adehad <26027314+adehad@users.noreply.github.com>
@adehad
Copy link
Contributor

adehad commented Nov 10, 2021

FYI @lucasolinden (and others following) this is now included in the pre-release pip install jira==3.1.0rc1 - expect a proper release soon.

@ssbarnea
Copy link
Member

@adehad I just wanted to mention that you have all my support to tag a full release whenever you think is ok. I liked the feedback I seen so far and once we have that release up it should be easier to make new ones w/o having to do pre-releases. If we release often, the need for a pre-release goes down. Thanks for reviving maintenance on jira library!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

search_users - allow search by query
9 participants