Class: DiasporaFederation::Discovery::WebFinger
- Defined in:
- lib/diaspora_federation/discovery/web_finger.rb
Overview
The WebFinger document used for diaspora* user discovery is based on an older draft of the specification.
In the meantime an actual RFC draft has been in development, which should serve as a base for all future changes of this implementation.
Constant Summary collapse
- REL_HCARD =
hcard_url
link relation "http://microformats.org/profile/hcard".freeze
- REL_SEED =
seed_url
link relation "http://joindiaspora.com/seed_location".freeze
- REL_GUID =
Deprecated.
This should be a
Property
or moved to thehCard
, butLink
is inappropriate according to the specification (will affect older diaspora* installations).guid
link relation "http://joindiaspora.com/guid".freeze
- REL_PROFILE =
Note:
This might just as well be an
Alias
instead of aLink
.profile_url
link relation. "http://webfinger.net/rel/profile-page".freeze
- REL_ATOM =
atom_url
link relation "http://schemas.google.com/g/2010#updates-from".freeze
- REL_SALMON =
salmon_url
link relation "salmon".freeze
- REL_SUBSCRIBE =
subscribe_url
link relation "http://ostatus.org/schema/1.0/subscribe".freeze
- REL_PUBKEY =
Deprecated.
This should be a
Property
or moved to thehcard
, butLink
is inappropriate according to the specification (will affect older diaspora* installations).pubkey
link relation "diaspora-public-key".freeze
Constants inherited from Entity
Instance Attribute Summary collapse
-
#acct_uri ⇒ String
readonly
The Subject element should contain the webfinger address that was asked for.
-
#alias_url ⇒ String
readonly
Link to the users profile.
-
#atom_url ⇒ String
readonly
This atom feed is an Activity Stream of the user’s public posts.
-
#guid ⇒ String
readonly
deprecated
Deprecated.
Either convert these to
Property
elements or move to thehCard
, which actually has fields for anUID
defined in thevCard
specification (will affect older diaspora* installations). -
#hcard_url ⇒ String
readonly
Link to the
hCard
. -
#profile_url ⇒ String
readonly
Link to the users profile.
-
#public_key ⇒ String
readonly
deprecated
Deprecated.
Either convert these to
Property
elements or move to thehCard
, which actually has fields for anKEY
defined in thevCard
specification (will affect older diaspora* installations). -
#salmon_url ⇒ String
readonly
Salmon endpoint url.
-
#seed_url ⇒ String
readonly
Link to the pod.
-
#subscribe_url ⇒ Object
readonly
This url is used to find another user on the home-pod of the user in the webfinger.
Class Method Summary collapse
-
.from_xml(webfinger_xml) ⇒ WebFinger
Creates a WebFinger instance from the given XML string.
Instance Method Summary collapse
-
#to_s ⇒ String
String representation of this object.
-
#to_xml ⇒ String
Creates the XML string from the current WebFinger instance.
Methods inherited from Entity
entity_class, entity_name, #initialize, #to_h
Methods included from PropertiesDSL
#class_props, #default_values, #entity, #find_property_for_xml_name, #missing_props, #property, #resolv_aliases, #xml_names
Methods included from Logging
Constructor Details
This class inherits a constructor from DiasporaFederation::Entity
Instance Attribute Details
#acct_uri ⇒ String (readonly)
The Subject element should contain the webfinger address that was asked for. If it does not, then this webfinger profile MUST be ignored.
38 |
# File 'lib/diaspora_federation/discovery/web_finger.rb', line 38 property :acct_uri |
#alias_url ⇒ String (readonly)
could be nil
Returns link to the users profile.
43 |
# File 'lib/diaspora_federation/discovery/web_finger.rb', line 43 property :alias_url |
#atom_url ⇒ String (readonly)
This atom feed is an Activity Stream of the user’s public posts. diaspora* pods SHOULD publish an Activity Stream of public posts, but there is currently no requirement to be able to read Activity Streams. Note that this feed MAY also be made available through the PubSubHubbub mechanism by supplying a <link rel=“hub”> in the atom feed itself.
66 |
# File 'lib/diaspora_federation/discovery/web_finger.rb', line 66 property :atom_url |
#guid ⇒ String (readonly)
Either convert these to Property
elements or move to the hCard
, which actually has fields for an UID
defined in the vCard
specification (will affect older diaspora* installations).
Returns guid.
87 |
# File 'lib/diaspora_federation/discovery/web_finger.rb', line 87 property :guid |
#hcard_url ⇒ String (readonly)
Returns link to the hCard
.
47 |
# File 'lib/diaspora_federation/discovery/web_finger.rb', line 47 property :hcard_url |
#profile_url ⇒ String (readonly)
Returns link to the users profile.
55 |
# File 'lib/diaspora_federation/discovery/web_finger.rb', line 55 property :profile_url |
#public_key ⇒ String (readonly)
Either convert these to Property
elements or move to the hCard
, which actually has fields for an KEY
defined in the vCard
specification (will affect older diaspora* installations).
When a user is created on the pod, the pod MUST generate a pgp keypair for them. This key is used for signing messages. The format is a DER-encoded PKCS#1 key beginning with the text “—–BEGIN PUBLIC KEY—–” and ending with “—–END PUBLIC KEY—–”.
101 |
# File 'lib/diaspora_federation/discovery/web_finger.rb', line 101 property :public_key |
#salmon_url ⇒ String (readonly)
could be nil
Returns salmon endpoint url.
73 |
# File 'lib/diaspora_federation/discovery/web_finger.rb', line 73 property :salmon_url |
#seed_url ⇒ String (readonly)
Returns link to the pod.
51 |
# File 'lib/diaspora_federation/discovery/web_finger.rb', line 51 property :seed_url |
#subscribe_url ⇒ Object (readonly)
This url is used to find another user on the home-pod of the user in the webfinger.
77 |
# File 'lib/diaspora_federation/discovery/web_finger.rb', line 77 property :subscribe_url |
Class Method Details
.from_xml(webfinger_xml) ⇒ WebFinger
Creates a WebFinger instance from the given XML string
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 |
# File 'lib/diaspora_federation/discovery/web_finger.rb', line 150 def self.from_xml(webfinger_xml) data = parse_xml_and_validate(webfinger_xml) links = data[:links] # TODO: remove! public key is deprecated in webfinger public_key = parse_link(links, REL_PUBKEY) new( acct_uri: data[:subject], alias_url: parse_alias(data[:aliases]), hcard_url: parse_link(links, REL_HCARD), seed_url: parse_link(links, REL_SEED), profile_url: parse_link(links, REL_PROFILE), atom_url: parse_link(links, REL_ATOM), salmon_url: parse_link(links, REL_SALMON), subscribe_url: parse_link_template(links, REL_SUBSCRIBE), # TODO: remove me! ########## guid: parse_link(links, REL_GUID), public_key: (Base64.strict_decode64(public_key) if public_key) ) end |
Instance Method Details
#to_s ⇒ String
Returns string representation of this object.
176 177 178 |
# File 'lib/diaspora_federation/discovery/web_finger.rb', line 176 def to_s "WebFinger:#{acct_uri}" end |
#to_xml ⇒ String
Creates the XML string from the current WebFinger instance
136 137 138 139 140 141 142 143 144 |
# File 'lib/diaspora_federation/discovery/web_finger.rb', line 136 def to_xml doc = XrdDocument.new doc.subject = @acct_uri doc.aliases << @alias_url add_links_to(doc) doc.to_xml end |