module J1App

App in production mode


~/lib/j1_auth_manager/auth_manager/.rb

Provides authentication services based on Warden|OmniAuth

Product/Info:
https://jekyll.one

Copyright (C) 2021 Juergen Adams

J1 Template is licensed under the MIT License.
See: https://github.com/jekyll-one-org/J1 Template/blob/master/LICENSE

NOTES



~/lib/j1_app/j1_auth_manager/omniauth/strategies/eror_pages.rb

Provides plan error pages

Product/Info: jekyll.one

Copyright (C) 2021 Juergen Adams

J1 Template is licensed under the MIT License See: github.com/jekyll-one-org/J1 Template/blob/master/LICENSE


NOTES



~/lib/j1_app/j1_auth_manager/omniauth/strategies/helpers_disqus.rb

Provides helper methods for the disqus omniauth strategy

Product/Info: jekyll.one

Copyright (C) 2021 Juergen Adams

J1 Template is licensed under the MIT License See: github.com/jekyll-one-org/J1 Template/blob/master/LICENSE


NOTES



~/lib/j1_app/j1_auth_manager/omniauth/strategies/helpers_facebook.rb

Provides helper methods for the facebook omniauth strategy

Product/Info: jekyll.one

Copyright (C) 2021 Juergen Adams

J1 Template is licensed under the MIT License See: github.com/jekyll-one-org/J1 Template/blob/master/LICENSE


NOTES



~/lib/j1_app/j1_auth_manager/omniauth/strategies/helpers_github.rb

Provides helper methods for the github omniauth strategy

Product/Info: jekyll.one

Copyright (C) 2021 Juergen Adams

J1 Template is licensed under the MIT License See: github.com/jekyll-one-org/J1 Template/blob/master/LICENSE


NOTES



~/lib/j1_app/j1_auth_manager/omniauth/strategies/helpers_patreon.rb

Provides helper methods for the patreon omniauth strategy

Product/Info: jekyll.one

Copyright (C) 2021 Juergen Adams

J1 Template is licensed under the MIT License See: github.com/jekyll-one-org/J1 Template/blob/master/LICENSE


NOTES



~/lib/j1_app/j1_auth_manager/omniauth/strategies/helpers_twitter.rb

Provides helper methods for the twitter omniauth strategy

Product/Info: jekyll.one

Copyright (C) 2021 Juergen Adams

J1 Template is licensed under the MIT License See: github.com/jekyll-one-org/J1 Template/blob/master/LICENSE


NOTES


Public Class Methods

active_providers() click to toggle source
# File lib/j1_app/j1_auth_manager/config.rb, line 116
def self.active_providers
  auth_config['providers']['activated']
end
auth?() click to toggle source
# File lib/j1_app/j1_auth_manager/config.rb, line 98
def self.auth?
  !!auth_config['enabled']
end
auth_config() click to toggle source
# File lib/j1_app/j1_auth_manager/config.rb, line 89
def self.auth_config
  # @auth['settings']['j1_auth']
  auth_settings['j1_auth']
end
auth_config_data() click to toggle source
# File lib/j1_app/j1_auth_manager/config.rb, line 44
def self.auth_config_data
  @auth ||= YAML.safe_load_file(auth_config_file)
rescue StandardError
  {}
end
auth_config_file() click to toggle source
# File lib/j1_app/j1_auth_manager/config.rb, line 39
def self.auth_config_file
  # File.join(Dir.pwd, '_data/modules/authentication.yml')
  File.join(J1App.project_path, '_data/modules/authentication.yml')
end
auth_settings() click to toggle source
# File lib/j1_app/j1_auth_manager/config.rb, line 85
def self.auth_settings
  auth_config_data.fetch('settings', {})
end
conditions(arg) click to toggle source
# File lib/j1_app/j1_auth_manager/config.rb, line 145
def self.conditions (arg)
  condition_profile = {}
  provider = arg
  provider_conditions = auth_config['providers']["#{provider}"]['conditions']
  provider_conditions.each do |key, value|
    condition_profile[key] = value
  end
  condition_profile
end
default_provider() click to toggle source
# File lib/j1_app/j1_auth_manager/config.rb, line 120
def self.default_provider
  auth_config['providers']['activated'][0]
end
destination() click to toggle source
# File lib/j1_app/j1_auth_manager/config.rb, line 80
def self.destination
  # jekyll_config.fetch('destination', File.expand_path('_site', Dir.pwd))
  jekyll_config.fetch('destination', File.expand_path(J1App.project_path, '_site'))
end
get_condition(arg) click to toggle source
# File lib/j1_app/j1_auth_manager/config.rb, line 141
def self.get_condition(arg)
  auth_config['provider']['condition']["#{arg}"]
