Skip to content

Uniform authentication method for HttpSender#7941

Merged
nielsm5 merged 48 commits intomasterfrom
3045/uniform-authentication-method-for-httpsender
Dec 11, 2024
Merged

Uniform authentication method for HttpSender#7941
nielsm5 merged 48 commits intomasterfrom
3045/uniform-authentication-method-for-httpsender

Conversation

@thomaspj10
Copy link
Contributor

Closes #3045

@thomaspj10 thomaspj10 changed the title Create initial implementation for all current existing authentication methods Uniform authentication method for HttpSender Nov 14, 2024
*/
RESOURCE_OWNER_PASSWORD_CREDENTIALS_QUERY_PARAMETERS;

public IAuthenticator newAuthenticator(AbstractHttpSession session) throws HttpAuthenticationException {
Copy link
Contributor

Choose a reason for hiding this comment

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

Ik zou dit eerder verwachten in AbstractOauthAuthenticator ipv in de enum

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Snap ik. Er zijn veel soorten manieren om te authenticaten, dus AbstractOauthAuthenticator zal niet altijd als superclass gebruikt worden zoals bijvoorbeeld bij saml. Vandaar dat ik het hier neer heb gezet.

Copy link
Contributor

Choose a reason for hiding this comment

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

Dan nog vind ik een enum hier niet de juiste plaats voor

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Waar zou je het dan naar toe verplaatsen?

Copy link
Contributor

Choose a reason for hiding this comment

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

Een AuthenticatorFactory misschien?

Ik vind het zelf nog niet heel storend om het in de enum te doen maar vind het switch-statement niet mooi.

UrlEncodedFormEntity body = new UrlEncodedFormEntity(formParameters, DEFAULT_INPUT_STREAM_ENCODING);

HttpPost request = new HttpPost(uri);
request.addHeader(body.getContentType());
Copy link
Member

Choose a reason for hiding this comment

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

Deze call zou niet moeten hoeven dacht ik, de contenttype van de entity is de default? In de HttpSender doen we het iig niet 😃

Copy link
Contributor Author

Choose a reason for hiding this comment

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

De Content-Type header wordt niet toegevoegd aan de request als ik die regel weghaal.

Copy link
Member

Choose a reason for hiding this comment

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

Dat zou betekenen dat het in de rest can de (huidige) code fout zou zijn. Overal wordt het content type aan de entity gehangen, en de HttpEntityEnclosingRequestBase (HttpPost) zou deze klakkeloos over moeten nemen 🍓

@thomaspj10 thomaspj10 requested a review from nielsm5 November 29, 2024 07:40
@nielsm5 nielsm5 requested a review from tnleeuw December 4, 2024 10:10
Copy link
Contributor

@tnleeuw tnleeuw left a comment

Choose a reason for hiding this comment

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

De meeste opmerkingen die ik heb zijn geloof ik relatief kleinigheden.

*/
RESOURCE_OWNER_PASSWORD_CREDENTIALS_QUERY_PARAMETERS;

public IAuthenticator newAuthenticator(AbstractHttpSession session) throws HttpAuthenticationException {
Copy link
Contributor

Choose a reason for hiding this comment

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

Een AuthenticatorFactory misschien?

Ik vind het zelf nog niet heel storend om het in de enum te doen maar vind het switch-statement niet mooi.

}
}
void testGetAccessToken(AbstractHttpSession.OauthAuthenticationMethod oauthAuthenticationMethod, boolean shouldResolveSuccessfully) throws Exception {
assumeFalse(TestAssertions.isTestRunningOnGitHub());
Copy link
Contributor

Choose a reason for hiding this comment

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

Dit statement komt te laat -- het gaat al lang fout in de static test setup, voordat individuele test-methods worden aangeroepen.

Comment on lines +54 to +55
log.warn("Thread [{}] executing task [{}] exceeds timeout of [{}] s, interrupting. Created from source point:",
timeoutThread.getName(), description, timeout, source);
Copy link
Contributor

Choose a reason for hiding this comment

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

@nielsm5 Hier heb ik iets gesleuteld om te kunnen debuggen waarom een test fout ging -- er werd een TimeoutGuard getriggered waarvan we niet wisten waar die vandaan kwam.

Met deze stacktrace konden we dat wel zien.

Willen we deze extra log er in laten zitten bij iedere warning van een TimeoutGuard? Of willen we dat er conditioneel in hebben / alleen bij loglevel DEBUG?

Copy link
Member

Choose a reason for hiding this comment

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

Het zat er al in (alleen bij debug) toch? als het goed draaien we onze tests ook op dit level. je kan in de if(log.isdebugenabled) een log.error gooien, dan is hij iets prominenter.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ik had een stacktrace toegevoegd aan de warn log.

Ik heb die nu verplaatst naar debug level en de oorspronkelijke warn log hersteld.

String responseBody = EntityUtils.toString(response.getEntity());

if (response.getStatusLine().getStatusCode() != 200) {
tg.cancel();
Copy link
Contributor

Choose a reason for hiding this comment

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

Dit was de missende tg.cancel().
Ik vond het niet de moeite waard om hem te checken en een timeout-exception te gooien, en daarmee dan de status-code line in de exception kwijt te raken.

De tg.cancel() miste omdat ik bij Thomas erop aangedrongen had, het niet in de finally te doen. 🫣

@tnleeuw tnleeuw requested a review from nielsm5 December 10, 2024 16:29
@sonarqubecloud
Copy link

@nielsm5 nielsm5 merged commit 2897169 into master Dec 11, 2024
@nielsm5 nielsm5 deleted the 3045/uniform-authentication-method-for-httpsender branch December 11, 2024 08:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Uniform authentication method for HttpSender

5 participants