You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: single_sign_on.rb
    path of file: ./repos/homeland/lib
    
    the code of the file until where you have to start completion: # frozen_string_literal: true

# From: https://github.com/discourse/discourse/blob/master/lib/single_sign_on.rb
class SingleSignOn
  ACCESSORS = %i[nonce name username email avatar_url bio external_id return_sso_url admin]
  FIXNUMS = []
  BOOLS = [:admin]
  NONCE_EXPIRY_TIME = 10.minutes

  attr_accessor(*ACCESSORS)
  attr_writer :sso_secret, :sso_url

  def self.parse(payload, sso_secret = nil)
    sso = new
    sso.sso_secret = sso_secret if sso_secret

    parsed = Rack::Utils.parse_query(payload)
    if sso.sign(parsed["sso"]) != parsed["sig"]
      diags = "\n\nsso: #{parsed["sso"]}\n\nsig: #{parsed["sig"]}\n\nexpected sig: #{sso.sign
    
  def diagnostics
    SingleSignOn::ACCESSORS.map do |a|
      "#{a}: #{send(a)}"
    end.join("\n")
  end

  def sso_secret
    @sso_secret || self.class.sso_secret
  end

  def sso_url
    @sso_url || self.class.sso_url
  end

  def custom_fields
    @custom_fields ||= {}
  end

  def sign(payload)
    return if payload.nil?
    OpenSSL::HMAC.hexdigest("sha256", sso_secret, payload)
  end

  def to_url(base_url = nil)
    base = (base_url || sso_url).to_s
    "#{base}#{base.include?("?") ? "&" : "?"}#{payload}"
  end

  def payload
    payload = Base64.encode64(unsigned_payload)
    "sso=#{CGI.escape(payload)}&sig=#{sign(payload)}"
  end

  def unsigned_payload
    payload = {}
    ACCESSORS.each do |k|
      next if (val = send k).nil?

      payload[k] = val
    end

    @custom_fields&.each do |k, v|
      payload["custom.#{k}"] = v.to_s
    end

    Rack::Utils.build_query(payload)
  end
end