Repository is archived
No commit activity in last 3 years
No release in over 3 years
Deprecated in favor of indieweb-endpoints from 2019-04-24. Discover a URL’s authorization endpoint for use with Micropub and IndieAuth clients.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 12.3
~> 3.8
~> 0.67.2
~> 0.16.1
~> 3.5

Runtime

~> 4.1
~> 1.10
 Project Readme

authorization-endpoint-ruby

⚠️ Deprecation Notice (2019-04-24) ⚠️ This gem is deprecated in favor of indieweb/indieweb-endpoints-ruby and will no longer receive updates.


A Ruby gem for discovering a URL’s authorization endpoint for use with Micropub and IndieAuth clients.

Gem Downloads Build Dependencies Maintainability Coverage

Key Features

Getting Started

Before installing and using authorization-endpoint-ruby, you'll want to have Ruby 2.4 (or newer) installed. It's recommended that you use a Ruby version managment tool like rbenv, chruby, or rvm.

authorization-endpoint-ruby is developed using Ruby 2.4.6 and is additionally tested against Ruby 2.5.5 and 2.6.2 using Travis CI.

Installation

If you're using Bundler, add authorization-endpoint-ruby to your project's Gemfile:

source 'https://rubygems.org'

gem 'authorization-endpoint'

…and hop over to your command prompt and run…

$ bundle install

Usage

Basic Usage

With authorization-endpoint-ruby added to your project's Gemfile and installed, you may discover a URL's authorization endpoint by doing:

require 'authorization-endpoint'

endpoint = AuthorizationEndpoint.discover('https://aaronparecki.com')

puts endpoint # returns String: 'https://aaronparecki.com/auth'

This example will search https://aaronparecki.com for a valid authorization endpoint using the same rules described in the W3C's Micropub Recommendation. In this case, the program returns a string: https://aaronparecki.com/auth.

If no endpoint is discovered at the provided URL, the program will return nil:

require 'authorization-endpoint'

endpoint = AuthorizationEndpoint.discover('https://example.com')

puts endpoint.nil? # returns Boolean: true

Advanced Usage

Should the need arise, you may work directly with the AuthorizationEndpoint::Client class:

require 'authorization-endpoint'

client = AuthorizationEndpoint::Client.new('https://aaronparecki.com')

puts client.response # returns HTTP::Response
puts client.endpoint # returns String: 'https://aaronparecki.com/auth'

Exception Handling

There are several exceptions that may be raised by authorization-endpoint-ruby's underlying dependencies. These errors are raised as subclasses of AuthorizationEndpoint::Error (which itself is a subclass of StandardError).

From jgarber623/absolutely and sporkmonger/addressable:

  • AuthorizationEndpoint::InvalidURIError

From httprb/http:

  • AuthorizationEndpoint::ConnectionError
  • AuthorizationEndpoint::TimeoutError
  • AuthorizationEndpoint::TooManyRedirectsError

Contributing

Interested in helping improve authorization-endpoint-ruby? Awesome! Your help is greatly appreciated. See CONTRIBUTING.md for details.

Acknowledgments

authorization-endpoint-ruby wouldn't exist without Micropub and the hard work put in by everyone involved in the IndieWeb movement.

authorization-endpoint-ruby is written and maintained by Jason Garber.

License

authorization-endpoint-ruby is freely available under the MIT License. Use it, learn from it, fork it, improve it, change it, tailor it to your needs.