omniauth-hack_club 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 0cbbbdc010e75678bda5162bc0223bf55a2384eaefcffc230b73f24125623ebd
4
+ data.tar.gz: f4d93e173317b81ad812f7591ef423265f1f2da61e85b8c36bf68fcf4a76a54d
5
+ SHA512:
6
+ metadata.gz: bec4d86d1d031c177631ab120042f4dd5af837179fe3f5eedff76a52dd0e53550055f9cc3a07d073e8642be7cb9ef38bff80ded659d1b6bdb6fd763464a5d059
7
+ data.tar.gz: 7397d9351b503df2a694772359ab8a85dea68a52e53c50a6e55684a9625931601a31e52b6dbd35c03c8b9e504725e1dc92426d6c673c36849879fee833cb7689
data/CHANGELOG.md ADDED
@@ -0,0 +1,6 @@
1
+ # Changelog
2
+
3
+ ## 1.0.0 (2024-12-15)
4
+
5
+ - Initial release
6
+
data/LICENSE.md ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2025 Hack Club
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,93 @@
1
+ # omniauth-hack_club
2
+
3
+ An OmniAuth strategy for authenticating with [Hack Club Auth](https://auth.hackclub.com).
4
+
5
+ ## Installation
6
+
7
+ Add to your Gemfile:
8
+
9
+ ```ruby
10
+ gem "omniauth-hack_club"
11
+ ```
12
+
13
+ Then run `bundle install`.
14
+
15
+ ## Usage
16
+
17
+ 1. Create an OAuth application at [auth.hackclub.com/developer/apps](https://auth.hackclub.com/developer/apps)
18
+ 2. Configure the strategy in your application:
19
+
20
+ ### Rails
21
+
22
+ ```ruby
23
+ # config/initializers/omniauth.rb
24
+ Rails.application.config.middleware.use OmniAuth::Builder do
25
+ provider :hack_club, ENV["HACKCLUB_CLIENT_ID"], ENV["HACKCLUB_CLIENT_SECRET"],
26
+ scope: "openid email name slack_id verification_status"
27
+ end
28
+ ```
29
+
30
+ ### Sinatra
31
+
32
+ ```ruby
33
+ use OmniAuth::Builder do
34
+ provider :hack_club, ENV["HACKCLUB_CLIENT_ID"], ENV["HACKCLUB_CLIENT_SECRET"],
35
+ scope: "openid email name slack_id verification_status"
36
+ end
37
+ ```
38
+
39
+ ### Staging Environment
40
+
41
+ To use the staging instance at `hca.dinosaurbbq.org`:
42
+
43
+ ```ruby
44
+ provider :hack_club, ENV["HACKCLUB_CLIENT_ID"], ENV["HACKCLUB_CLIENT_SECRET"],
45
+ scope: "openid email name",
46
+ staging: true
47
+ ```
48
+
49
+ ## Available Scopes
50
+
51
+ Community apps can request the following scopes:
52
+
53
+ | Scope | Description |
54
+ |-------|-------------|
55
+ | `openid` | Enable OpenID Connect authentication |
56
+ | `profile` | Name and profile information (OIDC) |
57
+ | `email` | Access to email address |
58
+ | `name` | Access to first and last name |
59
+ | `slack_id` | Access to Slack ID |
60
+ | `verification_status` | Verification status and YSWS eligibility |
61
+
62
+ ## Auth Hash
63
+
64
+ The auth hash available in `request.env["omniauth.auth"]` will contain:
65
+
66
+ ```ruby
67
+ {
68
+ provider: "hack_club",
69
+ uid: "ident!abc123",
70
+ info: {
71
+ email: "user@example.com",
72
+ name: "Ada Lovelace",
73
+ first_name: "Ada",
74
+ last_name: "Lovelace",
75
+ slack_id: "U12345678",
76
+ verification_status: "verified"
77
+ },
78
+ credentials: {
79
+ token: "idntk.skdfjlsdfjsldf",
80
+ expires_at: 1234567890,
81
+ expires: true
82
+ },
83
+ extra: {
84
+ raw_info: {
85
+ # Full response from /api/v1/me
86
+ }
87
+ }
88
+ }
89
+ ```
90
+
91
+ ## License
92
+
93
+ MIT License. See [LICENSE.md](LICENSE.md).
@@ -0,0 +1,61 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'omniauth-oauth2'
4
+
5
+ module OmniAuth
6
+ module Strategies
7
+ class HackClub < OmniAuth::Strategies::OAuth2
8
+ PRODUCTION_SITE = 'https://auth.hackclub.com'
9
+ STAGING_SITE = 'https://hca.dinosaurbbq.org'
10
+
11
+ option :name, 'hack_club'
12
+ option :staging, false
13
+ option :scope, 'email'
14
+
15
+ option :client_options, {
16
+ site: PRODUCTION_SITE,
17
+ authorize_url: '/oauth/authorize',
18
+ token_url: '/oauth/token'
19
+ }
20
+
21
+ option :authorize_options, %i[scope]
22
+
23
+ def client
24
+ options.client_options[:site] = options.staging ? STAGING_SITE : PRODUCTION_SITE
25
+ super
26
+ end
27
+
28
+ uid { identity['id'] }
29
+
30
+ info do
31
+ {
32
+ email: identity['primary_email'],
33
+ name: identity['name'],
34
+ first_name: identity['first_name'],
35
+ last_name: identity['last_name'],
36
+ slack_id: identity['slack_id'],
37
+ verification_status: identity['verification_status']
38
+ }.compact
39
+ end
40
+
41
+ extra do
42
+ {
43
+ raw_info: raw_info,
44
+ scopes: raw_info['scopes']
45
+ }
46
+ end
47
+
48
+ def raw_info
49
+ @raw_info ||= access_token.get('/api/v1/me').parsed
50
+ end
51
+
52
+ def identity
53
+ raw_info['identity'] || {}
54
+ end
55
+
56
+ def callback_url
57
+ full_host + callback_path
58
+ end
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module OmniAuth
4
+ module HackClub
5
+ VERSION = '1.0.1'
6
+ end
7
+ end
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'omniauth-hack_club/version'
4
+ require 'omniauth/strategies/hack_club'
metadata ADDED
@@ -0,0 +1,64 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omniauth-hack_club
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Nora
8
+ bindir: bin
9
+ cert_chain: []
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
+ dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: omniauth-oauth2
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - "~>"
17
+ - !ruby/object:Gem::Version
18
+ version: '1.8'
19
+ type: :runtime
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - "~>"
24
+ - !ruby/object:Gem::Version
25
+ version: '1.8'
26
+ description: An OmniAuth strategy for authenticating with Hack Club Auth using OAuth2.
27
+ email:
28
+ - auth@hackclub.com
29
+ executables: []
30
+ extensions: []
31
+ extra_rdoc_files: []
32
+ files:
33
+ - CHANGELOG.md
34
+ - LICENSE.md
35
+ - README.md
36
+ - lib/omniauth-hack_club.rb
37
+ - lib/omniauth-hack_club/version.rb
38
+ - lib/omniauth/strategies/hack_club.rb
39
+ homepage: https://github.com/24c02/omniauth-hack_club
40
+ licenses:
41
+ - MIT
42
+ metadata:
43
+ homepage_uri: https://github.com/24c02/omniauth-hack_club
44
+ source_code_uri: https://github.com/24c02/omniauth-hack_club
45
+ changelog_uri: https://github.com/24c02/omniauth-hack_club/blob/main/CHANGELOG.md
46
+ rubygems_mfa_required: 'true'
47
+ rdoc_options: []
48
+ require_paths:
49
+ - lib
50
+ required_ruby_version: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: 2.7.0
55
+ required_rubygems_version: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: '0'
60
+ requirements: []
61
+ rubygems_version: 3.6.7
62
+ specification_version: 4
63
+ summary: OmniAuth strategy for Hack Club Auth
64
+ test_files: []