Skip to content

Refresh tokens improvements#13168

Merged
Praveen2112 merged 4 commits intotrinodb:masterfrom
s2lomon:refresh-tokens-improvements
Aug 9, 2022
Merged

Refresh tokens improvements#13168
Praveen2112 merged 4 commits intotrinodb:masterfrom
s2lomon:refresh-tokens-improvements

Conversation

@s2lomon
Copy link
Member

@s2lomon s2lomon commented Jul 13, 2022

Description

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

It's a fix of two potential bugs

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

It improves handling of oauth2 refresh tokens

How would you describe this change to a non-technical end user or system administrator?

It makes UI experience smother and prevents us from rejecting possibly correct TokenPairs

Related issues, pull requests, and links

Documentation

(x) 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

  • Improvements to UI when refresh tokens are enabled
  • Fix potential bug in scenarios when refresh-tokens are not obtained from IdP, but are expected
  • Fix a bug with outdated refresh-token on UI
# Section
* Fix some things. ({issue}`issuenumber`)

@s2lomon s2lomon force-pushed the refresh-tokens-improvements branch from 40fe6c9 to d4eef71 Compare July 14, 2022 12:46
@s2lomon s2lomon requested a review from Praveen2112 July 14, 2022 12:46
@s2lomon s2lomon force-pushed the refresh-tokens-improvements branch from f374374 to 579c9b6 Compare July 16, 2022 09:14
Copy link
Member

Choose a reason for hiding this comment

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

Not really related but since you're already making changes in this area we could consider adding additional tokens logging, probably behind flag, to make debugging easier. Similar to Hydra's LOG_LEAK_SENSITIVE_VALUES https://www.ory.sh/docs/ecosystem/logging

Copy link
Member Author

Choose a reason for hiding this comment

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

We can discuss this offline, as it is a potential security issue. Recommendations are that we should not log anything security related, so I'm a bit hesitant.

Copy link
Member

Choose a reason for hiding this comment

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

I agree with @s2lomon we shouldn't be logging any security tokens, passwords, or other sensitive information. Image that the logs can always be read by a malicious party and act accordingly.

Copy link
Member

Choose a reason for hiding this comment

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

cmt msg: into account?

Copy link
Member Author

Choose a reason for hiding this comment

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

done

Copy link
Member

Choose a reason for hiding this comment

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

Typo in cmt msg

Copy link
Member Author

Choose a reason for hiding this comment

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

should be fixed.

Copy link
Member

Choose a reason for hiding this comment

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

Typo in cmt msg

Copy link
Member

Choose a reason for hiding this comment

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

Additional than in the commit message.

Copy link
Member Author

Choose a reason for hiding this comment

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

done.

@Praveen2112 Praveen2112 force-pushed the refresh-tokens-improvements branch from 579c9b6 to b0e7761 Compare July 28, 2022 07:53
@Praveen2112 Praveen2112 requested a review from 11xor6 July 28, 2022 09:36
Copy link
Member

@Praveen2112 Praveen2112 left a comment

Choose a reason for hiding this comment

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

LGTM some minor cleanups.

Copy link
Member

Choose a reason for hiding this comment

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

Isn't this redundant ?

Copy link
Member Author

Choose a reason for hiding this comment

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

no, because this method is a void one (as we modify the response in Filter, rather than creating and returning it). So I need to return somewhere, to stop further processing. Still I will change it to if-else as it seems clearer than this return;

Copy link
Member

Choose a reason for hiding this comment

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

Should this be a part of the next commit ?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think it belongs here, as before we were mixing up handling error from refreshToken flow for api and non api calls.

Copy link
Member

Choose a reason for hiding this comment

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

Additional than in the commit message.

Copy link
Member

Choose a reason for hiding this comment

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

Can we revert this change isValidPrincipal ?

Copy link
Member Author

Choose a reason for hiding this comment

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

It's just a method reordering, as I'm adding few new ones. I've not added this method (although it seems as if I did on diff)

s2lomon added 3 commits August 4, 2022 15:13
- Extract method to keep existing conventions for response creation
- Filter out outdated tokens instead of trying to obtain claims for them
Previously, only requests for ui pages were taken into account
for the token refresh. After this change, every call for
ui - including the api ones to fill existing charts etc.
will benefit from refresh tokens. The end result is that when refresh
token is enabled, user should never be asked to relog, as long as the
site is active and any secure communication goes through to coordinator.
There might be a scenario when refresh token won't be issued, even if
it's expected from trino coordinator. Such cases should be handled gracefully.
@s2lomon s2lomon force-pushed the refresh-tokens-improvements branch from b0e7761 to d5371c2 Compare August 4, 2022 13:20
Copy link
Member

@11xor6 11xor6 left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@lukasz-walkiewicz lukasz-walkiewicz left a comment

Choose a reason for hiding this comment

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

LGTM 👍

When our internal token has been issued for lesser time than the
refresh token from idp or if idp would start to reject already issued
refresh-tokens we need to capture every possible exception and restart
whole login.
@s2lomon s2lomon force-pushed the refresh-tokens-improvements branch from d5371c2 to f9a17d3 Compare August 8, 2022 11:52
@Praveen2112
Copy link
Member

CI hit - reported as #13556, #13557, #13507

@Praveen2112
Copy link
Member

@s2lomon Can you please update the RN here.

@Praveen2112 Praveen2112 merged commit 5c1da02 into trinodb:master Aug 9, 2022
@Praveen2112
Copy link
Member

Thanks for fixing this !!

@github-actions github-actions bot added this to the 393 milestone Aug 9, 2022
@colebow
Copy link
Member

colebow commented Aug 10, 2022

@s2lomon pinging again on the topic of a release note - if you'd like to propose one, I think a bugfix like this would be worth mentioning, especially if any users were running into these bugs.

@s2lomon
Copy link
Member Author

s2lomon commented Aug 10, 2022

@s2lomon pinging again on the topic of a release note - if you'd like to propose one, I think a bugfix like this would be worth mentioning, especially if any users were running into these bugs.

@colebow Sure sorry for that. Take a look at my propositions, as it's fixing few bugs that I've found.

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.

5 participants