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

Do not set 'realm=Quarkus' in Basic auth challenge #27342

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -23,6 +23,7 @@ public class CombinedFormBasicAuthTestCase {

private static final String APP_PROPS = "" +
"quarkus.http.auth.basic=true\n" +
"quarkus.http.auth.realm=TestRealm\n" +
"quarkus.http.auth.form.enabled=true\n" +
"quarkus.http.auth.form.login-page=login\n" +
"quarkus.http.auth.form.error-page=error\n" +
Expand Down Expand Up @@ -154,7 +155,7 @@ public void testBasicAuthFailure() {
.then()
.assertThat()
.statusCode(401)
.header("WWW-Authenticate", equalTo("basic realm=\"Quarkus\""));
.header("WWW-Authenticate", equalTo("basic realm=\"TestRealm\""));

}
}
Expand Up @@ -29,8 +29,8 @@ public class AuthConfig {
/**
* The authentication realm
*/
@ConfigItem(defaultValue = "Quarkus")
public String realm;
@ConfigItem
public Optional<String> realm;

/**
* The HTTP permissions
Expand Down
Expand Up @@ -95,7 +95,7 @@ public BasicAuthenticationMechanism(final String realmName, final boolean silent

public BasicAuthenticationMechanism(final String realmName, final boolean silent,
Charset charset, Map<Pattern, Charset> userAgentCharsets) {
this.challenge = BASIC_PREFIX + "realm=\"" + realmName + "\"";
this.challenge = realmName == null ? BASIC : BASIC_PREFIX + "realm=\"" + realmName + "\"";
this.silent = silent;
this.charset = charset;
this.userAgentCharsets = Collections.unmodifiableMap(new LinkedHashMap<>(userAgentCharsets));
Expand Down
Expand Up @@ -279,7 +279,8 @@ public Supplier<?> setupBasicAuth(HttpBuildTimeConfig buildTimeConfig) {
return new Supplier<BasicAuthenticationMechanism>() {
@Override
public BasicAuthenticationMechanism get() {
return new BasicAuthenticationMechanism(buildTimeConfig.auth.realm, buildTimeConfig.auth.form.enabled);
return new BasicAuthenticationMechanism(buildTimeConfig.auth.realm.orElse(null),
buildTimeConfig.auth.form.enabled);
}
};
}
Expand Down
Expand Up @@ -75,7 +75,7 @@ public void testBasicAuthWrongPassword() {
.when().get("/api/users/me")
.then()
.statusCode(401)
.header("WWW-Authenticate", equalTo("basic realm=\"Quarkus\""));
.header("WWW-Authenticate", equalTo("basic"));
}

@Test
Expand Down Expand Up @@ -144,7 +144,7 @@ public void testVerificationFailedNoBearerTokenAndBasicCreds() {
RestAssured.given()
.when().get("/api/users/me").then()
.statusCode(401)
.header("WWW-Authenticate", equalTo("basic realm=\"Quarkus\""));
.header("WWW-Authenticate", equalTo("basic"));
}

@Test
Expand All @@ -171,7 +171,7 @@ public void testBearerAuthFailureWhereBasicIsRequired() {
.when().get("/basic-only")
.then()
.statusCode(401)
.header("WWW-Authenticate", equalTo("basic realm=\"Quarkus\""));
.header("WWW-Authenticate", equalTo("basic"));
}

@Test
Expand Down