The project is in a healthy, maintained state
`openid_config_parser` is a lightweight Ruby gem designed to fetch and parse OpenID Connect configuration data from any specified endpoint URL. Whether you are building an authentication system or integrating with an OpenID Connect provider, this gem provides a simple and efficient way to retrieve and handle the necessary configuration details.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

 Project Readme

OpenidConfigParser

openid_config_parser is a lightweight Rubygem containing a method that fetches and parses OpenID Connect configuration data from a specified endpoint URL and returns a Hash object. It includes error handling to manage various issues that might occur during the HTTP request and JSON parsing process.

Installation

To install the gem run the following command in the terminal:

$ bundle add openid_config_parser

If bundler is not being used to manage dependencies, install the gem by executing:

$ gem install openid_config_parser

Usage

For non-Rails application you might need to require the gem in your file like so:

require 'openid_config_parser'

You can use the openid_config_parser in any of your Rails controllers, models, or other parts of your application.

# app/controllers/application_controller.rb

class ApplicationController < ActionController::Base
  def fetch_openid_config
    endpoint = "https://example.com/.well-known/openid-configuration"
    config = OpenidConfigParser.fetch_openid_configuration(endpoint)

    if config
      issuer = config.issuer # or config[:issuer]
      auth_endpoint = config.authorization_endpoint # or config[:authorization_endpoint]
      token_endpoint = config.token_endpoint # or config[:token_endpoint]
      jwks_uri = config.jwks_uri # or config[:jwks_uri]
      userinfo_endpoint = config.userinfo_endpoint # or config[:userinfo_endpoint]
      # and so on
    else
      Rails.logger.error "Failed to fetch OpenID configuration"
    end
  rescue OpenidConfigParser::Error => e
    Rails.logger.error "Error fetching OpenID configuration: #{e.message}"
  end
end

Considering that HTTP request is made to fetch the endpoint configuration, you can call this method in a background job for optimized performance.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/msuliq/openid_config_parser. 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 OpenidConfigParser project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.