1.15.3 1.97GB
1.15.2 1.86GB
22:  devise :two_factor_authenticatable, :registerable,
26:  devise :two_factor_backupable, otp_backup_code_length: 12, otp_number_of_backup_codes: 10
191:  config.lock_strategy = :failed_attempts
201:  config.unlock_strategy = :both
208:  config.unlock_in = 1.hour
# frozen_string_literal: true

if User.none?
  Rails.logger.debug 'Creating user...'

  email = 'demo@dawarich.app'

  User.create!(
    email:,
    password: 'safepassword',
    password_confirmation: 'safepassword',
    admin: true,
    status: :active,
    active_until: 100.years.from_now
  )

  Rails.logger.debug "User created: '#{email}' / password: 'safepassword'"
end

if Country.none?
  Rails.logger.debug 'Creating countries...'

  countries_path = Rails.root.join('lib/assets/countries.geojson.gz')
  countries_json = Zlib::GzipReader.open(countries_path) { |gzip| Oj.load(gzip.read) }

  factory = RGeo::Geos.factory(srid: 4326)
  countries_multi_polygon = RGeo::GeoJSON.decode(countries_json.to_json, geo_factory: factory)

  ActiveRecord::Base.transaction do
    countries_multi_polygon.each do |country|
6:  before_action :authenticate_api_key
37:    authenticated = api_key.present? && current_api_user.present?
44:  def authenticate_api_key
65:    return unless current_api_user # auth already handled by authenticate_api_key
76:    return unless current_api_user # auth already handled by authenticate_api_key
areas_controller.rb
auth
countries
demo_data_controller.rb
digests_controller.rb
families
flights_controller.rb
health_controller.rb
immich
imports
imports_controller.rb
insights_controller.rb
locations_controller.rb
maps
mcp_controller.rb
notes_controller.rb
overland
owntracks
photos_controller.rb
places_controller.rb
plan_controller.rb
points
points_controller.rb
recalculations_controller.rb
residency_controller.rb
settings
settings_controller.rb
shared
stats_controller.rb
subscriptions_controller.rb
tags_controller.rb
tiles
timeline_controller.rb
traccar
tracks
tracks_controller.rb
users
users_controller.rb
visits
visits_controller.rb
wget: /usr/bin/wget
curl: /usr/bin/curl
pgrep: /usr/bin/pgrep
  attr_accessor :oauth_newly_created

  devise :two_factor_authenticatable, :registerable,
         :recoverable, :rememberable, :validatable, :trackable,
         :lockable,
         :omniauthable, omniauth_providers: ::OMNIAUTH_PROVIDERS
  devise :two_factor_backupable, otp_backup_code_length: 12, otp_number_of_backup_codes: 10

  has_many :points, dependent: :destroy
191:  config.lock_strategy = :failed_attempts
198:  # :time  = Re-enables login after a certain amount of time (see :unlock_in below)
201:  config.unlock_strategy = :both
203:  # Number of authentication tries before locking an account if lock_strategy
205:  config.maximum_attempts = 10
207:  # Time interval to unlock the account if :time is enabled as unlock_strategy.
208:  config.unlock_in = 1.hour
211:  config.last_attempt_warning = true
84:ALLOW_EMAIL_PASSWORD_REGISTRATION = ENV.fetch('ALLOW_EMAIL_PASSWORD_REGISTRATION', 'false') == 'true'
config/initializers/devise.rb:9:  # Devise will use the `secret_key_base` as its `secret_key`
app/models/instance_setting.rb:7:  encrypts :encrypted_value
app/models/service_setting.rb:8:  encrypts :credentials
app/models/trip_source.rb:11:  encrypts :api_key
down
config/environments/production.rb:109:  require_relative '../../lib/smtp_config'
config/environments/production.rb:111:  config.action_mailer.default_url_options = SmtpConfig.mailer_url_options
config/environments/production.rb:114:  config.action_mailer.delivery_method = :smtp
config/environments/production.rb:115:  config.action_mailer.smtp_settings = SmtpConfig.smtp_settings
config/initializers/devise.rb:21:  config.mailer_sender = ENV['SMTP_FROM']

module SmtpConfig
  ALLOWED_AUTHENTICATIONS = %i[plain login cram_md5 digest_md5 gssapi ntlm xoauth2].freeze
  NO_AUTHENTICATION_VALUES = %w[none nil false off disabled].freeze
  DEFAULT_OPEN_TIMEOUT = 30
  DEFAULT_READ_TIMEOUT = 60
  ALLOWED_OPENSSL_VERIFY_MODES = %w[none peer].freeze

  IMPLICIT_TLS_PORT = 465

  def self.smtp_settings(env = ENV)
    ssl = ssl?(env)
    auth = authentication(env)
    user, pass = credentials(env, auth)

    settings = {
      address:         env['SMTP_SERVER'],
      port:            env['SMTP_PORT']&.to_i,
      domain:          env['SMTP_DOMAIN'],
      user_name:       user,
      password:        pass,
      authentication:  auth,
      ssl:             ssl,
      enable_starttls: !ssl && env.fetch('SMTP_STARTTLS', 'true') == 'true',
      open_timeout:    timeout(env, 'SMTP_OPEN_TIMEOUT', DEFAULT_OPEN_TIMEOUT),
      read_timeout:    timeout(env, 'SMTP_READ_TIMEOUT', DEFAULT_READ_TIMEOUT)
    }

    mode = openssl_verify_mode(env)
    settings[:openssl_verify_mode] = mode if mode

    settings
  end

  def self.mailer_url_options(env = ENV)
    {
      host:     env['DOMAIN'],
      protocol: 'https'
    }
  end

  def self.authentication(env)
    raw = env.fetch('SMTP_AUTHENTICATION', 'plain').to_s.strip
    return :plain if raw.empty?

    normalized = raw.downcase
    return nil if NO_AUTHENTICATION_VALUES.include?(normalized)

    sym = normalized.to_sym
    return sym if ALLOWED_AUTHENTICATIONS.include?(sym)
