jekyll-auth 0.6.1 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,47 +0,0 @@
1
- class JekyllAuth
2
- class AuthSite < Sinatra::Base
3
-
4
- # require ssl
5
- configure :production do
6
- require 'rack-ssl-enforcer'
7
- use Rack::SslEnforcer if JekyllAuth.ssl?
8
- end
9
-
10
- use Rack::Session::Cookie, {
11
- :http_only => true,
12
- :secret => ENV['SESSION_SECRET'] || SecureRandom.hex
13
- }
14
-
15
- set :github_options, {
16
- :client_id => ENV['GITHUB_CLIENT_ID'],
17
- :client_secret => ENV['GITHUB_CLIENT_SECRET'],
18
- :scopes => 'read:org'
19
- }
20
-
21
- register Sinatra::Auth::Github
22
-
23
- before do
24
- pass if JekyllAuth.whitelist && JekyllAuth.whitelist.match(request.path_info)
25
- if ENV['GITHUB_TEAM_IDS']
26
- authenticate!
27
- ENV['GITHUB_TEAM_IDS'].split(",").each do |team|
28
- return pass if github_team_access?(team.strip)
29
- end
30
- halt 401
31
- elsif ENV['GITHUB_TEAM_ID']
32
- github_team_authenticate!(ENV['GITHUB_TEAM_ID'])
33
- elsif ENV['GITHUB_ORG_ID']
34
- github_organization_authenticate!(ENV['GITHUB_ORG_ID'])
35
- else
36
- puts "ERROR: Jekyll Auth is refusing to serve your site."
37
- puts "Looks like your oauth credentials are not properly configured. RTFM."
38
- halt 401
39
- end
40
- end
41
-
42
- get '/logout' do
43
- logout!
44
- redirect '/'
45
- end
46
- end
47
- end
@@ -1,28 +0,0 @@
1
- class JekyllAuth
2
- def self.setup_config
3
- @config_file ||= if File.file?(config_filename)
4
- YAML.safe_load_file(config_filename)
5
- else
6
- Hash.new
7
- end
8
- end
9
-
10
- def self.config_filename
11
- File.join(Dir.pwd, "_config.yml")
12
- end
13
-
14
- def self.config
15
- config_file = JekyllAuth.setup_config
16
- return {} if config_file.nil? || config_file["jekyll_auth"].nil?
17
- config_file["jekyll_auth"]
18
- end
19
-
20
- def self.whitelist
21
- whitelist = JekyllAuth::config["whitelist"]
22
- Regexp.new(whitelist.join("|")) unless whitelist.nil?
23
- end
24
-
25
- def self.ssl?
26
- !!JekyllAuth::config["ssl"]
27
- end
28
- end
@@ -1,7 +0,0 @@
1
- class JekyllAuth
2
- class JekyllSite < Sinatra::Base
3
- register Sinatra::Index
4
- set :public_folder, '_site'
5
- use_static_index 'index.html'
6
- end
7
- end