Sha256: 1dec5253530cde3c690ee06f8b2a82ae231b1d2e979b807c213bc66a1ab371fc
Contents?: true
Size: 1.24 KB
Versions: 2
Compression:
Stored size: 1.24 KB
Contents
class JekyllAuth class AuthSite < Sinatra::Base # require ssl configure :production do require 'rack-ssl-enforcer' use Rack::SslEnforcer if JekyllAuth.ssl? end use Rack::Session::Cookie, { :http_only => true, :secret => ENV['SESSION_SECRET'] || SecureRandom.hex } set :github_options, { :client_id => ENV['GITHUB_CLIENT_ID'], :client_secret => ENV['GITHUB_CLIENT_SECRET'], :scopes => 'read:org' } register Sinatra::Auth::Github before do pass if JekyllAuth.whitelist && JekyllAuth.whitelist.match(request.path_info) if ENV['GITHUB_TEAM_IDS'] authenticate! ENV['GITHUB_TEAM_IDS'].split(",").each do |team| return pass if github_team_access?(team.strip) end halt 401 elsif ENV['GITHUB_TEAM_ID'] github_team_authenticate!(ENV['GITHUB_TEAM_ID']) elsif ENV['GITHUB_ORG_ID'] github_organization_authenticate!(ENV['GITHUB_ORG_ID']) else puts "ERROR: Jekyll Auth is refusing to serve your site." puts "Looks like your oauth credentials are not properly configured. RTFM." halt 401 end end get '/logout' do logout! redirect '/' end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
jekyll-auth-0.6.1 | lib/jekyll-auth/auth-site.rb |
jekyll-auth-0.6.0 | lib/jekyll-auth/auth-site.rb |