-
-
Notifications
You must be signed in to change notification settings - Fork 292
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
Allow connection profiles to use custom STS and OIDC endpoints #14972
Conversation
6fb5dee
to
450138b
Compare
s3/src/main/java/ch/cyberduck/core/sts/STSAssumeRoleTokenExpiredResponseInterceptor.java
Outdated
Show resolved
Hide resolved
.find(host.getProtocol().getOAuthAuthorizationUrl()), this, prompt).build(), host) | ||
.withRedirectUri(host.getProtocol().getOAuthRedirectUrl()) | ||
.withFlowType(OAuth2AuthorizationService.FlowType.valueOf(host.getProtocol().getAuthorization()))); | ||
configuration.addInterceptorLast(sts = new STSAssumeRoleCredentialsRequestInterceptor(oauth, this, trust, key)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As sts
comes last, does this mean we renew oauth
even if STS token is still valid? Is this necessary? Comment on this. Do we have tests for all possible cases?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OAuth should be refreshed first using the standard OAuth2ErrorResponseInterceptor
although it must be verified this actually works as it only handles 401
. We are missing tests cases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OAuth should be refreshed first
This seems not self-evident to me - can you reason why?
If OAuth is refreshed, will this force to renew STS as well even if it is still valid? If yes, is this intended? Which cases should be tested?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Implementation currently is intended as follows
- Refresh of OAuth tokens when expired preemptively in
OAuth2RequestInterceptor
1 - Refresh STS tokens using cached OAuth token preemptively in
STSAssumeRoleCredentialsRequestInterceptor
2 - On error response handle cases in
STSAssumeRoleTokenExpiredResponseInterceptor
as follows
- On
401
,403
refresh OIDC Id token - On
400
reuse cached OIDC Id token - For both cases above refresh STS tokens
Footnotes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated handling of authentication failures in S3AuthenticationResponseInterceptor
as of 8ea744a.
- Handle
403
and400
- Refresh STS token with cached OIDC Id token when not expired
- Otherwise refresh OIDC Id token first
- On failure refresh STS token with refreshed OIDC Id token
Google OpenID Provider | AWS API | HTTP Status Code | Error Code (in XML response body) |
---|---|---|---|
OpenID Id Token Expired | S3 ListObjects | 1 | |
OpenID Id Token Expired | STS AssumeRoleWithWebIdentity | 400 | ExpiredTokenException 2 |
STS Tokens Expired | S3 ListObjects | 400 | ExpiredToken 3 |
STS Tokens Invalid | S3 ListObjects | 400 | InvalidToken [^4] |
HTTP/1.1 400 Bad Request
x-amzn-RequestId: b6baa352-afcb-4763-a32c-a67d7eb5020b
Content-Type: text/xml
Content-Length: 346
Date: Sun, 13 Aug 2023 10:53:10 GMT
Connection: close
<ErrorResponse xmlns="https://sts.amazonaws.com/doc/2011-06-15/">
<Error>
<Type>Sender</Type>
<Code>ExpiredTokenException</Code>
<Message>Token expired: current date/time 1691923690 must be before the expiration date/time1691878565</Message>
</Error>
<RequestId>b6baa352-afcb-4763-a32c-a67d7eb5020b</RequestId>
</ErrorResponse>
Footnotes
s3/src/main/java/ch/cyberduck/core/s3/S3TokenExpiredResponseInterceptor.java
Outdated
Show resolved
Hide resolved
adff9aa
to
de8f6e1
Compare
.find(host.getProtocol().getOAuthAuthorizationUrl()), this, prompt).build(), host) | ||
.withRedirectUri(host.getProtocol().getOAuthRedirectUrl()) | ||
.withFlowType(OAuth2AuthorizationService.FlowType.valueOf(host.getProtocol().getAuthorization()))); | ||
configuration.addInterceptorLast(sts = new STSAssumeRoleCredentialsRequestInterceptor(oauth, this, trust, key)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OAuth should be refreshed first
This seems not self-evident to me - can you reason why?
If OAuth is refreshed, will this force to renew STS as well even if it is still valid? If yes, is this intended? Which cases should be tested?
s3/src/main/java/ch/cyberduck/core/sts/STSAssumeRoleAuthorizationService.java
Outdated
Show resolved
Hide resolved
s3/src/main/java/ch/cyberduck/core/sts/STSAssumeRoleAuthorizationService.java
Outdated
Show resolved
Hide resolved
s3/src/main/java/ch/cyberduck/core/sts/STSAssumeRoleAuthorizationService.java
Outdated
Show resolved
Hide resolved
631eab4
to
204949f
Compare
dbc86fd
to
a4ad431
Compare
4297378
to
bc2b5d2
Compare
bc2b5d2
to
19c8fc9
Compare
…be identified in keychain.
2ca4ef4
to
ad1c2e5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
…st class not working as expected). Signed-off-by: chenkins <chenkins44@gmail.com>
…ithWebIdentity testcontainer tests. Signed-off-by: chenkins <chenkins44@gmail.com>
ad1c2e5
to
bdfdcf0
Compare
Resolves #13804.