Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Refresh cached credentials after PreAuthenticate fails#101053

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
rzikm merged 9 commits intodotnet:mainfromrzikm:93340-preauthenticate-refresh
Apr 30, 2024

Conversation

@rzikm
Copy link
Member

@rzikmrzikm commentedApr 15, 2024
edited
Loading

Fixes#93340.

This PR adds logic which, after Pre-Authenticated request fails with 401, checks whether the user supplied creentials are different from the cached ones, and if so, replaces the old (stale) creds with the new ones.

An implementational obstacle was removing the old creds from the preauth cache, because of insufficient API surface of CredentialCache. Therefore:

  • The type was replaced with a simpler internal-only cache type
  • and credential matching (CredentialKey class mostly) was moved to common source and reused.

NetEventSource.Info(pool.PreAuthCredentials,$"Pre-authentication credentials changed, removing Basic credential uri={preAuthCredentialUri}, username={preAuthCredential.UserName}");
}
pool.PreAuthCredentials.Remove(preAuthCredentialUri!,BasicScheme);
}
Copy link
Member

Choose a reason for hiding this comment

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

While we lock the PreAuthCredentials the logic leading to this can run in parallel, right? Do we have concurrency problem whenRemove can throw? Perhaps useTryRemove?

rzikm reacted with thumbs up emoji
Copy link
MemberAuthor

Choose a reason for hiding this comment

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

The method callsDictionary<TKey, TValue>.Remove() internally, which does not throw if the key does not exist in the first place.

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

But considering parallel requests, since we drop the lock between removing the creds and adding new ones, there may be some weird behavior if a parallel request starts when in-between. So I will move the removal to the same lock scope.

Copy link
Member

@wfurtwfurt left a comment

Choose a reason for hiding this comment

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

LGTM

@rzikm
Copy link
MemberAuthor

Test failures are known (HTTP3 tests which were addressed since the pipeline has run).

@rzikmrzikm merged commit3fac575 intodotnet:mainApr 30, 2024
michaelgsharp pushed a commit to michaelgsharp/runtime that referenced this pull requestMay 9, 2024
* Support refreshing credentials in pre-auth cache* Fix minor bug in CredentialCache* Add unit test* Fix tests* Fix tests attempt 2* Merge two lock statements.* Fix build
@karelzkarelz added this to the9.0.0 milestoneMay 14, 2024
Ruihan-Yin pushed a commit to Ruihan-Yin/runtime that referenced this pull requestMay 30, 2024
* Support refreshing credentials in pre-auth cache* Fix minor bug in CredentialCache* Add unit test* Fix tests* Fix tests attempt 2* Merge two lock statements.* Fix build
@github-actionsgithub-actionsbot locked and limited conversation to collaboratorsJun 14, 2024
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.

Reviewers

@wfurtwfurtwfurt approved these changes

Assignees

@rzikmrzikm

Projects

None yet

Milestone

9.0.0

Development

Successfully merging this pull request may close these issues.

HttpClientHandler with PreAuthenticate enabled can't refresh expired password

3 participants

@rzikm@wfurt@karelz

[8]ページ先頭

©2009-2025 Movatter.jp