Commit d8997a58 authored by Jyrki's avatar Jyrki :feet:
Browse files

Initial commit

parents
Showing with 163 additions and 0 deletions
+163 -0
.gitignore 0 → 100644
# See https://help.github.com/articles/ignoring-files for more about ignoring files.
#
# If you find yourself ignoring temporary files generated by your text editor
# or operating system, you probably want to add a global ignore instead:
# git config --global core.excludesfile '~/.gitignore_global'
# Ignore bundler config.
/.bundle
# Ignore all logfiles and tempfiles.
/tmp/*
!/tmp/.keep
# Ignore config file
/config.yml
twitter-profile-pic-uploader
ruby-2.3.1
Gemfile 0 → 100644
source 'https://rubygems.org'
gem 'sinatra'
gem 'sinatra-contrib'
gem 'haml'
gem 'twitter'
gem 'omniauth-twitter'
GEM
remote: https://rubygems.org/
specs:
addressable (2.4.0)
backports (3.6.8)
buftok (0.2.0)
domain_name (0.5.20161021)
unf (>= 0.0.5, < 1.0.0)
equalizer (0.0.10)
faraday (0.9.2)
multipart-post (>= 1.2, < 3)
haml (4.0.7)
tilt
hashie (3.4.6)
http (1.0.4)
addressable (~> 2.3)
http-cookie (~> 1.0)
http-form_data (~> 1.0.1)
http_parser.rb (~> 0.6.0)
http-cookie (1.0.3)
domain_name (~> 0.5)
http-form_data (1.0.1)
http_parser.rb (0.6.0)
json (1.8.3)
memoizable (0.4.2)
thread_safe (~> 0.3, >= 0.3.1)
multi_json (1.12.1)
multipart-post (2.0.0)
naught (1.1.0)
oauth (0.5.1)
omniauth (1.3.1)
hashie (>= 1.2, < 4)
rack (>= 1.0, < 3)
omniauth-oauth (1.1.0)
oauth
omniauth (~> 1.0)
omniauth-twitter (1.2.1)
json (~> 1.3)
omniauth-oauth (~> 1.1)
rack (1.6.4)
rack-protection (1.5.3)
rack
rack-test (0.6.3)
rack (>= 1.0)
simple_oauth (0.3.1)
sinatra (1.4.7)
rack (~> 1.5)
rack-protection (~> 1.4)
tilt (>= 1.3, < 3)
sinatra-contrib (1.4.7)
backports (>= 2.0)
multi_json
rack-protection
rack-test
sinatra (~> 1.4.0)
tilt (>= 1.3, < 3)
thread_safe (0.3.5)
tilt (2.0.5)
twitter (5.16.0)
addressable (~> 2.3)
buftok (~> 0.2.0)
equalizer (= 0.0.10)
faraday (~> 0.9.0)
http (~> 1.0)
http_parser.rb (~> 0.6.0)
json (~> 1.8)
memoizable (~> 0.4.0)
naught (~> 1.0)
simple_oauth (~> 0.3.0)
unf (0.1.4)
unf_ext
unf_ext (0.0.7.2)
PLATFORMS
ruby
DEPENDENCIES
haml
omniauth-twitter
sinatra
sinatra-contrib
twitter
BUNDLED WITH
1.13.6
app.rb 0 → 100644
# frozen_string_literal: true
require 'sinatra'
require 'sinatra/namespace'
require 'omniauth-twitter'
require 'haml'
require 'yaml'
APP_CONFIG = YAML.load_file(File.expand_path('../config.yml', __FILE__))
configure do
enable :sessions
use OmniAuth::Builder do
provider :twitter,
APP_CONFIG['twitter']['consumer_key'],
APP_CONFIG['twitter']['consumer_secret']
end
end
helpers do
def current_user
!session[:uid].nil?
end
end
before do
pass if request.path_info =~ %r{\A/auth/}
#redirect to('/auth/twitter') unless current_user
end
namespace '/auth' do
get '/:provider/callback' do
halt 403 unless params[:provider] == 'twitter'
session[:uid] = env['omniauth.auth']['uid']
# TODO: also store tokens
redirect to('/')
end
get '/failure' do
'FEHLER ' * 25
end
end
get '/' do
if current_user
'You are signed in!'
else
'Hey there, you might want to <a href="/auth/twitter">sign in</a>'
end
end
---
twitter:
consumer_key: ''
consumer_secret: ''
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment