Skip to content

Commit

Permalink
Merge pull request #15 from scientist-softserv/omniauth-cas
Browse files Browse the repository at this point in the history
OmniAuth CAS setup
  • Loading branch information
bkiahstroud authored Jul 25, 2024
2 parents 5fc4aaa + 2c2e504 commit ad4e76b
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 3 deletions.
1 change: 1 addition & 0 deletions api/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ gem "nokogiri", "~> 1.15.4"
gem "oauth2", "~> 1.3"
gem "oj", "~> 3.16"
gem "omniauth", "~> 2.0.0"
gem "omniauth-cas", git: "https://github.com/harvard-lts/omniauth-cas.git", branch: "harvard-main"
gem "omniauth-facebook", "~> 4.0.0"
gem "omniauth-google-oauth2", "~> 0.4"
gem "omniauth-twitter", "~> 1.4.0"
Expand Down
15 changes: 13 additions & 2 deletions api/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@ GIT
fast_jsonapi (1.6.0)
activesupport (>= 4.2)

GIT
remote: https://github.com/harvard-lts/omniauth-cas.git
revision: a61f71e9d9bdd0ba58c4302977b740a00d70a944
branch: harvard-main
specs:
omniauth-cas (2.0.1)
addressable (~> 2.8.5)
nokogiri (>= 1.15.5)
omniauth (>= 1.9, < 3)

GIT
remote: https://github.com/steveklabnik/metadown.git
revision: 34b79ad7e0bdf560ce13e384caa1626569397798
Expand Down Expand Up @@ -450,7 +460,7 @@ GEM
mime-types-data (3.2023.0808)
mini_magick (4.12.0)
mini_mime (1.1.5)
mini_portile2 (2.8.4)
mini_portile2 (2.8.7)
minitest (5.20.0)
money (6.16.0)
i18n (>= 0.6.4, <= 2)
Expand All @@ -475,7 +485,7 @@ GEM
net-protocol
net-ssh (5.2.0)
nio4r (2.5.9)
nokogiri (1.15.4)
nokogiri (1.15.6)
mini_portile2 (~> 2.8.2)
racc (~> 1.4)
oauth (1.1.0)
Expand Down Expand Up @@ -892,6 +902,7 @@ DEPENDENCIES
oauth2 (~> 1.3)
oj (~> 3.16)
omniauth (~> 2.0.0)
omniauth-cas!
omniauth-facebook (~> 4.0.0)
omniauth-google-oauth2 (~> 0.4)
omniauth-twitter (~> 1.4.0)
Expand Down
1 change: 1 addition & 0 deletions api/app/controllers/oauth_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ class OauthController < ApplicationController
skip_after_action :set_content_type

def authorize
Rails.logger.error("***** OmniAuth #{params.inspect} #{omniauth_hash.inspect}")
outcome = ExternalAuth::FindUser.run(
provider: params[:provider],
auth_hash: omniauth_hash
Expand Down
2 changes: 2 additions & 0 deletions api/config/initializers/omniauth.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
OmniAuth.config.allowed_request_methods = [:get, :post]

ManifoldEnv.oauth.configure do |config|
config.provider :facebook do |provider|
provider.strategy_options do |hsh|
Expand Down
6 changes: 5 additions & 1 deletion api/lib/middleware/omniauth_stack.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,11 @@ def build_middleware_stack
end

ManifoldEnv.oauth.enabled.each do |enabled_provider|
provider(*enabled_provider.provider_args)
if enabled_provider.provider_args[0] == :cas
provider :cas, host: enabled_provider.custom.host, url: enabled_provider.custom.site + "/cas"
else
provider(*enabled_provider.provider_args)
end
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export default function OAuthLoginOptions() {
return (
<Styled.Wrapper>
<OAuthMonitor />
<OAuthProviderButton provider="cas" icon="key32" />
<OAuthProviderButton provider="facebook" icon="socialFacebook32" />
<OAuthProviderButton provider="google" icon="socialEmail32" />
<OAuthProviderButton provider="twitter" icon="socialTwitter32" />
Expand Down

0 comments on commit ad4e76b

Please sign in to comment.