omniauth-cul 0.2.0 → 0.3.0
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 +4 -4
- data/.rubocop.yml +6 -11
- data/README.md +89 -47
- data/Rakefile +3 -3
- data/lib/omniauth/cul/case_converter.rb +7 -0
- data/lib/omniauth/cul/{cas_3.rb → columbia_cas.rb} +24 -10
- data/lib/omniauth/cul/exceptions.rb +6 -0
- data/lib/omniauth/cul/permission_file_validator.rb +11 -3
- data/lib/omniauth/cul/version.rb +1 -1
- data/lib/omniauth/cul.rb +7 -4
- data/lib/omniauth/strategies/columbia_cas.rb +21 -0
- data/lib/omniauth/strategies/developer_uid.rb +40 -0
- data/omniauth-cul.gemspec +41 -0
- metadata +10 -6
- data/lib/omniauth/cul/strategies/cas_3_strategy.rb +0 -9
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 875301ec5d629a7d873ed8128f9e85db1483328ccaa8399ea5b39c90da551d7a
|
|
4
|
+
data.tar.gz: a4a97f035b3c4993b145985861ea1fce2f1b742db5cfc133dda7db0e1a90e28c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f3275f7f39fa158516e144f626cc1c274191f73db0da823944b0a9503d7c49d01924679f5275b51c4556cbb062a2cb1cb732d3345cf963211c1d0917e8aca3d3
|
|
7
|
+
data.tar.gz: 05a5a1a6942d900fe8201e20d84e2f986e123ba4e35339f5030f888a6da96c985fa412d307db5dde974c67f6ae72188a6f36dfc6505494d1d076d0430f5053d9
|
data/.rubocop.yml
CHANGED
|
@@ -1,13 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
Style/StringLiterals:
|
|
5
|
-
Enabled: true
|
|
6
|
-
EnforcedStyle: double_quotes
|
|
1
|
+
inherit_gem:
|
|
2
|
+
rubocul: rubocul_default.yml
|
|
7
3
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
EnforcedStyle: double_quotes
|
|
4
|
+
AllCops:
|
|
5
|
+
TargetRubyVersion: 3.1
|
|
11
6
|
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
Rails:
|
|
8
|
+
Enabled: false
|
data/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
# Cul
|
|
1
|
+
# Omniauth::Cul
|
|
2
2
|
|
|
3
|
-
Cul
|
|
3
|
+
Omniauth::Cul is a gem that facilitates using Rails, [Devise](https://github.com/plataformatec/devise "Devise") and Omniauth with the [CAS offering from Columbia University IT](https://cuit.columbia.edu/cas-authentication "CUIT CAS Documentation").
|
|
4
4
|
|
|
5
5
|
At this time, this gem only supports Columbia University's CAS3 authentication endpoint (which provides user affiliation information), but support for additional auth mechanisms may be added later if needed.
|
|
6
6
|
|
|
@@ -8,74 +8,116 @@ At this time, this gem only supports Columbia University's CAS3 authentication e
|
|
|
8
8
|
|
|
9
9
|
The instructions below assume that your Rails application's user model will be called "User".
|
|
10
10
|
|
|
11
|
-
1. Add gem `devise` (
|
|
11
|
+
1. Add gem `devise` (~> 4.9) to your Gemfile. (This gem has only been tested with Devise 4.x.)
|
|
12
12
|
2. Follow the standard Devise setup instructions (https://github.com/heartcombo/devise). Recap:
|
|
13
13
|
1. `rails generate devise:install`
|
|
14
14
|
2. `rails generate devise User`
|
|
15
15
|
3. `rails db:migrate`
|
|
16
|
-
3. Add gem `omniauth` (
|
|
17
|
-
4. Add this gem, 'omniauth-cul', to your Gemfile.
|
|
16
|
+
3. Add gem `omniauth` (~> 2.1) to your Gemfile.
|
|
17
|
+
4. Add this gem, 'omniauth-cul', to your Gemfile. (This gem has only been tested with omniauth 2.x.)
|
|
18
18
|
5. Run `bundle install`.
|
|
19
|
-
6.
|
|
19
|
+
6. Add an initializer to your app at `/config/initializers/omniauth.rb` with this content in it (to mitigate):
|
|
20
|
+
1. ```
|
|
21
|
+
OmniAuth.config.request_validation_phase = OmniAuth::AuthenticityTokenProtection.new(key: :_csrf_token)
|
|
22
|
+
```
|
|
23
|
+
2. For more info, see: https://github.com/cookpad/omniauth-rails_csrf_protection?tab=readme-ov-file#omniauth---rails-csrf-protection
|
|
24
|
+
7. This gem offers two Omniauth providers:
|
|
25
|
+
- `:columbia_cas` - For logging in with a Columbia UNI
|
|
26
|
+
- `:developer_uid` - For logging in as a user with a specific uid (IMPORTANT: only enable this in a development environment!)
|
|
27
|
+
|
|
28
|
+
To enable one or both of these providers, edit `/config/initializers/devise.rb` and add one or both of these lines:
|
|
20
29
|
```
|
|
21
|
-
config.omniauth :
|
|
30
|
+
config.omniauth :columbia_cas, { label: 'Columbia SSO (CAS)' }
|
|
31
|
+
config.omniauth :developer_uid, { label: 'Developer UID' } if Rails.env.development?
|
|
22
32
|
```
|
|
23
|
-
(
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
-
|
|
27
|
-
|
|
33
|
+
(NOTE: You may already have other config.omniauth entries in your devise.rb file. If so, you can append the lines above to that section.)
|
|
34
|
+
8. Add a :uid column to the User model by running: `rails generate migration AddUidToUsers uid:string:uniq:index`
|
|
35
|
+
9. In `/app/models/user.rb`, find the line where the `devise` method is called.
|
|
36
|
+
- It might look something like this:
|
|
37
|
+
```
|
|
38
|
+
devise :database_authenticatable, :validatable
|
|
39
|
+
```
|
|
40
|
+
- Minimally, you need to add these additional arguments to the end of the method call: `:omniauthable, omniauth_providers: Devise.omniauth_configs.keys`, so the updated code might look like this:
|
|
41
|
+
```
|
|
42
|
+
devise :database_authenticatable, :validatable, :omniauthable, omniauth_providers: Devise.omniauth_configs.keys
|
|
43
|
+
```
|
|
44
|
+
This is just an example though! You might not need the `:database_authenticatable` and `:validatable` modules for your app. See the [Devise documentation](https://github.com/heartcombo/devise) for more information about available modules and what they do.
|
|
45
|
+
|
|
46
|
+
It's worth mentioning here that if you use plan to use omniauth-cul gem for CAS authentication, you might not actually want to support password authentication in your app anymore. If that's the case, you can remove the `:database_authenticatable` module (which enforces the presence of an `encrypted_password` field on your User model) and you can also remove the `:validatable` model (which, among other things, validates the presence of a password field when a new User is created).
|
|
47
|
+
|
|
48
|
+
- The simplest version of your devise configuration could look like this:
|
|
28
49
|
```
|
|
29
|
-
devise :
|
|
50
|
+
devise :omniauthable, omniauth_providers: Devise.omniauth_configs.keys
|
|
30
51
|
```
|
|
31
|
-
|
|
52
|
+
Why does `:omniauth_providers` configuration has a value of `Devise.omniauth_configs.keys`? This serves the purpose of automatically referencing any config.omniauth providers that you previously enabled in `devise.rb`. For example, if you enabled `:columbia_cas` and `:developer_uid` providers in `devise.rb`, then `Devise.omniauth_configs.keys` would return `[:columbia_cas, :developer_uid]`.
|
|
53
|
+
10. In `/config/routes.rb`, find this line:
|
|
32
54
|
```
|
|
33
55
|
devise_for :users
|
|
34
56
|
```
|
|
35
|
-
And replace it with
|
|
57
|
+
And replace it with this:
|
|
36
58
|
```
|
|
37
59
|
devise_for :users, controllers: { omniauth_callbacks: 'users/omniauth_callbacks' }
|
|
38
60
|
```
|
|
39
|
-
|
|
61
|
+
11. Create a new file at `app/controllers/users/omniauth_callbacks_controller.rb` with the following content (and then customize it based on your needs):
|
|
40
62
|
```
|
|
41
63
|
require 'omniauth/cul'
|
|
42
64
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
65
|
+
class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
|
|
66
|
+
# See https://github.com/omniauth/omniauth/wiki/FAQ#rails-session-is-clobbered-after-callback-on-developer-strategy
|
|
67
|
+
# The CAS login redirect to the columbia_cas callback endpoint AND the developer form submission to the
|
|
68
|
+
# developer_uid callback do not send authenticity tokens, so we'll skip token verification for these actions.
|
|
69
|
+
skip_before_action :verify_authenticity_token, only: [:columbia_cas, :developer_uid]
|
|
70
|
+
|
|
71
|
+
# POST /users/auth/developer_uid/callback
|
|
72
|
+
def developer_uid
|
|
73
|
+
return unless Rails.env.development? # Only allow this action to run in the development environment
|
|
74
|
+
uid = params[:uid]
|
|
75
|
+
user = User.find_by(uid: uid)
|
|
76
|
+
|
|
77
|
+
if !user
|
|
78
|
+
flash[:alert] = "Login attempt failed. User #{uid} does not have an account."
|
|
79
|
+
redirect_to root_path
|
|
80
|
+
return
|
|
51
81
|
end
|
|
52
82
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
redirect_to Omniauth::Cul::Cas3.passthru_redirect_url(app_cas_callback_endpoint), allow_other_host: true
|
|
56
|
-
end
|
|
83
|
+
sign_in_and_redirect user, event: :authentication # this will throw if user is not activated
|
|
84
|
+
end
|
|
57
85
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
86
|
+
# POST /users/auth/columbia_cas/callback
|
|
87
|
+
def columbia_cas
|
|
88
|
+
callback_url = user_columbia_cas_omniauth_callback_url # The columbia_cas callback route in this application
|
|
89
|
+
uid, _affils = Omniauth::Cul::ColumbiaCas.validation_callback(request.params['ticket'], callback_url)
|
|
90
|
+
|
|
91
|
+
# Custom auth logic for your app goes here.
|
|
92
|
+
# The code below is only provided as an example. If you want to use Omniauth::Cul::PermissionFileValidator,
|
|
93
|
+
# to validate see the later "Omniauth::Cul::PermissionFileValidator" section of this README.
|
|
94
|
+
#
|
|
95
|
+
# if Omniauth::Cul::PermissionFileValidator.permitted?(uid, _affils)
|
|
96
|
+
# user = User.find_by(uid: uid) || User.create!(
|
|
97
|
+
# uid: uid,
|
|
98
|
+
# email: "#{uid}@columbia.edu",
|
|
99
|
+
# # Only keep the line below if you're using the :database_authenticatable Devise module.
|
|
100
|
+
# # Omniauth login doesn't use a password (so the password value doesn't matter to Omniauth),
|
|
101
|
+
# # but your app's setup might require a password to be assigned to new users.
|
|
102
|
+
# password: Devise.friendly_token[0, 20]
|
|
103
|
+
# )
|
|
104
|
+
# sign_in_and_redirect user, event: :authentication # this will throw if user is not activated
|
|
105
|
+
# else
|
|
106
|
+
# flash[:alert] = 'Login attempt failed'
|
|
107
|
+
# redirect_to root_path
|
|
108
|
+
# end
|
|
109
|
+
rescue Omniauth::Cul::Exceptions::Error => e
|
|
110
|
+
# If an unexpected CAS ticket validation occurs, log the error message and ask the user to try
|
|
111
|
+
# logging in again. Do not display the exception object's original message to the user because it may
|
|
112
|
+
# contain information that only a developer should see.
|
|
113
|
+
error_message = 'CAS login validation failed. Please try again.'
|
|
114
|
+
Rails.logger.debug(error_message + " #{e.class.name}: #{e.message}")
|
|
115
|
+
flash[:alert] = error_message
|
|
116
|
+
redirect_to root_path
|
|
77
117
|
end
|
|
118
|
+
end
|
|
78
119
|
```
|
|
120
|
+
12. The last thing to note is that you must POST to any /users/auth/:provider paths when your users log in via Omniauth. For security reasons in Omniauth 2.0 and later, use of GET is discouraged and will not work for the Omniauth strategies provided by this gem. In the past, if you used the Rails `link_to` method to generate links to `/users/auth/:provider`, you should instead use `button_to` because it will generate a `<form method="post">` tag that will perform a POST request to your `/users/auth/:provider` URLs. If you attempt a GET request, you'll most likely get an error message that says something like "Not found. Authentication passthru."
|
|
79
121
|
|
|
80
122
|
## Omniauth::Cul::PermissionFileValidator - Permission validation with a user id list or affiliation list
|
|
81
123
|
|
data/Rakefile
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require
|
|
4
|
-
require
|
|
3
|
+
require 'bundler/gem_tasks'
|
|
4
|
+
require 'rspec/core/rake_task'
|
|
5
5
|
|
|
6
6
|
RSpec::Core::RakeTask.new(:spec)
|
|
7
7
|
|
|
8
|
-
require
|
|
8
|
+
require 'rubocop/rake_task'
|
|
9
9
|
|
|
10
10
|
RuboCop::RakeTask.new
|
|
11
11
|
|
|
@@ -1,19 +1,17 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require 'nokogiri'
|
|
4
|
+
require 'net/http'
|
|
5
|
+
|
|
3
6
|
module Omniauth
|
|
4
7
|
module Cul
|
|
5
|
-
module
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
def self.passthru_redirect_url(app_cas_callback_endpoint)
|
|
9
|
-
'https://cas.columbia.edu/cas/login?'\
|
|
10
|
-
"service=#{Rack::Utils.escape(app_cas_callback_endpoint)}"
|
|
11
|
-
end
|
|
12
|
-
|
|
8
|
+
# This module is built around the Columbia University CAS 3 endpoint.
|
|
9
|
+
# For more information about this endpoint, see: https://www.cuit.columbia.edu/cas-authentication
|
|
10
|
+
module ColumbiaCas
|
|
13
11
|
def self.validation_callback(ticket, app_cas_callback_endpoint)
|
|
14
12
|
cas_ticket = ticket
|
|
15
13
|
validation_url = cas_validation_url(app_cas_callback_endpoint, cas_ticket)
|
|
16
|
-
validation_response =
|
|
14
|
+
validation_response = validate(validation_url)
|
|
17
15
|
|
|
18
16
|
# We are always expecting an XML response
|
|
19
17
|
response_xml = Nokogiri::XML(validation_response)
|
|
@@ -21,6 +19,12 @@ module Omniauth
|
|
|
21
19
|
user_id = user_id_from_response_xml(response_xml)
|
|
22
20
|
affils = affils_from_response_xml(response_xml)
|
|
23
21
|
|
|
22
|
+
if user_id.nil?
|
|
23
|
+
Rails.logger.error("Cas3 validation failed with validation response:\n#{response_xml}") if defined?(Rails)
|
|
24
|
+
raise Omniauth::Cul::Exceptions::CasTicketValidationError,
|
|
25
|
+
'Invalid CAS ticket'
|
|
26
|
+
end
|
|
27
|
+
|
|
24
28
|
[user_id, affils]
|
|
25
29
|
end
|
|
26
30
|
|
|
@@ -30,7 +34,7 @@ module Omniauth
|
|
|
30
34
|
"ticket=#{cas_ticket}"
|
|
31
35
|
end
|
|
32
36
|
|
|
33
|
-
def self.
|
|
37
|
+
def self.validate(validation_url)
|
|
34
38
|
uri = URI.parse(validation_url)
|
|
35
39
|
http = Net::HTTP.new(uri.host, uri.port)
|
|
36
40
|
http.use_ssl = true
|
|
@@ -41,10 +45,20 @@ module Omniauth
|
|
|
41
45
|
end
|
|
42
46
|
|
|
43
47
|
def self.user_id_from_response_xml(response_xml)
|
|
48
|
+
unless response_xml.is_a?(Nokogiri::XML::Document)
|
|
49
|
+
raise ArgumentError,
|
|
50
|
+
'response_xml must be a Nokogiri::XML::Document'
|
|
51
|
+
end
|
|
52
|
+
|
|
44
53
|
response_xml.xpath('/cas:serviceResponse/cas:authenticationSuccess/cas:user', 'cas' => 'http://www.yale.edu/tp/cas')&.first&.text
|
|
45
54
|
end
|
|
46
55
|
|
|
47
56
|
def self.affils_from_response_xml(response_xml)
|
|
57
|
+
unless response_xml.is_a?(Nokogiri::XML::Document)
|
|
58
|
+
raise ArgumentError,
|
|
59
|
+
'response_xml must be a Nokogiri::XML::Document'
|
|
60
|
+
end
|
|
61
|
+
|
|
48
62
|
response_xml.xpath('/cas:serviceResponse/cas:authenticationSuccess/cas:attributes/cas:affiliation', 'cas' => 'http://www.yale.edu/tp/cas')&.map(&:text)
|
|
49
63
|
end
|
|
50
64
|
end
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require 'yaml'
|
|
4
|
+
|
|
3
5
|
module Omniauth
|
|
4
6
|
module Cul
|
|
5
7
|
module PermissionFileValidator
|
|
@@ -7,12 +9,17 @@ module Omniauth
|
|
|
7
9
|
|
|
8
10
|
def self.permission_file_data
|
|
9
11
|
return @permission_file_data if @permission_file_data
|
|
12
|
+
|
|
10
13
|
@permission_file_data = {}
|
|
11
14
|
if defined?(Rails)
|
|
12
15
|
permission_file_path = Rails.root.join('config/permissions.yml')
|
|
13
16
|
# We'll use YAML loading logic similar to Rails 7, for older and newer psych gem compatibility
|
|
14
17
|
# https://github.com/rails/rails/blob/7-1-stable/activesupport/lib/active_support/encrypted_configuration.rb#L99
|
|
15
|
-
conf = YAML.respond_to?(:unsafe_load)
|
|
18
|
+
conf = if YAML.respond_to?(:unsafe_load)
|
|
19
|
+
YAML.unsafe_load_file(permission_file_path)
|
|
20
|
+
else
|
|
21
|
+
YAML.load_file(permission_file_path)
|
|
22
|
+
end
|
|
16
23
|
@permission_file_data = conf[Rails.env] || {}
|
|
17
24
|
end
|
|
18
25
|
|
|
@@ -32,8 +39,9 @@ module Omniauth
|
|
|
32
39
|
def self.permitted?(user_id, affils)
|
|
33
40
|
return false if user_id.nil?
|
|
34
41
|
return true if allowed_user_ids.include?(user_id)
|
|
35
|
-
return true if affils.respond_to?(:include?) && allowed_user_affils.
|
|
36
|
-
|
|
42
|
+
return true if affils.respond_to?(:include?) && (affils & allowed_user_affils).length.positive?
|
|
43
|
+
|
|
44
|
+
false
|
|
37
45
|
end
|
|
38
46
|
end
|
|
39
47
|
end
|
data/lib/omniauth/cul/version.rb
CHANGED
data/lib/omniauth/cul.rb
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require_relative 'cul/version'
|
|
4
|
-
|
|
4
|
+
|
|
5
5
|
require_relative 'cul/permission_file_validator'
|
|
6
|
-
require_relative 'cul/
|
|
6
|
+
require_relative 'cul/case_converter'
|
|
7
|
+
require_relative 'cul/exceptions'
|
|
8
|
+
require_relative 'cul/columbia_cas'
|
|
9
|
+
|
|
10
|
+
require_relative 'strategies/developer_uid'
|
|
11
|
+
require_relative 'strategies/columbia_cas'
|
|
7
12
|
|
|
8
13
|
module Omniauth
|
|
9
14
|
module Cul
|
|
10
|
-
class Error < StandardError; end
|
|
11
|
-
# Your code goes here...
|
|
12
15
|
end
|
|
13
16
|
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Omniauth
|
|
4
|
+
module Strategies
|
|
5
|
+
class ColumbiaCas
|
|
6
|
+
include OmniAuth::Strategy
|
|
7
|
+
|
|
8
|
+
# IMPORTANT NOTE: By default, any Omniauth strategy class that has a PascalCase name that would be converted to a
|
|
9
|
+
# downcased version (without underscores), which is not what we want. So we must override the name option to use
|
|
10
|
+
# proper snake_casing. This is unfortunate because it means that a strategy like MyStrategy will become
|
|
11
|
+
# :mystrategy by default, unless we set `option :name, :my_strategy`.
|
|
12
|
+
# You can see the original Omniauth implementation here:
|
|
13
|
+
# https://github.com/omniauth/omniauth/blob/v2.1.4/lib/omniauth/strategy.rb#L139
|
|
14
|
+
option :name, Omniauth::Cul::CaseConverter.to_snake_case(name.split('::').last).to_sym
|
|
15
|
+
|
|
16
|
+
def request_phase
|
|
17
|
+
redirect "https://cas.columbia.edu/cas/login?service=#{Rack::Utils.escape(callback_url)}"
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'omniauth'
|
|
4
|
+
|
|
5
|
+
module Omniauth
|
|
6
|
+
module Strategies
|
|
7
|
+
class DeveloperUid
|
|
8
|
+
include OmniAuth::Strategy
|
|
9
|
+
|
|
10
|
+
# IMPORTANT NOTE: By default, any Omniauth strategy class that has a PascalCase name that would be converted to a
|
|
11
|
+
# downcased version (without underscores), which is not what we want. So we must override the name option to use
|
|
12
|
+
# proper snake_casing. This is unfortunate because it means that a strategy like MyStrategy will become
|
|
13
|
+
# :mystrategy by default, unless we set `option :name, :my_strategy`.
|
|
14
|
+
# You can see the original Omniauth implementation here:
|
|
15
|
+
# https://github.com/omniauth/omniauth/blob/v2.1.4/lib/omniauth/strategy.rb#L139
|
|
16
|
+
option :name, Omniauth::Cul::CaseConverter.to_snake_case(name.split('::').last).to_sym
|
|
17
|
+
|
|
18
|
+
option :fields, [:uid]
|
|
19
|
+
option :uid_field, :uid
|
|
20
|
+
|
|
21
|
+
def request_phase # rubocop:disable Metrics/MethodLength
|
|
22
|
+
form = OmniAuth::Form.new(
|
|
23
|
+
title: 'Developer Sign-In',
|
|
24
|
+
url: callback_path,
|
|
25
|
+
header_info: <<~FOCUSSCRIPT
|
|
26
|
+
<script>
|
|
27
|
+
document.addEventListener("DOMContentLoaded", (event) => {
|
|
28
|
+
// Automatically focus on the uid input element when the page loads
|
|
29
|
+
document.getElementById('uid').focus();
|
|
30
|
+
});
|
|
31
|
+
</script>
|
|
32
|
+
FOCUSSCRIPT
|
|
33
|
+
)
|
|
34
|
+
form.text_field 'UID', 'uid'
|
|
35
|
+
form.button 'Sign In'
|
|
36
|
+
form.to_response
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative 'lib/omniauth/cul/version'
|
|
4
|
+
|
|
5
|
+
Gem::Specification.new do |spec|
|
|
6
|
+
spec.name = 'omniauth-cul'
|
|
7
|
+
spec.version = Omniauth::Cul::VERSION
|
|
8
|
+
spec.authors = ['Eric O']
|
|
9
|
+
spec.email = ['elo2112@columbia.edu']
|
|
10
|
+
|
|
11
|
+
spec.summary = 'A devise omniauth adapter for Rails apps, using Columbia University authentication.'
|
|
12
|
+
spec.homepage = 'https://github.com/cul/omniauth-cul'
|
|
13
|
+
spec.license = 'MIT'
|
|
14
|
+
spec.required_ruby_version = '>= 3.1.0'
|
|
15
|
+
|
|
16
|
+
# spec.metadata["allowed_push_host"] = "TODO: Set to your gem server 'https://example.com'"
|
|
17
|
+
|
|
18
|
+
spec.metadata['homepage_uri'] = spec.homepage
|
|
19
|
+
spec.metadata['source_code_uri'] = spec.homepage
|
|
20
|
+
|
|
21
|
+
# Specify which files should be added to the gem when it is released.
|
|
22
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
|
23
|
+
spec.files = Dir.chdir(__dir__) do
|
|
24
|
+
`git ls-files -z`.split("\x0").reject do |f|
|
|
25
|
+
(File.expand_path(f) == __FILE__) ||
|
|
26
|
+
f.start_with?(*%w[bin/ test/ spec/ features/ .git .circleci appveyor Gemfile])
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
spec.bindir = 'exe'
|
|
31
|
+
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
|
32
|
+
|
|
33
|
+
spec.require_paths = ['lib']
|
|
34
|
+
|
|
35
|
+
# Dependencies
|
|
36
|
+
spec.add_dependency 'devise', '>= 4.9'
|
|
37
|
+
spec.add_dependency 'omniauth', '>= 2.0'
|
|
38
|
+
|
|
39
|
+
# For more information and examples about making a new gem, check out our
|
|
40
|
+
# guide at: https://bundler.io/guides/creating_gem.html
|
|
41
|
+
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: omniauth-cul
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Eric O
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2026-01-16 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: devise
|
|
@@ -51,10 +51,14 @@ files:
|
|
|
51
51
|
- README.md
|
|
52
52
|
- Rakefile
|
|
53
53
|
- lib/omniauth/cul.rb
|
|
54
|
-
- lib/omniauth/cul/
|
|
54
|
+
- lib/omniauth/cul/case_converter.rb
|
|
55
|
+
- lib/omniauth/cul/columbia_cas.rb
|
|
56
|
+
- lib/omniauth/cul/exceptions.rb
|
|
55
57
|
- lib/omniauth/cul/permission_file_validator.rb
|
|
56
|
-
- lib/omniauth/cul/strategies/cas_3_strategy.rb
|
|
57
58
|
- lib/omniauth/cul/version.rb
|
|
59
|
+
- lib/omniauth/strategies/columbia_cas.rb
|
|
60
|
+
- lib/omniauth/strategies/developer_uid.rb
|
|
61
|
+
- omniauth-cul.gemspec
|
|
58
62
|
- sig/omniauth/cul.rbs
|
|
59
63
|
homepage: https://github.com/cul/omniauth-cul
|
|
60
64
|
licenses:
|
|
@@ -70,14 +74,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
70
74
|
requirements:
|
|
71
75
|
- - ">="
|
|
72
76
|
- !ruby/object:Gem::Version
|
|
73
|
-
version:
|
|
77
|
+
version: 3.1.0
|
|
74
78
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
75
79
|
requirements:
|
|
76
80
|
- - ">="
|
|
77
81
|
- !ruby/object:Gem::Version
|
|
78
82
|
version: '0'
|
|
79
83
|
requirements: []
|
|
80
|
-
rubygems_version: 3.
|
|
84
|
+
rubygems_version: 3.3.26
|
|
81
85
|
signing_key:
|
|
82
86
|
specification_version: 4
|
|
83
87
|
summary: A devise omniauth adapter for Rails apps, using Columbia University authentication.
|