summaryrefslogtreecommitdiff
path: root/users/lib
diff options
context:
space:
mode:
authorAzul <azul@leap.se>2013-01-22 12:02:18 +0100
committerAzul <azul@leap.se>2013-01-22 13:06:37 +0100
commitde48efcf2a6b5fb096fd209b1efea482f743c19c (patch)
treec555b53719f67fd48bd6b742ff2f5e2ede7b7c53 /users/lib
parented1caa740f0e58cfd5f2d908946461154db68174 (diff)
some basic webfinger routes, controller, presenters, views
Diffstat (limited to 'users/lib')
-rw-r--r--users/lib/.webfinger.rb.swpbin0 -> 12288 bytes
-rw-r--r--users/lib/leap_web_users/engine.rb2
-rw-r--r--users/lib/webfinger.rb6
-rw-r--r--users/lib/webfinger/host_meta_presenter.rb17
-rw-r--r--users/lib/webfinger/user_presenter.rb16
5 files changed, 41 insertions, 0 deletions
diff --git a/users/lib/.webfinger.rb.swp b/users/lib/.webfinger.rb.swp
new file mode 100644
index 0000000..09528c6
--- /dev/null
+++ b/users/lib/.webfinger.rb.swp
Binary files differ
diff --git a/users/lib/leap_web_users/engine.rb b/users/lib/leap_web_users/engine.rb
index 7033576..f8ed71c 100644
--- a/users/lib/leap_web_users/engine.rb
+++ b/users/lib/leap_web_users/engine.rb
@@ -7,6 +7,8 @@ require "ruby-srp"
require "warden/session_serializer"
require "warden/strategies/secure_remote_password"
+require "webfinger"
+
module LeapWebUsers
class Engine < ::Rails::Engine
diff --git a/users/lib/webfinger.rb b/users/lib/webfinger.rb
new file mode 100644
index 0000000..dd49b41
--- /dev/null
+++ b/users/lib/webfinger.rb
@@ -0,0 +1,6 @@
+module Webfinger
+
+ autoload :HostMetaPresenter, 'webfinger/host_meta_presenter'
+ autoload :UserPresenter, 'webfinger/user_presenter'
+
+end
diff --git a/users/lib/webfinger/host_meta_presenter.rb b/users/lib/webfinger/host_meta_presenter.rb
new file mode 100644
index 0000000..3901a28
--- /dev/null
+++ b/users/lib/webfinger/host_meta_presenter.rb
@@ -0,0 +1,17 @@
+require 'uri'
+
+class Webfinger::HostMetaPresenter
+ def initialize(request)
+ @request = request
+ end
+
+ def subject
+ url = URI.parse(@request.url)
+ url.path = ''
+ url.to_s
+ end
+
+ def webfinger_template(path = 'webfinger', query_param='q')
+ "#{subject}/#{path}?#{query_param}={uri}"
+ end
+end
diff --git a/users/lib/webfinger/user_presenter.rb b/users/lib/webfinger/user_presenter.rb
new file mode 100644
index 0000000..bbfc908
--- /dev/null
+++ b/users/lib/webfinger/user_presenter.rb
@@ -0,0 +1,16 @@
+class Webfinger::UserPresenter
+ attr_accessor :subject
+
+ def initialize(subject, request)
+ @subject = subject
+ @request = request
+ end
+
+ def email_identifier
+ "#{@subject.username}@#{@request.host}"
+ end
+
+ def key
+ Base64.encode64(@subject.public_key.to_s)
+ end
+end