Module: J1App

Defined in:
lib/j1_app.rb,
lib/j1_app/j1_auth_manager/config.rb,
lib/j1_app/j1_auth_manager/helpers.rb,
lib/j1_app/j1_auth_manager/commands.rb,
lib/j1_app/j1_site_manager/static_site.rb,
lib/j1_app/j1_auth_manager/auth_manager.rb,
lib/j1_app/j1_auth_manager/helpers_disqus.rb,
lib/j1_app/j1_auth_manager/helpers_github.rb,
lib/j1_app/j1_auth_manager/helpers_patreon.rb,
lib/j1_app/j1_auth_manager/helpers_twitter.rb,
lib/j1_app/j1_auth_manager/helpers_facebook.rb,
lib/j1_app/j1_auth_manager/_unused/auth_manager.update.web_cookie.rb,
lib/j1_app/j1_auth_manager/_unused/auth_manager.before_merge_added.rb

Overview


~/lib/j1_auth_manager/auth_manager/.rb

Provides authentication services based on Warden|OmniAuth

Product/Info:
https://jekyll-one.com

Copyright (C) 2019 Juergen Adams

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

NOTES


frozen_string_literal: true

Defined Under Namespace

Modules: DisqusHelpers, FacebookHelpers, GithubHelpers, Helpers, PatreonHelpers, TwitterHelpers Classes: AuthManager, Commands, ConfigError, SiteManager

Class Method Summary collapse

Class Method Details

.active_providersObject



40
41
42
# File 'lib/j1_app/j1_auth_manager/config.rb', line 40

def self.active_providers
  auth_config['providers']['activated']
end

.auth?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/j1_app/j1_auth_manager/config.rb', line 22

def self.auth?
  !!auth_config['enabled']
end

.auth_configObject



18
19
20
# File 'lib/j1_app/j1_auth_manager/config.rb', line 18

def self.auth_config
  jekyll_config.fetch('j1_auth', {})
end

.conditions(arg) ⇒ Object



69
70
71
72
73
74
75
76
77
# File 'lib/j1_app/j1_auth_manager/config.rb', line 69

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

.config_fileObject



3
4
5
6
# File 'lib/j1_app/j1_auth_manager/config.rb', line 3

def self.config_file
  File.join(Dir.pwd, '_config.yml')
  # File.join(Dir.pwd, "_config.develop.yml")
end

.default_providerObject



44
45
46
# File 'lib/j1_app/j1_auth_manager/config.rb', line 44

def self.default_provider
  auth_config['providers']['activated'][0]
end

.destinationObject



14
15
16
# File 'lib/j1_app/j1_auth_manager/config.rb', line 14

def self.destination
  jekyll_config.fetch('destination', File.expand_path('_site', Dir.pwd))
end

.get_condition(arg) ⇒ Object



65
66
67
# File 'lib/j1_app/j1_auth_manager/config.rb', line 65

def self.get_condition(arg)
  auth_config['provider']['condition']["#{arg}"]
end

.jekyll_configObject



8
9
10
11
12
# File 'lib/j1_app/j1_auth_manager/config.rb', line 8

def self.jekyll_config
  @config ||= YAML.safe_load_file(config_file)
rescue StandardError
  {}
end

.permissionsObject



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/j1_app/j1_auth_manager/config.rb', line 48

def self.permissions
  permission_profile = {
      :protected   => [],
      :private   => []
  }

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

  for p in active_providers do
    provider_permissions = auth_config['providers']["#{p}"]['permissions']
    provider_permissions.each do |perm|
      permission_profile[:"#{perm}"] << "#{p}"
    end
  end
  permission_profile
end

.public_contentObject



35
36
37
38
# File 'lib/j1_app/j1_auth_manager/config.rb', line 35

def self.public_content
  public_content = auth_config['content']['public']
  Regexp.new(public_content.join("|")) unless public_content.nil?
end

.siteObject



58
59
60
61
62
63
64
65
# File 'lib/j1_app.rb', line 58

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?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/j1_app/j1_auth_manager/config.rb', line 26

def self.ssl?
  !!auth_config['ssl']
end

.whitelistObject



30
31
32
33
# File 'lib/j1_app/j1_auth_manager/config.rb', line 30

def self.whitelist
  whitelist = auth_config['whitelist']
  Regexp.new(whitelist.join("|")) unless whitelist.nil?
end