This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

initial working sinatra app with github auth

  • Loading branch information...
schacon committed May 30, 2011
0 parents commit f5d05d2b6e0931cb007a109101e1699073c937e0
Showing with 80 additions and 0 deletions.
  1. +7 −0 .gitignore
  2. +5 −0 Gemfile
  3. +20 −0 LICENSE
  4. +5 −0 README.md
  5. +31 −0 app.rb
  6. +12 −0 config.ru
@@ -0,0 +1,7 @@
+coverage
+.bundle
+pkg
+.DS_Store
+Gemfile.lock
+tmp
+.powrc
@@ -0,0 +1,5 @@
+source "http://rubygems.org"
+
+gem "sinatra"
+gem "sinatra_auth_github"
+
20 LICENSE
@@ -0,0 +1,20 @@
+Copyright (c) 2010 Scott Chacon
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,5 @@
+GitHub Terminal
+===============
+
+Awesome.
+
31 app.rb
@@ -0,0 +1,31 @@
+require 'sinatra'
+require 'sinatra_auth_github'
+require 'pp'
+
+class TerminalApp < Sinatra::Base
+ enable :sessions
+
+ set :github_options, {
+ :secret => ENV['GITHUB_CLIENT_SECRET'],
+ :client_id => ENV['GITHUB_CLIENT_ID'],
+ :scopes => 'user,repo' # repo is need for org auth :\
+ }
+
+ register Sinatra::Auth::Github
+
+ helpers do
+ def repos
+ github_request("repos/show/#{github_user.login}")
+ end
+ end
+
+ get '/' do
+ authenticate!
+ "Hello There, #{github_user.name}!#{github_user.token}\n#{repos.inspect}"
+ end
+
+ get '/logout' do
+ logout!
+ redirect '/'
+ end
+end
@@ -0,0 +1,12 @@
+require "rubygems"
+require "bundler"
+Bundler.setup
+
+Bundler.require(:runtime)
+
+require 'app'
+
+use Rack::Static, :urls => ["/css", "/img", "/js"], :root => "public"
+
+run TerminalApp
+

0 comments on commit f5d05d2

Please sign in to comment.