omniauth-hack_club
An OmniAuth strategy for authenticating with Hack Club Auth.
Installation
Add to your Gemfile:
gem "omniauth-hack_club"
Then run bundle install.
Usage
- Create an OAuth application at auth.hackclub.com/developer/apps
- Configure the strategy in your application:
Rails
# config/initializers/omniauth.rb
Rails.application.config.middleware.use OmniAuth::Builder do
provider :hack_club, ENV["HACKCLUB_CLIENT_ID"], ENV["HACKCLUB_CLIENT_SECRET"],
scope: "openid email name slack_id verification_status"
end
Sinatra
use OmniAuth::Builder do
provider :hack_club, ENV["HACKCLUB_CLIENT_ID"], ENV["HACKCLUB_CLIENT_SECRET"],
scope: "openid email name slack_id verification_status"
end
Staging Environment
To use the staging instance at hca.dinosaurbbq.org:
provider :hack_club, ENV["HACKCLUB_CLIENT_ID"], ENV["HACKCLUB_CLIENT_SECRET"],
scope: "openid email name",
staging: true
Available Scopes
Community apps can request the following scopes:
| Scope | Description |
|---|---|
openid |
Enable OpenID Connect authentication |
profile |
Name and profile information (OIDC) |
email |
Access to email address |
name |
Access to first and last name |
slack_id |
Access to Slack ID |
verification_status |
Verification status and YSWS eligibility |
Auth Hash
The auth hash available in request.env["omniauth.auth"] will contain:
{
provider: "hack_club",
uid: "ident!abc123",
info: {
email: "[email protected]",
name: "Ada Lovelace",
first_name: "Ada",
last_name: "Lovelace",
slack_id: "U12345678",
verification_status: "verified"
},
credentials: {
token: "idntk.skdfjlsdfjsldf",
expires_at: 1234567890,
expires: true
},
extra: {
raw_info: {
# Full response from /api/v1/me
}
}
}
License
MIT License. See LICENSE.md.