Sha256: a6af3ecad3cc623bc05caf95e04cd83c6021fb4c04035e51947ec6816c6dc532
Contents?: true
Size: 990 Bytes
Versions: 5
Compression:
Stored size: 990 Bytes
Contents
module Stoor class GithubAuth < Sinatra::Base set :github_options, { :scopes => "user,user:email", :client_id => ENV['GITHUB_CLIENT_ID'], :secret => ENV['GITHUB_CLIENT_SECRET'] } register Sinatra::Auth::Github register Mustache::Sinatra get '/logout' do logout! mustache :logout end get '/*' do ENV['GITHUB_AUTHORIZED'] = nil pass unless ENV['GITHUB_CLIENT_ID'] && ENV['GITHUB_CLIENT_SECRET'] pass if request.path_info =~ /\./ authenticate! if ENV['GITHUB_TEAM_ID'] github_team_authenticate!(ENV['GITHUB_TEAM_ID']) end ENV['GITHUB_AUTHORIZED'] = "yes" email = nil emails = github_user.api.emails if ENV['GITHUB_EMAIL_DOMAIN'] email = emails.find { |e| e =~ /#{ENV['GITHUB_EMAIL_DOMAIN']}/ } end email ||= emails.first session['gollum.author'] = { :name => github_user.name, :email => email } pass end end end
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
stoor-0.1.4 | lib/stoor/github_auth.rb |
stoor-0.1.3 | lib/stoor/github_auth.rb |
stoor-0.1.2 | lib/stoor/github_auth.rb |
stoor-0.1.1 | lib/stoor/github_auth.rb |
stoor-0.1.0 | lib/stoor/github_auth.rb |