Sha256: 1b4f94e7b4e07abfdd240ab60d4785ba181122a795a446d5e690080714a6b298

Contents?: true

Size: 1.02 KB

Versions: 4

Compression:

Stored size: 1.02 KB

Contents

class JekyllAuth
  class AuthSite < Sinatra::Base

    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, {
      :scopes    => 'read:org'
    }

    ENV['WARDEN_GITHUB_VERIFIER_SECRET'] ||= SecureRandom.hex
    register Sinatra::Auth::Github

    use Rack::Logger

    include JekyllAuth::Helpers

    before do
      pass if whitelisted?

      logger.info "Authentication strategy: #{authentication_strategy}"

      case authentication_strategy
      when :team
        github_team_authenticate! ENV['GITHUB_TEAM_ID']
      when :teams
        github_teams_authenticate! ENV['GITHUB_TEAM_IDS'].split(",")
      when :org
        github_organization_authenticate! ENV['GITHUB_ORG_ID']
      else
        raise JekyllAuth::ConfigError
      end
    end

    get '/logout' do
      logout!
      redirect '/'
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
jekyll-auth-1.0.3 lib/jekyll_auth/auth_site.rb
jekyll-auth-1.0.2 lib/jekyll_auth/auth_site.rb
jekyll-auth-1.0.1 lib/jekyll_auth/auth_site.rb
jekyll-auth-1.0.0 lib/jekyll_auth/auth_site.rb