Remove old authentication code (browser-id, github, twitter)

footer-fixes
Marcin Kulik 10 years ago
parent 7397e14a57
commit feb9703620

@ -9,10 +9,6 @@ gem 'jquery-rails', '~> 3.0.4'
gem 'pg', '~> 0.14'
gem 'carrierwave', '~> 0.8.0'
gem 'omniauth', '~> 1.1.4'
gem 'omniauth-twitter', '~> 0.0.16'
gem 'omniauth-github', '~> 1.1.0'
gem 'omniauth-browserid', git: 'https://github.com/callahad/omniauth-browserid.git'
gem 'kaminari', '~> 0.14.1'
gem 'bugsnag', '~> 2.2.1'
gem 'draper', '~> 1.3.1'

@ -1,12 +1,3 @@
GIT
remote: https://github.com/callahad/omniauth-browserid.git
revision: c594029ddf92661b9cf6f04374683981f25471c2
specs:
omniauth-browserid (0.0.1)
faraday
multi_json
omniauth (~> 1.0)
GEM
remote: https://rubygems.org/
specs:
@ -110,8 +101,6 @@ GEM
factory_girl_rails (4.2.1)
factory_girl (~> 4.2.0)
railties (>= 3.0.0)
faraday (0.8.8)
multipart-post (~> 1.2.0)
ffi (1.9.3)
fog (1.9.0)
builder
@ -136,13 +125,11 @@ GEM
guard-rspec (4.3.1)
guard (~> 2.1)
rspec (>= 2.14, < 4.0)
hashie (2.0.5)
highline (1.6.19)
hike (1.2.3)
httparty (0.13.1)
json (~> 1.8)
multi_xml (>= 0.5.2)
httpauth (0.2.0)
i18n (0.6.11)
ice_nine (0.11.0)
jasmine-core (1.3.1)
@ -154,8 +141,6 @@ GEM
railties (>= 3.0, < 5.0)
thor (>= 0.14, < 2.0)
json (1.8.1)
jwt (0.1.8)
multi_json (>= 1.5)
kaminari (0.14.1)
actionpack (>= 3.0.0)
activesupport (>= 3.0.0)
@ -173,7 +158,6 @@ GEM
minitest (5.4.1)
multi_json (1.10.1)
multi_xml (0.5.5)
multipart-post (1.2.0)
net-scp (1.0.4)
net-ssh (>= 1.99.1)
net-sftp (2.1.2)
@ -183,28 +167,6 @@ GEM
net-ssh (>= 2.6.5)
newrelic_rpm (3.7.1.182)
nokogiri (1.5.11)
oauth (0.4.7)
oauth2 (0.8.1)
faraday (~> 0.8)
httpauth (~> 0.1)
jwt (~> 0.1.4)
multi_json (~> 1.0)
rack (~> 1.2)
omniauth (1.1.4)
hashie (>= 1.2, < 3)
rack
omniauth-github (1.1.1)
omniauth (~> 1.0)
omniauth-oauth2 (~> 1.1)
omniauth-oauth (1.0.1)
oauth
omniauth (~> 1.0)
omniauth-oauth2 (1.1.1)
oauth2 (~> 0.8.0)
omniauth (~> 1.0)
omniauth-twitter (0.0.18)
multi_json (~> 1.3)
omniauth-oauth (~> 1.0)
open4 (1.3.0)
parallel (0.7.1)
pg (0.17.0)
@ -391,10 +353,6 @@ DEPENDENCIES
jquery-rails (~> 3.0.4)
kaminari (~> 0.14.1)
newrelic_rpm
omniauth (~> 1.1.4)
omniauth-browserid!
omniauth-github (~> 1.1.0)
omniauth-twitter (~> 0.0.16)
open4 (~> 1.3.0)
pg (~> 0.14)
poltergeist (~> 1.5.0)

