indieauth_discovery
Profile and client discovery for Ruby-based IndieAuth clients and providers.
Features
- [x] User profile URL and client identifier validation and canonicalization with
- [x] Handling of permanant and temporary redirects
- [x] Authorization, token, and MicroPub endpoint discovery from user profiles
Roadmap
Installation
Add this line to your application's Gemfile
:
gem 'indieauth_discovery'
And then execute:
$ bundle install
Or install it yourself as:
$ gem install indieauth_discovery
Usage
URL verification and canonicalization
indieauth_discovery
can canonicalize and verify URLs indepedently of information discovery via the IndieAuthDiscovery::URL
class:
require 'indieauth_discovery/url'
url = IndieAuthDiscovery::URL.new('example.com')
url.canonicalize
# or
url = IndieAuthDiscovery::URL.canonicalize('example.com')
url.original_url # example.com
url.canonical_url # http://example.com/
The #canonicalize
method performs the following steps:
- Normalizes the URL (downcases the hostname)
- Verifies the URL if already
http
orhttps
by performing an HTTPHEAD
request - If the URL is generic without a scheme (i.e.
example.com
), attempts to verify the URL with an HTTPHEAD
request to bothhttps://<url>
andhttp://<url>
, prioritizing HTTPS - Ensures the URL has a path by appending
/
to it if the path component is empty - Follows up to three redirects, and uses the last permanent (301) redirect as the canonical URL
If none of the steps above result in a verified URL, an IndieAuthDiscovery::InvalidURLError
will be raised.
User profile discovery
User profile information can be discovered with indieauth_discovery
via the IndieAuthDiscovery::Profile
class:
require 'indieauth_discovery/profile'
profile = IndieAuthDiscovery::Profile.new('example.com')
profile.discover
# or
profile = IndieAuthDiscovery::Profile.discover('example.com')
profile.url # http://example.com/
profile. # http://example.com/auth
profile.token_endpoint # http://example.com/token
profile.micropub_endpoint # http://example.com/micropub
Development
After checking out the repo, run bin/setup
to install dependencies. Then, run bundle exec rspec
to run the tests. You can also run bin/console
for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install
. To release a new version, update the version number in version.rb
, and then run bundle exec rake release
, which will create a git tag for the version, push git commits and tags, and push the .gem
file to rubygems.org.
Contributing
Bug reports and pull requests are welcome on GitHub at craftyphotons/indieauth_discovery. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.
License
The gem is available as open source under the terms of the MIT License.
Code of Conduct
Everyone interacting in the IndieauthDiscovery project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.