Skip to content

Commit

Permalink
add option to control if https should be secure
Browse files Browse the repository at this point in the history
  • Loading branch information
pwielgolaski committed Jul 1, 2017
1 parent 22d61a4 commit 8c2f379
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import java.util.List;
import java.util.Map;
import java.util.Optional;

public class AuthenticationSchemeProperties {

Expand Down Expand Up @@ -84,4 +85,10 @@ private Map<String, String> getSchemeProperties() {
List<AuthModule<OAuthAuthenticationScheme>> aadAuthModules = loginConfiguration.getConfiguredAuthModules(OAuthAuthenticationScheme.class);
return aadAuthModules.isEmpty() ? null : aadAuthModules.get(0).getProperties();
}

public boolean isAllowInsecureHttps() {
return Optional.ofNullable(getProperty(ConfigKey.allowInsecureHttps))
.map(Boolean::valueOf)
.orElse(true);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ public enum ConfigKey {
clientId,
clientSecret,
scope,
hideLoginForm
hideLoginForm,
allowInsecureHttps
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class OAuthClient {

public OAuthClient(AuthenticationSchemeProperties properties) {
this.properties = properties;
this.httpClient = HttpClientFactory.createClient(true);
this.httpClient = HttpClientFactory.createClient(properties.isAllowInsecureHttps());
}

public String getRedirectUrl(String state) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,15 @@
<span class="grayNote">OAuth scope of this TeamCity server.</span>
</div>
<div>
<label width="100%" for="<%=ConfigKey.scope%>">Hide login form:</label><br/>
<prop:checkboxProperty style="width: 100%;" name="<%=ConfigKey.hideLoginForm.toString()%>"/><br/>
<prop:checkboxProperty uncheckedValue="false" name="<%=ConfigKey.hideLoginForm.toString()%>"/>
<label width="100%" for="<%=ConfigKey.hideLoginForm%>">Hide login form</label><br/>
<span class="grayNote">Hide user/password login form on Teamcity login page.</span>
</div>

<div>
<prop:checkboxProperty uncheckedValue="false" name="<%=ConfigKey.allowInsecureHttps.toString()%>"/>
<label width="100%" for="<%=ConfigKey.allowInsecureHttps%>">Insecure https</label><br/>
<span class="grayNote">Allow insecure https access like invalid certificate (restart required)</span>
</div>
<script type="text/javascript">
BS.TeamCityOAuth.init('#<%=ConfigKey.preset.toString()%>');
</script>

0 comments on commit 8c2f379

Please sign in to comment.