@ -7,7 +7,6 @@
//= require base
//= require jquery_ujs
//= require jquery.timeago
//= require persona
//= require bootstrap
$(function() {

@ -1,31 +0,0 @@
$ ->
$('#persona-button, #log-in').click (event) ->
event.preventDefault()
navigator.id.request {
siteName: 'Asciinema',
siteLogo: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAAEAAQMAAABmvDolAAAABlBMVEUAAAD///+l2Z/dAAAAAWJLR0QAiAUdSAAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9wHGBMiFVqqanYAAAAZdEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIEdJTVBXgQ4XAAAAMklEQVRo3u3KoQEAAAgDoP3/tBaD0WiATAJwVIsgCIIgCIIgCIIgCIIgCIIgCMKHADAafyL3ebnQxskAAAAASUVORK5CYII=',
backgroundColor: '#06989a',
privacyPolicy: 'https://asciinema.org/privacy',
termsOfService: 'https://asciinema.org/tos'
}
if window.browserIdUser
$('header .logout').click (event) ->
event.preventDefault()
navigator.id.logout()
navigator.id.watch
loggedInUser: window.browserIdUser
onlogin: (assertion) ->
if assertion
form = $(
"<form action='/auth/browser_id/callback'>" +
"<input type='hidden' name='assertion' value='#{assertion}' />"
)
$('body').append form
form.submit()
onlogout: ->
window.location = '/logout'

@ -1,6 +1,5 @@
/*
*= require bootstrap
*= require auth-buttons
*= require source-sans-pro
*= require base
*= require header

@ -1,26 +0,0 @@
class AccountMergesController < ApplicationController
def create
user = find_user
if user
user.update_attribute(:email, store.delete(:new_user_email))
self.current_user = user
redirect_back_or_to root_url, notice: 'Welcome back!'
else
redirect_to new_user_path,
alert: 'Sorry, no account found. Try a different provider.'
end
end
private
def store
session
end
def find_user
User.for_credentials(omniauth_credentials)
end
end

@ -26,10 +26,6 @@ class ApplicationController < ActionController::Base
handle_unauthenticated unless current_user
end
def omniauth_credentials
OmniAuthCredentials.new(request.env['omniauth.auth'])
end
def store_location
session[:return_to] = request.path
end

@ -1,21 +0,0 @@
class OmniAuthCredentials
attr_reader :omniauth_hash
def initialize(omniauth_hash)
@omniauth_hash = omniauth_hash
end
def provider
omniauth_hash['provider']
end
def uid
omniauth_hash['uid']
end
def email
omniauth_hash['info'] && omniauth_hash['info']['email']
end
end

@ -25,19 +25,6 @@ module ApplicationHelper
end
end
def twitter_auth_path
"/auth/twitter"
end
def github_auth_path
"/auth/github"
end
def browser_id_user
email = current_user && current_user.email || session[:new_user_email]
email ? "'#{email}'".html_safe : 'null'
end
def category_links(current_category, &blk)
links = CategoryLinks.new(current_category, self)

@ -8,14 +8,8 @@ html[lang="en"]
= stylesheet_link_tag "application", :media => "all"
= javascript_include_tag "application"
= javascript_include_tag "player"
- if CFG.local_persona_js?
= javascript_include_tag "persona-include.js"
- else
= javascript_include_tag "https://login.persona.org/include.js"
= favicon_link_tag 'favicon.png'
= render 'layouts/ga'
script
| window.browserIdUser = #{browser_id_user};
body
= render 'layouts/header'
= render 'shared/flash'

@ -10,22 +10,15 @@ module Asciinema
attribute :aws_secret_access_key, String
attribute :carrierwave_storage, String, default: 'file'
attribute :carrierwave_storage_dir_prefix, String, default: 'uploads/'
attribute :github_consumer_key, String
attribute :github_consumer_secret, String
attribute :google_analytics_id, String
attribute :home_asciicast_id, Integer
attribute :local_persona_js, Boolean, default: false
attribute :scheme, String, default: 'http'
attribute :host, String, default: 'localhost:3000'
attribute :secret_token, String, default: '21deaa1a1228e119434aa783ecb4af21be7513ff1f5b8c1d8894241e5fc70ad395db72c8c1b0508a0ebb994ed88a8d73f6c84e44f7a4bc554a40d77f9844d2f4'
attribute :twitter_consumer_key, String
attribute :twitter_consumer_secret, String
attribute :admin_ids, Array[Integer]
attribute :host, String, default: 'localhost:3000'
attribute :smtp_settings, Hash
attribute :from_email, String, default: "Asciinema <hello@asciinema.org>"
alias_method :local_persona_js?, :local_persona_js
def home_asciicast
asciicast = if home_asciicast_id
Asciicast.find(home_asciicast_id)

@ -5,4 +5,4 @@ Rails.application.config.assets.version = '1.0'
# Precompile additional assets.
# application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
Rails.application.config.assets.precompile += %w( player.css player.js embed.css embed.js persona-include.js )
Rails.application.config.assets.precompile += %w( player.css player.js embed.css embed.js )

@ -1,9 +0,0 @@
Rails.application.config.middleware.use OmniAuth::Builder do
provider :twitter, CFG.twitter_consumer_key, CFG.twitter_consumer_secret, :client_options => { :ssl => { :ca_path => "/etc/ssl/certs" } }
provider :github, CFG.github_consumer_key, CFG.github_consumer_secret, :client_options => { :ssl => { :ca_path => "/etc/ssl/certs" } }
provider :browser_id
end
OmniAuth.config.on_failure = Proc.new { |env|
OmniAuth::FailureEndpoint.new(env).redirect_to_failure
}

@ -1,65 +0,0 @@
require 'rails_helper'
describe AccountMergesController do
describe '#create' do
subject { get :create, provider: 'twitter' }
let(:credentials) { double('credentials') }
let(:store) { {} }
before do
allow(controller).to receive(:omniauth_credentials) { credentials }
allow(controller).to receive(:store) { store }
allow(User).to receive(:for_credentials).with(credentials) { user }
store[:new_user_email] = 'foo@bar.com'
end
context "when user can be found for given credentials" do
let(:user) { stub_model(User) }
before do
allow(user).to receive(:update_attribute)
allow(controller).to receive(:current_user=)
subject
end
it 'updates the email on the user' do
expect(user).to have_received(:update_attribute).
with(:email, 'foo@bar.com')
end
it 'removes the email from the store' do
expect(store.key?(:new_user_email)).to be(false)
end
it 'sets the current_user' do
expect(controller).to have_received(:current_user=).with(user)
end
it 'redirects to the root_path with a notice' do
expect(flash[:notice]).to_not be_blank
should redirect_to(root_path)
end
end
context "when user can't be found for given credentials" do
let(:user) { nil }
before do
subject
end
it "doesn't remove the email from the store" do
expect(store.key?(:new_user_email)).to be(true)
end
it 'redirects to new user page with an alert' do
expect(flash[:alert]).to_not be_blank
should redirect_to(new_user_path)
end
end
end
end

@ -1,40 +0,0 @@
require 'rails_helper'
describe OmniAuthCredentials do
let(:credentials) { described_class.new(omniauth_hash) }
let(:omniauth_hash) { {
'provider' => 'twitter',
'uid' => '1234567',
'info' => { 'email' => 'foo@bar.com' }
} }
describe '#provider' do
subject { credentials.provider }
it { should eq('twitter') }
end
describe '#uid' do
subject { credentials.uid }
it { should eq('1234567') }
end
describe '#email' do
subject { credentials.email }
it { should eq('foo@bar.com') }
context "when no info section in hash" do
let(:omniauth_hash) { {
'provider' => 'twitter',
'uid' => '1234567'
} }
it { should be(nil) }
end
end
end

@ -1,7 +1,6 @@
# Read about factories at http://github.com/thoughtbot/factory_girl
FactoryGirl.define do
sequence(:uid) { |n| n }
sequence(:username) { |n| "user#{n}" }
factory :user do

@ -1,36 +1,4 @@
require 'rails_helper'
describe ApplicationHelper do
describe '#browser_id_user' do
let(:session) { {} }
subject { helper.browser_id_user }
before do
allow(helper).to receive(:session) { session }
allow(helper).to receive(:current_user) { user }
end
context "when current_user is present" do
let(:user) { double('user', email: 'foo@bar.com') }
it { should eq("'foo@bar.com'".html_safe) }
end
context "when current_user isn't present" do
let(:user) { nil }
it { should eq('null') }
context "when new_user_email is present in session" do
before do
session[:new_user_email] = 'qux@quux.com'
end
it { should eq("'qux@quux.com'".html_safe) }
end
end
end
end

@ -29,8 +29,6 @@ Dir[Rails.root.join("spec/shared/**/*.rb")].each { |f| require f }
Capybara.javascript_driver = :poltergeist
OmniAuth.config.test_mode = true
CarrierWave.configure do |config|
config.storage = :file
config.enable_processing = false

@ -15,23 +15,5 @@ module Asciinema
expect(page).to have_link('FAQ')
end
def set_omniauth(provider, opts = {})
if opts[:message]
OmniAuth.config.mock_auth[provider] = opts[:message]
else
OmniAuth.config.mock_auth[provider] = OmniAuth::AuthHash.new({
:provider => provider.to_s,
:uid => '123456',
:info => { :username => opts[:username] },
:extra => {
:raw_info => {
:avatar_url =>
'http://gravatar.com/avatar/9cecfc695240b56e5d3c1a5dc3830967'
}
}
})
end
end
end
end

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.1 KiB

File diff suppressed because one or more lines are too long

@ -1,376 +0,0 @@
/*
* Button Object
*/
/*
* 1. Corrects inability to style clickable 'input' types in iOS
* 2. Remove excess padding in IE6/7
* 3. IE6/7 inline-block hack for native block-level elements
*/
.btn-auth {
position: relative;
display: inline-block;
height: 22px;
padding: 0 1em;
border: 1px solid #999;
border-radius: 2px;
margin: 0;
text-align: center;
text-decoration: none;
font-size: 14px;
line-height: 22px;
white-space: nowrap;
cursor: pointer;
color: #222;
background: #fff;
-webkit-box-sizing: content-box;
-moz-box-sizing: content-box;
box-sizing: content-box;
/* iOS */
-webkit-appearance: none; /* 1 */
/* IE6/7 hacks */
*overflow: visible; /* 2 */
*display: inline; /* 3 */
*zoom: 1; /* 3 */
}
.btn-auth:hover,
.btn-auth:focus,
.btn-auth:active {
color: #222;
text-decoration: none;
}
.btn-auth:before {
content: "";
float: left;
width: 22px;
height: 22px;
background: image-url("auth-icons.png") no-repeat 99px 99px;
}
/*
* 36px
*/
.btn-auth.large {
height: 36px;
line-height: 36px;
font-size: 20px;
}
.btn-auth.large:before {
width: 36px;
height: 36px;
}
/*
* Remove excess padding and border in FF3+
*/
.btn-auth::-moz-focus-inner {
border: 0;
padding: 0;
}
/* Facebook (extends .btn-auth)
========================================================================== */
.btn-facebook {
border-color: #29447e;
border-bottom-color: #1a356e;
color: #fff;
background-color: #5872a7;
background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#637bad), to(#5872a7));
background-image: -webkit-linear-gradient(#637bad, #5872a7);
background-image: -moz-linear-gradient(#637bad, #5872a7);
background-image: -ms-linear-gradient(#637bad, #5872a7);
background-image: -o-linear-gradient(#637bad, #5872a7);
background-image: linear-gradient(#637bad, #5872a7);
-webkit-box-shadow: inset 0 1px 0 #879ac0;
box-shadow: inset 0 1px 0 #879ac0;
}
.btn-facebook:hover,
.btn-facebook:focus {
color: #fff;
background-color: #3b5998;
}
.btn-facebook:active {
color: #fff;
background: #4f6aa3;
-webkit-box-shadow: inset 0 1px 0 #45619d;
box-shadow: inset 0 1px 0 #45619d;
}
/*
* Icon
*/
.btn-facebook:before {
border-right: 1px solid #465f94;
margin: 0 1em 0 -1em;
background-position: 0 0;
}
.btn-facebook.large:before {
background-position: 0 -22px;
}
/* GitHub
========================================================================== */
.btn-github {
border-color: #d4d4d4;
background: #ececec;
background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#f4f4f4), to(#ececec));
background-image: -webkit-linear-gradient(#f4f4f4, #ececec);
background-image: -moz-linear-gradient(#f4f4f4, #ececec);
background-image: -ms-linear-gradient(#f4f4f4, #ececec);
background-image: -o-linear-gradient(#f4f4f4, #ececec);
background-image: linear-gradient(#f4f4f4, #ececec);
}
.btn-github:hover,
.btn-github:focus {
border-color: #518cc6;
border-bottom-color: #2a65a0;
color: #fff;
background-color: #599bdc;
background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#599bdc), to(#3072b3));
background-image: -webkit-linear-gradient(#599bdc, #3072b3);
background-image: -moz-linear-gradient(#599bdc, #3072b3);
background-image: -ms-linear-gradient(#599bdc, #3072b3);
background-image: -o-linear-gradient(#599bdc, #3072b3);
background-image: linear-gradient(#599bdc, #3072b3);
}
.btn-github:active {
border-color: #2A65A0;
border-bottom-color: #518CC6;
color: #fff;
background: #3072B3;
background: -webkit-gradient(linear, 0 0, 0 100%, from(#3072b3), to(#599bdc));
background: -webkit-linear-gradient(#3072b3, #599bdc);
background: -moz-linear-gradient(#3072b3, #599bdc);
background: -ms-linear-gradient(#3072b3, #599bdc);
background: -o-linear-gradient(#3072b3, #599bdc);
background: linear-gradient(#3072b3, #599bdc);
}
/*
* Icon
*/
.btn-github:before {
margin: 0 0.6em 0 -0.6em;
background-position: -44px 0;
}
.btn-github:hover:before,
.btn-github:focus:before,
.btn-github:active:before {
background-position: -66px 0;
}
.btn-github.large:before {
background-position: -72px -22px;
}
.btn-github.large:hover:before,
.btn-github.large:focus:before,
.btn-github.large:active:before {
background-position: -108px -22px;
}
/* Google
========================================================================== */
.btn-google {
border-color: #3079ed;
color: #fff;
background: #4787ed;
background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#4d90fe), to(#4787ed));
background-image: -webkit-linear-gradient(#4d90fe, #4787ed);
background-image: -moz-linear-gradient(#4d90fe, #4787ed);
background-image: -ms-linear-gradient(#4d90fe, #4787ed);
background-image: -o-linear-gradient(#4d90fe, #4787ed);
background-image: linear-gradient(#4d90fe, #4787ed);
}
.btn-google:hover,
.btn-google:focus,
.btn-google:active {
color: #fff;
background-color: #357ae8;
background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#4d90fe), to(#357ae8));
background-image: -webkit-linear-gradient(#4d90fe, #357ae8);
background-image: -moz-linear-gradient(#4d90fe, #357ae8);
background-image: -ms-linear-gradient(#4d90fe, #357ae8);
background-image: -o-linear-gradient(#4d90fe, #357ae8);
background-image: linear-gradient(#4d90fe, #357ae8);
}
.btn-google:active {
-webkit-box-shadow: inset 0 1px 2px rgba(0,0,0,0.3);
box-shadow: inset 0 1px 2px rgba(0,0,0,0.3);
}
/*
* Icon
*/
.btn-google:before {
margin: 0 1em 0 -1em;
background-position: -88px 0;
background-color: #e6e6e6;
}
.btn-google.large:before {
background-position: -144px -22px;
}
/* Open ID
========================================================================== */
.btn-openid:hover,
.btn-openid:focus {
border-color: #777;
background: #fcfcfc;
}
.btn-openid:active {
background: #f5f5f5;
}
/*
* Icon
*/
.btn-openid:before {
margin: 0 0.6em 0 -0.6em;
background-position: -154px 0;
}
.btn-openid.large:before {
background-position: -252px -22px;
}
/* Twitter
========================================================================== */
.btn-twitter {
border-color: #a6cde6;
color: #327695;
background: #cfe4f0;
/* css3 */
background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#f1f5f7), to(rgba(255,255,255,0)));
background-image: -webkit-linear-gradient(#f1f5f7, rgba(255,255,255,0));
background-image: -moz-linear-gradient(#f1f5f7, rgba(255,255,255,0));
background-image: -ms-linear-gradient(#f1f5f7, rgba(255,255,255,0));
background-image: -o-linear-gradient(#f1f5f7, rgba(255,255,255,0));
background-image: linear-gradient(#f1f5f7, rgba(255,255,255,0));
-webkit-box-shadow: inset 0 1px 0 #fff;
box-shadow: inset 0 1px 0 #fff;
}
.btn-twitter:hover,
.btn-twitter:focus,
.btn-twitter:active {
color: #327695;
border-color: #8dc2e4;
background-color: #cadde9;
}
.btn-twitter:active {
background: #cadde9;
-webkit-box-shadow: inset 0 1px 0 #bbd6e7;
box-shadow: inset 0 1px 0 #bbd6e7;
}
/*
* Icon
*/
.btn-twitter:before {
margin: 0 0.6em 0 -0.6em;
background-position: -22px 0;
}
.btn-twitter.large:before {
background-position: -36px -22px;
}
/* Windows Live ID
========================================================================== */
.btn-windows:hover,
.btn-windows:focus {
border-color: #777;
background: #fcfcfc;
}
.btn-windows:active {
background: #f5f5f5;
}
/*
* Icon
*/
.btn-windows:before {
margin: 0 0.6em 0 -0.6em;
background-position: -110px 0;
}
.btn-windows.large:before {
background-position: -180px -22px;
}
/* Yahoo!
========================================================================== */
.btn-yahoo {
border-color: #ffb305;
background: #ffc426;
background-image: -webkit-gradient(linear, 0 0, 0 100%, from(rgba(255,255,255,0.5)), to(rgba(255,255,255,0)));
background-image: -webkit-linear-gradient(rgba(255,255,255,0.5), rgba(255,255,255,0));
background-image: -moz-linear-gradient(rgba(255,255,255,0.5), rgba(255,255,255,0));
background-image: -ms-linear-gradient(rgba(255,255,255,0.5), rgba(255,255,255,0));
background-image: -o-linear-gradient(rgba(255,255,255,0.5), rgba(255,255,255,0));
background-image: linear-gradient(rgba(255,255,255,0.5), rgba(255,255,255,0));
}
.btn-yahoo:hover,
.btn-yahoo:focus {
background-color: #fabf20;
}
.btn-yahoo:active {
border-color: #f09700;
background-image: none;
-webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,0.3);
box-shadow: inset 0 1px 1px rgba(0,0,0,0.3);
}
/*
* Icon
*/
.btn-yahoo:before {
margin: 0 0.6em 0 -0.6em;
background-position: -132px 0;
}
.btn-yahoo.large:before {
background-position: -216px -22px;
}
Loading…
Cancel
Save