No commit activity in last 3 years
No release in over 3 years
An easy to use OpenID Connect Client for Ruby
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Development

~> 1.11
~> 10.0
~> 3.0

Runtime

~> 0
 Project Readme

openid-connect-ruby

This is a literal, not so idiomatic ruby port of Michael Jett's excellent OpenID Connect library for PHP.

Requirements

Installation

gem install openid_connect_client

Usage

It's done in two steps: first, in your login controller you'll request authorization and redirect the user to the OpenID Connect provider. If your app gets authorized, then the provider will redirect the user back to your callback url where you'll be able to ask the provider for the user data.

See example.rb

In the login controller

# 1. Client setup
oidc = OpenIDConnectClient::Client.new('https://provider.com/openid', 'CLIENT_ID', 'SECRET')
oidc.redirect_url = "http://yourweb.com/callback"
oidc.scopes = "openid email profile address"

# 2. Request authorization
oidc.authorize()

# 3. Save state in session
session[:state] = oidc.state

# 4. Redirect user to OpenID Connect provider
redirect_to(oidc.auth_endpoint)

In the callback controller

# 1. Get client
oidc = OpenIDConnectClient::Client.new('https://provider.com/openid', 'CLIENT_ID', 'SECRET')

# 2. Restore state
oidc.state = session[:state]

# 3. Pass the authorization parameters sent by the provider
oidc.params = request.parameters

# 4. Authenticate your app against the provider
oidc.authenticate()

# 5. Fetch the user's details
given_name = oidc.get('given_name')
email = oidc.get('email')
address = oidc.get('address')