All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.hubspot.singularity.config.AuthConfiguration Maven / Gradle / Ivy

package com.hubspot.singularity.config;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.collect.Lists;
import com.hubspot.singularity.auth.authenticator.AuthResponseParser;
import com.hubspot.singularity.auth.dw.SingularityAuthDatastoreClass;
import com.hubspot.singularity.auth.dw.SingularityAuthenticatorClass;
import java.util.HashSet;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;

public class AuthConfiguration {
  @JsonProperty
  private boolean enabled = false;

  @JsonProperty
  @NotNull
  @Deprecated
  private SingularityAuthenticatorClass authenticator =
    SingularityAuthenticatorClass.QUERYPARAM_PASSTHROUGH;

  @JsonProperty
  @NotNull
  private List authenticators = Lists.newArrayList(
    SingularityAuthenticatorClass.QUERYPARAM_PASSTHROUGH
  );

  @JsonProperty
  @NotNull
  private SingularityAuthDatastoreClass datastore = SingularityAuthDatastoreClass.DUMMY;

  @JsonProperty
  @NotNull
  private String requestUserHeaderName = "X-Username"; // used by SingularityHeaderPassthroughAuthenticator

  @JsonProperty
  private int webhookAuthRequestTimeoutMs = 2000;

  @JsonProperty
  private int webhookAuthRetries = 2;

  @JsonProperty
  private int webhookAuthConnectTimeoutMs = 2000;

  @JsonProperty
  private UserAuthMode authMode = UserAuthMode.GROUPS;

  // Properties relevant only for groups-based auth config
  @JsonProperty
  @NotNull
  private Set requiredGroups = new HashSet<>();

  @JsonProperty
  @NotNull
  private Set adminGroups = new HashSet<>();

  // End properties for groups config

  // Properties below relevant for both groups + groups/scopes auth
  @JsonProperty
  @NotNull
  private Set defaultReadOnlyGroups = new HashSet<>();

  @JsonProperty
  @NotNull
  private Set globalReadOnlyGroups = new HashSet<>();

  @JsonProperty
  @NotNull
  private Set jitaGroups = new HashSet<>();

  // End properties for groups + scopes config

  // Properties relevant for scopes auth only
  @JsonProperty
  @NotNull
  private Set globalReadWriteGroups = new HashSet<>();

  @JsonProperty
  @Valid
  private ScopesConfiguration scopes = new ScopesConfiguration();

  @JsonProperty
  private Optional defaultEmailDomain = Optional.empty();

  // end scopes auth config

  @JsonProperty
  private AuthResponseParser authResponseParser = AuthResponseParser.WRAPPED;

  public boolean isEnabled() {
    return enabled;
  }

  public void setEnabled(boolean enabled) {
    this.enabled = enabled;
  }

  @Deprecated
  public SingularityAuthenticatorClass getAuthenticator() {
    return authenticator;
  }

  public void setAuthenticator(SingularityAuthenticatorClass authenticator) {
    this.authenticator = authenticator;
    this.authenticators.add(authenticator);
  }

  public List getAuthenticators() {
    return authenticators;
  }

  public void setAuthenticators(List authenticators) {
    this.authenticators = authenticators;
  }

  public SingularityAuthDatastoreClass getDatastore() {
    return datastore;
  }

  public void setDatastore(SingularityAuthDatastoreClass datastore) {
    this.datastore = datastore;
  }

  public Set getRequiredGroups() {
    return requiredGroups;
  }

  public void setRequiredGroups(Set requiredGroups) {
    this.requiredGroups = requiredGroups;
  }

  public Set getAdminGroups() {
    return adminGroups;
  }

  public void setAdminGroups(Set adminGroups) {
    this.adminGroups = adminGroups;
  }

  public Set getJitaGroups() {
    return jitaGroups;
  }

  public void setJitaGroups(Set jitaGroups) {
    this.jitaGroups = jitaGroups;
  }

  public Set getDefaultReadOnlyGroups() {
    return defaultReadOnlyGroups;
  }

  public void setDefaultReadOnlyGroups(Set defaultReadOnlyGroups) {
    this.defaultReadOnlyGroups = defaultReadOnlyGroups;
  }

  public Set getGlobalReadOnlyGroups() {
    return globalReadOnlyGroups;
  }

  public void setGlobalReadOnlyGroups(Set globalReadOnlyGroups) {
    this.globalReadOnlyGroups = globalReadOnlyGroups;
  }

  public String getRequestUserHeaderName() {
    return requestUserHeaderName;
  }

  public void setRequestUserHeaderName(String requestUserHeaderName) {
    this.requestUserHeaderName = requestUserHeaderName;
  }

  public int getWebhookAuthRequestTimeoutMs() {
    return webhookAuthRequestTimeoutMs;
  }

  public AuthConfiguration setWebhookAuthRequestTimeoutMs(
    int webhookAuthRequestTimeoutMs
  ) {
    this.webhookAuthRequestTimeoutMs = webhookAuthRequestTimeoutMs;
    return this;
  }

  public int getWebhookAuthRetries() {
    return webhookAuthRetries;
  }

  public AuthConfiguration setWebhookAuthRetries(int webhookAuthRetries) {
    this.webhookAuthRetries = webhookAuthRetries;
    return this;
  }

  public int getWebhookAuthConnectTimeoutMs() {
    return webhookAuthConnectTimeoutMs;
  }

  public AuthConfiguration setWebhookAuthConnectTimeoutMs(
    int webhookAuthConnectTimeoutMs
  ) {
    this.webhookAuthConnectTimeoutMs = webhookAuthConnectTimeoutMs;
    return this;
  }

  public UserAuthMode getAuthMode() {
    return authMode;
  }

  public void setAuthMode(UserAuthMode authMode) {
    this.authMode = authMode;
  }

  public ScopesConfiguration getScopes() {
    return scopes;
  }

  public void setScopes(ScopesConfiguration scopes) {
    this.scopes = scopes;
  }

  public Optional getDefaultEmailDomain() {
    return defaultEmailDomain;
  }

  public void setDefaultEmailDomain(Optional defaultEmailDomain) {
    this.defaultEmailDomain = defaultEmailDomain;
  }

  public AuthResponseParser getAuthResponseParser() {
    return authResponseParser;
  }

  public void setAuthResponseParser(AuthResponseParser authResponseParser) {
    this.authResponseParser = authResponseParser;
  }

  public Set getGlobalReadWriteGroups() {
    return globalReadWriteGroups;
  }

  public void setGlobalReadWriteGroups(Set globalReadWriteGroups) {
    this.globalReadWriteGroups = globalReadWriteGroups;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy