An Ruby WebFinger client library.
Following the latest WebFinger spec discussed at IETF WebFinger WG. tools.ietf.org/html/draft-ietf-appsawg-webfinger
If you found something different from the latest spec, open an issue please.
Add this line to your application’s Gemfile:
gem 'webfinger'
And then execute:
$ bundle
Or install it yourself as:
$ gem install webfinger
You can discover resource metadata.
WebFinger.discover! 'acct:[email protected]' WebFinger.discover! 'connect-op.heroku.com' WebFinger.discover! 'http://connect-op.heroku.com'
You can also specify link relations via “rel” option.
WebFinger.discover! 'acct:[email protected]', rel: 'http://openid.net/specs/connect/1.0/issuer' WebFinger.discover! 'acct:[email protected]', rel: ['http://openid.net/specs/connect/1.0/issuer', 'vcard']
Caching is important in HTTP-based discovery.
If you set your own cache object to WebFinger.cache
, this gem caches the discovery result until it expires. (the expiry is calculated based on the “expires” value in JRD response)
# Set Cache WebFinger.cache = Rails.cache WebFinger.discover! 'acct:[email protected]' # do HTTP request WebFinger.discover! 'acct:[email protected]' # use cache, no HTTP request
Once you turn-on debugging, you can see all HTTP request/response in your log.
# Turn on debugging WebFinger.debug! # Set logger (OPTIONAL, ::Logger.new(STDOUT) is used as default) WebFinger.logger = Rails.logger
You can also specify URL builder to force non-HTTPS access. (NOTE: allow non-HTTPS access only for debugging, not on your production.)
WebFinger.url_builder = URI::HTTP # default URI::HTTPS
-
Fork it
-
Create your feature branch (‘git checkout -b my-new-feature`)
-
Commit your changes (‘git commit -am ’Add some feature’‘)
-
Push to the branch (‘git push origin my-new-feature`)
-
Create new Pull Request
Copyright © 2012 nov matake. See LICENSE for details.