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.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +15 -0
- data/Gemfile +3 -0
- data/README.md +149 -0
- data/Rakefile +18 -7
- data/bin/jekyll-auth +97 -109
- data/jekyll-auth.gemspec +31 -0
- data/lib/jekyll-auth.rb +31 -6
- data/lib/jekyll_auth/auth_site.rb +47 -0
- data/lib/jekyll_auth/commands.rb +73 -0
- data/lib/jekyll_auth/config_error.rb +8 -0
- data/lib/jekyll_auth/helpers.rb +18 -0
- data/lib/jekyll_auth/jekyll_site.rb +14 -0
- data/lib/jekyll_auth/sinatra/auth/github.rb +11 -0
- data/lib/{jekyll-auth → jekyll_auth}/version.rb +1 -1
- data/script/bootstrap +7 -0
- data/script/cibuild +8 -0
- data/script/console +1 -0
- data/script/release +38 -0
- data/script/server +3 -0
- data/script/setup +5 -0
- data/spec/jekyll_auth_auth_site_spec.rb +76 -0
- data/spec/jekyll_auth_bin_spec.rb +44 -0
- data/spec/jekyll_auth_commands_spec.rb +76 -0
- data/spec/jekyll_auth_helpers_spec.rb +62 -0
- data/spec/jekyll_auth_jekyll_site_spec.rb +44 -0
- data/spec/jekyll_auth_spec.rb +47 -0
- data/spec/spec_helper.rb +60 -0
- data/templates/.gitignore +3 -0
- data/templates/Rakefile +9 -0
- data/{config.ru → templates/config.ru} +0 -0
- data/templates/index.html +19 -0
- metadata +126 -25
- data/lib/jekyll-auth/auth-site.rb +0 -47
- data/lib/jekyll-auth/config.rb +0 -28
- data/lib/jekyll-auth/jekyll-site.rb +0 -7
@@ -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
|
data/lib/jekyll-auth/config.rb
DELETED
@@ -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
|