Sha256: 3fdae974ec596f0855ae2d23a9de3e30d12672f945f511a5081b5b0ca5ec98e8

Contents?: true

Size: 744 Bytes

Versions: 4

Compression:

Stored size: 744 Bytes

Contents

class JekyllAuth
  class AuthSite < Sinatra::Base

    use Rack::Session::Cookie, :secret => ENV['SESSION_SECRET'] || SecureRandom.hex

    set :github_options, {
      :client_id     => ENV['GITHUB_CLIENT_ID'],
      :client_secret => ENV['GITHUB_CLIENT_SECRET'],
      :scopes        => 'user'
    }

    register Sinatra::Auth::Github

    before do
      if 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
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
jekyll-auth-0.1.3 lib/jekyll-auth/auth-site.rb
jekyll-auth-0.1.2 lib/jekyll-auth/auth-site.rb
jekyll-auth-0.1.1 lib/jekyll-auth/auth-site.rb
jekyll-auth-0.1.0 lib/jekyll-auth/auth-site.rb