Skip to content
This repository

OpenID improvements and one other #5

Closed
wants to merge 4 commits into from

2 participants

Stephen Paul Weber Aaron Parecki
Stephen Paul Weber

I could not reproduce failures with any of my OpenIDs on my local box. I'm a bit suprised that there isn't a DataMapper or similar store, though, I may write one. That said, I used to use file-based stores without trouble (except on on host, where the tmp folder was just super slow).

This pull request contains some improvements to the OpenID handling in general, as well as some logic to reduce duplicate fetches in the detection.

Aaron Parecki
Owner
aaronpk commented

Dropping OpenID support

Aaron Parecki aaronpk closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 4 unique commits by 1 author.

Oct 11, 2012
Stephen Paul Weber singpolyma Do not fetch the same link twice
If a page lists a link more than once, or links to itself, don't fetch
more than once.
f68bca1
Stephen Paul Weber singpolyma Add OpenID to bootstrap dc130fc
Stephen Paul Weber singpolyma We do not require any profile info 12d732f
Stephen Paul Weber singpolyma More robust OpenID detection 5c3216e
This page is out of date. Refresh to see the latest.

Showing 3 changed files with 8 additions and 3 deletions. Show diff stats Hide diff stats

  1. +4 0 Rakefile
  2. +1 1  environment.rb
  3. +3 2 lib/relparser.rb
4 Rakefile
@@ -48,6 +48,10 @@ namespace :db do
48 48 :regex_username => 'https?:\/\/(?:www\.)?twitter\.com\/([^\/]+)'
49 49 })
50 50
  51 + openid = Provider.create ({
  52 + :code => 'open_id'
  53 + })
  54 +
51 55 end
52 56 task :migrate do
53 57 init
2  environment.rb
@@ -47,7 +47,7 @@ class Controller < Sinatra::Base
47 47 # puts "Configuring provider #{p['code'].to_sym} with #{p['client_id']} and #{p['client_secret']}"
48 48 provider p['code'].to_sym, p['client_id'], p['client_secret'] if p['client_id']
49 49 end
50   - provider :open_id, :store => OpenID::Store::Filesystem.new('/tmp')
  50 + provider :open_id, :required => [], :optional => [], :store => OpenID::Store::Filesystem.new('/tmp')
51 51 end
52 52
53 53 DataMapper.finalize
5 lib/relparser.rb
@@ -11,6 +11,7 @@ def initialize(opts={})
11 11 # Normalize
12 12 @meURI.scheme = "http" if @meURI.scheme == "https"
13 13 @meURI.path = "/" if @meURI.path == ""
  14 + @meURI.normalize!
14 15 end
15 16
16 17 def agent
@@ -40,7 +41,7 @@ def get(tag)
40 41 @page.links.each do |link|
41 42 links << link.href if link.rel?("me")
42 43 end
43   - links
  44 + links.map {|u| URI::parse(u).normalize}.uniq.reject {|u| u == @meURI}.map(&:to_s)
44 45 end
45 46
46 47 def rel_me_links
@@ -74,7 +75,7 @@ def get_provider
74 75 # If the page contains an openID tag, use it!
75 76 return nil if @page.class != Mechanize::Page
76 77
77   - if @page.at('/html/head/link[@rel="openid.server"]/@href') || @page.at('/html/head/link[@rel="openid2.provider"]/@href')
  78 + if @page.at('link[rel~="openid.server"]') || @page.at('link[rel~="openid2.provider"]')
78 79 return Provider.first(:code => 'open_id')
79 80 end
80 81 return nil

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.