end
jekyll_config() click to toggle source
# File lib/j1_app/j1_auth_manager/config.rb, line 33
def self.jekyll_config
  @config ||= YAML.safe_load_file(jekyll_config_file)
rescue StandardError
  {}
end
jekyll_config_file() click to toggle source
# File lib/j1_app/j1_auth_manager/config.rb, line 27
def self.jekyll_config_file
  # File.join(Dir.pwd, "_config.develop.yml")
  # File.join(Dir.pwd, '_config.yml')
  File.join(J1App.project_path, '_config.yml')
end
middleware_data() click to toggle source
# File lib/j1_app/j1_auth_manager/config.rb, line 72
def self.middleware_data
  private_data.fetch('middleware', {})
end
oauth_data() click to toggle source
# File lib/j1_app/j1_auth_manager/config.rb, line 76
def self.oauth_data
  middleware_data.fetch('oauth', {})
end
permissions() click to toggle source
# File lib/j1_app/j1_auth_manager/config.rb, line 124
def self.permissions
  permission_profile = {
      :protected   => [],
      :private   => []
  }

  active_providers = auth_config['providers']['activated']

  active_providers.each { |p|
    provider_permissions = auth_config['providers']["#{p}"]['permissions']
    provider_permissions.each do |perm|
      permission_profile[:"#{perm}"] << "#{p}"
    end
  }
  permission_profile
end
private_data() click to toggle source
# File lib/j1_app/j1_auth_manager/config.rb, line 66
def self.private_data
  @private_data ||= YAML.safe_load_file(template_private_data_file)
rescue StandardError
  {}
end
project_path() click to toggle source

set j1 project path

# File lib/j1_app/j1_auth_manager/config.rb, line 5
def self.project_path
  # set project folder to the path set by ENV var J1_PROJECT_HOME (preferred)
  #
  if ENV['J1_PROJECT_HOME'] != nil
    ENV['J1_PROJECT_HOME']
  elsif ARGV.grep(/config.ru/)[0] != nil
    # set project folder to path of ARGV argument for config.ru if available.
    # This will work, if the app is called from commandline (rackup)
    #
    File.dirname(ARGV.grep(/config.ru/)[0])
  else
    # set project folder if app is called from application manager
    # (e.g. passenger) to current work dir
    # NOTE:
    #   Unclear why File.join resolves the PATH correctly
    #   but File.dirname doesn't:
    #     File.dirname(Dir.pwd)
    #
    File.join(Dir.pwd, "")
  end
end
public_content() click to toggle source
# File lib/j1_app/j1_auth_manager/config.rb, line 111
def self.public_content
  public_content = auth_config['content']['public']
  Regexp.new(public_content.join("|")) unless public_content.nil?
end
site() click to toggle source
# File lib/j1_app.rb, line 67
def self.site
  Rack::Builder.new do
    use Rack::ShowExceptions                                                  # Middleware. Generate web-based error pages (for Rack)
    use Rack::Deflater                                                        # Middleware. Enable gzip compression for ALL web servers out of Rack
    use J1App::AuthManager                                                    # Middleware. Support authentication methods using OmniAuth
    run J1App::SiteManager                                                    # Run J1App Manager to manage the (static) site as an (Rack-based) Web Application:
  end
end
ssl?() click to toggle source
# File lib/j1_app/j1_auth_manager/config.rb, line 102
def self.ssl?
  !!auth_config['ssl']
end
template_config() click to toggle source
# File lib/j1_app/j1_auth_manager/config.rb, line 55
def self.template_config
  @template_config ||= YAML.safe_load_file(template_config_file)
rescue StandardError
  {}
end
template_config_file() click to toggle source
# File lib/j1_app/j1_auth_manager/config.rb, line 50
def self.template_config_file
  # File.join(Dir.pwd, '_data/j1_config.yml')
  File.join(J1App.project_path, '_data/j1_config.yml')
end
template_private_data_file() click to toggle source
# File lib/j1_app/j1_auth_manager/config.rb, line 61
def self.template_private_data_file
  # File.join(Dir.pwd, '_data/private.yml')
  File.join(J1App.project_path, '_data/private.yml')
end
user_settings() click to toggle source
# File lib/j1_app/j1_auth_manager/config.rb, line 94
def self.user_settings
  template_config.fetch('user', {})
end
whitelist() click to toggle source
# File lib/j1_app/j1_auth_manager/config.rb, line 106
def self.whitelist
  whitelist = auth_config['whitelist']
  Regexp.new(whitelist.join("|")) unless whitelist.nil?
end