Record Class SocialProperties

java.lang.Object
java.lang.Record
com.irurueta.authserver.authorization.api.web.social.SocialProperties
Record Components:
providers - settings of each provider, by registration id (google, microsoft, apple, github).

@ConfigurationProperties("authserver.social") public record SocialProperties(Map<String,SocialProperties.Provider> providers) extends Record
Settings of the sign-in with external providers, bound once from authserver.social.* and injected wherever one is needed; an invalid value stops the application at startup. A provider is enabled when its client-id has text: a blank one leaves the provider off, so the shipped application.yml can list all of them with the values of environment variables and nothing is enabled until a deployment supplies them. Secrets (the client secret, the Apple private key) are never kept in a committed file: they come from the environment only.

Whether a provider's own multi-factor authentication is trusted (trust-mfa) is per provider and off by default: the sign-in is then a primary factor and the normal second-factor flow applies.

  • Field Details

    • providers

      private final Map<String,SocialProperties.Provider> providers
      The field for the providers record component.
    • COMMON_TENANT

      public static final String COMMON_TENANT
      Tenant value of Entra ID that accepts work, school and personal accounts of any tenant.
      See Also:
    • ORGANIZATIONS_TENANT

      public static final String ORGANIZATIONS_TENANT
      Tenant value of Entra ID that accepts work and school accounts of any tenant.
      See Also:
    • CONSUMERS_TENANT

      public static final String CONSUMERS_TENANT
      Tenant value of Entra ID that accepts personal accounts only.
      See Also:
    • MAX_APPLE_CLIENT_SECRET_TTL

      public static final Duration MAX_APPLE_CLIENT_SECRET_TTL
      Longest lifetime Apple accepts for a client secret: six months.
    • DEFAULT_APPLE_CLIENT_SECRET_TTL

      public static final Duration DEFAULT_APPLE_CLIENT_SECRET_TTL
      Default lifetime of the client secret JWT sent to Apple.
    • TENANT_ID_PATTERN

      private static final Pattern TENANT_ID_PATTERN
      Shape of a tenant id (a GUID): the issuer of a single-tenant token is built from it.
    • TENANT_PATTERN

      private static final Pattern TENANT_PATTERN
      Characters a tenant (a GUID or a domain name) may contain: it becomes part of a URL.
  • Constructor Details

    • SocialProperties

      public SocialProperties(Map<String,SocialProperties.Provider> providers)
      Validates the settings and copies the map.
      Throws:
      IllegalArgumentException - if a key is not the registration id of a known provider, or an enabled provider lacks a setting it needs or has an invalid one.
  • Method Details

    • enabledProviders

      public Map<IdentityProvider,SocialProperties.Provider> enabledProviders()
      Returns the enabled providers, in the order of IdentityProvider.
      Returns:
      the enabled providers and their settings; empty when none is configured.
    • find

      Returns the settings of an enabled provider.
      Parameters:
      provider - the provider.
      Returns:
      its settings, or an empty optional when it is not enabled.
    • trust

      public ProviderTrust trust(IdentityProvider provider)
      Returns how far the multi-factor authentication of a provider is trusted.
      Parameters:
      provider - the provider.
      Returns:
      the trust setting; the provider is not trusted when it is not enabled.
    • validate

      private static void validate(IdentityProvider id, SocialProperties.Provider provider)
      Checks the settings of a provider that is enabled.
      Parameters:
      id - the provider.
      provider - its settings.
    • require

      private static void require(String value, String name)
      Requires a setting to have text.
      Parameters:
      value - value of the setting.
      name - full name of the setting, for the message.
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • providers

      public Map<String,SocialProperties.Provider> providers()
      Returns the value of the providers record component.
      Returns:
      the value of the providers record component