-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3643fc0
commit aa71118
Showing
17 changed files
with
436 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
# Admin Variables | ||
ADMIN_USERNAME=test | ||
ADMIN_PASSWORD=password | ||
# Admin Variables | ||
ADMIN_USERNAME=test | ||
ADMIN_PASSWORD=password | ||
|
||
# Mail Variables | ||
MAIL_SENDER=[email protected] | ||
|
@@ -15,6 +15,6 @@ | |
TREATMENT_DATABASE_TIMEOUT=5000 | ||
TREATMENT_DATABASE_USERNAME= | ||
|
||
Mailer settings | ||
# Mailer settings | ||
TREATMENT_PRODUCTION_MAILER_FROM=[email protected] | ||
TREATMENT_PRODUCTION_MAILER_URL=localhost |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# frozen_string_literal: true | ||
|
||
class CallbacksController < ApplicationController | ||
# Authenticate user not yet defined | ||
# skip_before_action :authenticate_user!, only: [:shibboleth] | ||
|
||
def shibboleth | ||
# This is a placeholder for the Shibboleth callback. | ||
render plain: 'Shibboleth callback received' | ||
|
||
# Possible implementation of Shibboleth callback: | ||
# shib_attributes = request.env['Shib-Attributes'] | ||
# email = shib_attributes[:email] | ||
# username = shib_attributes[:username] | ||
# | ||
# user = User.find(email: email) do |user| | ||
# user.username = username | ||
# # Assign other user attributes as needed | ||
# end | ||
# | ||
# session[:user_id] = user.id | ||
# redirect_to root_path | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# frozen_string_literal: true | ||
|
||
module Middleware | ||
class Shibboleth | ||
def initialize(app) | ||
@app = app | ||
end | ||
|
||
def call(env) | ||
request = Rack::Request.new(env) | ||
|
||
# Extract Shibboleth attributes from the request environment | ||
shib_attributes = { | ||
email: request.env['mail'], | ||
username: request.env['uid'], | ||
first_name: request.env['givenName'], | ||
last_name: request.env['sn'] | ||
} | ||
|
||
# Store Shibboleth attributes in the environment | ||
env['Shib-Attributes'] = shib_attributes | ||
|
||
@app.call(env) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'rails_helper' | ||
|
||
RSpec.describe CallbacksController, type: :controller do | ||
describe 'GET #shibboleth' do | ||
it 'returns a plain text response' do | ||
get :shibboleth | ||
expect(response).to have_http_status(:ok) | ||
expect(response.body).to eq('Shibboleth callback received') | ||
end | ||
end | ||
end | ||
|
||
# 4/30 copied directly from ucrate controller spec for our own transition to Shibboleth. | ||
# We will need to modify these tests to fit our own application. | ||
# Callbacks are functions that handle the response from an external service such as Shibboleth. | ||
|
||
# Skipping this because we don't have a CallbacksController. | ||
|
||
# describe CallbacksController do | ||
# describe 'omniauth-shibboleth' do | ||
# let(:uid) { '[email protected]' } | ||
# let(:provider) { :shibboleth } | ||
# | ||
# before do | ||
# @request.env['devise.mapping'] = Devise.mappings[:user] | ||
# omniauth_hash = { provider: 'shibboleth', | ||
# uid:, | ||
# extra: { | ||
# raw_info: { | ||
# mail: uid, | ||
# title: 'title', | ||
# telephoneNumber: '123-456-7890', | ||
# givenName: 'Fake', | ||
# sn: 'User', | ||
# uceduPrimaryAffiliation: 'staff', | ||
# ou: 'department' | ||
# } | ||
# } } | ||
# OmniAuth.config.add_mock(provider, omniauth_hash) | ||
# request.env['omniauth.auth'] = OmniAuth.config.mock_auth[provider] | ||
# end | ||
# | ||
# context 'with a user who is already logged in' do | ||
# let(:user) { FactoryBot.create(:user) } | ||
# | ||
# before do | ||
# controller.stub(:current_user).and_return(user) | ||
# end | ||
# it 'redirects to the dashboard' do | ||
# get provider | ||
# expect(response).to redirect_to(Hyrax::Engine.routes.url_helpers.dashboard_path) | ||
# end | ||
# end | ||
# | ||
# shared_examples 'Shibboleth login' do | ||
# it 'assigns the user and redirects' do | ||
# get provider | ||
# expect(flash[:notice]).to match(/You are now signed in as */) | ||
# expect(assigns(:user).email).to eq(email) | ||
# expect(assigns(:user).uid).to eq(request.env['omniauth.auth']['uid']) | ||
# expect(response).to be_redirect | ||
# end | ||
# end | ||
# | ||
# it_behaves_like 'Shibboleth login' | ||
# | ||
# it 'updates the shibboleth attributes' do | ||
# get provider | ||
# expect(assigns(:user).mail).to eq(request.env['omniauth.auth']['extra']['raw_info']['email']) | ||
# end | ||
# end | ||
# | ||
# context 'with a registered user who has previously logged in' do | ||
# let!(:user) { FactoryBot.create(:shibboleth_user, count: 1, profile_update_not_required: false) } | ||
# let(:email) { user.email } | ||
# | ||
# it_behaves_like 'Shibboleth login' | ||
# end | ||
# | ||
# context 'with a registered user who has never logged in' do | ||
# let!(:user) { FactoryBot.create(:shibboleth_user, count: 0, profile_update_not_required: false) } | ||
# let(:email) { user.email } | ||
# | ||
# it_behaves_like 'Shibboleth login' | ||
# | ||
# it 'updates the shibboleth attributes' do | ||
# get provider | ||
# expect(assigns(:user).mail).to eq(request.env['omniauth.auth']['extra']['raw_info']['email']) | ||
# end | ||
# end | ||
# end |
Oops, something went wrong.