Skip to content
This repository has been archived by the owner on Sep 29, 2021. It is now read-only.

Commit

Permalink
Switch from cru_lib to cru-auth-lib.
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian Zoetewey committed May 2, 2017
1 parent d73131d commit 66e7faa
Show file tree
Hide file tree
Showing 13 changed files with 22 additions and 35 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ gem 'oj_mimic_json'
# rubyCAS
gem 'rubycas-client-rails'

gem 'cru_lib', git: 'https://github.com/CruGlobal/cru_lib.git'
gem 'cru-auth-lib', '~> 0.1.0'

gem 'xml-simple', require: 'xmlsimple'

Expand Down
25 changes: 6 additions & 19 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,6 @@ GIT
activemodel (>= 4.0)
railties (>= 4.0)

GIT
remote: https://github.com/CruGlobal/cru_lib.git
revision: 8da4a0abb7195c0ad4e23aaf26e55ead312c441a
specs:
cru_lib (0.0.6)
active_model_serializers
global_registry
redis

GEM
remote: https://rubygems.org/
specs:
Expand Down Expand Up @@ -72,6 +63,9 @@ GEM
tins (~> 1.6.0)
crack (0.4.3)
safe_yaml (~> 1.0.0)
cru-auth-lib (0.1.0)
active_model_serializers (>= 0.10.0.rc1)
redis (~> 3.3)
diff-lcs (1.2.5)
docile (1.1.5)
dotenv (2.0.2)
Expand All @@ -88,12 +82,6 @@ GEM
redis (~> 3.0)
ffi (1.9.10)
formatador (0.2.5)
global_registry (1.0.8)
activesupport
oj (~> 2.13.0)
oj_mimic_json
rest-client (~> 1.6.7)
retryable-rb (~> 1.1.0)
globalid (0.3.6)
activesupport (>= 4.1.0)
guard (2.13.0)
Expand Down Expand Up @@ -187,10 +175,9 @@ GEM
rb-fsevent (0.9.7)
rb-inotify (0.9.5)
ffi (>= 0.5.0)
redis (3.2.2)
redis (3.3.3)
rest-client (1.6.9)
mime-types (~> 1.16)
retryable-rb (1.1.0)
rollbar (2.7.1)
multi_json
rspec (3.4.0)
Expand Down Expand Up @@ -274,7 +261,7 @@ DEPENDENCIES
active_model_serializers!
awesome_print
coveralls
cru_lib!
cru-auth-lib (~> 0.1.0)
dotenv-rails
factory_girl_rails
fakeredis
Expand All @@ -301,4 +288,4 @@ DEPENDENCIES
xml-simple

BUNDLED WITH
1.10.6
1.14.6
2 changes: 1 addition & 1 deletion app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def redis_pgt_iou_key(pgt_iou)

def render_error(message, options = {})
render(
json: CruLib::ApiError.new(message: message),
json: CruAuthLib::ApiError.new(message: message),
status: options[:status] || :bad_request # 400
)
end
Expand Down
6 changes: 3 additions & 3 deletions app/controllers/cas_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def logout
end

def proxy_callback
CruLib.redis_client.setex(
CruAuthLib.redis_client.setex(
redis_pgt_iou_key(params[:pgtIou]), 30, params[:pgtId]
) unless params[:pgtId].blank? || params[:pgtIou].blank?
render status: :ok, plain: 'OK'
Expand All @@ -28,7 +28,7 @@ def service_ticket
end

def invalidate_ticket(ticket)
token = CruLib.redis_client.del(redis_ticket_key(ticket))
CruLib::AccessToken.del(token) if token
token = CruAuthLib.redis_client.del(redis_ticket_key(ticket))
CruAuthLib::AccessToken.del(token) if token
end
end
10 changes: 5 additions & 5 deletions app/controllers/v1/tokens_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module V1
class TokensController < ApplicationController
include CruLib::AccessTokenProtectedConcern
include CruAuthLib::AccessTokenProtectedConcern

before_action :authenticate_request, except: [:new]

Expand All @@ -16,7 +16,7 @@ def new
end

def destroy
CruLib::AccessToken.del(@access_token.token)
CruAuthLib::AccessToken.del(@access_token.token)
render status: :ok, plain: 'OK'
end

Expand All @@ -40,14 +40,14 @@ def generate_access_token(st)
map.each do |k, v|
attributes[k] = st.extra_attributes[v] if st.extra_attributes.key?(v)
end
attributes[:pgt] = CruLib.redis_client.get(redis_pgt_iou_key(st.pgt_iou))
CruLib::AccessToken.new(attributes)
attributes[:pgt] = CruAuthLib.redis_client.get(redis_pgt_iou_key(st.pgt_iou))
CruAuthLib::AccessToken.new(attributes)
end

# Stores a Service Ticket to Access Token relationship
# This is used to invalidate access tokens when CAS session expires
def store_service_ticket(ticket, token)
CruLib.redis_client.setex(redis_ticket_key(ticket), 2.hours.to_i, token.token)
CruAuthLib.redis_client.setex(redis_ticket_key(ticket), 2.hours.to_i, token.token)
end
end
end
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
require 'cru_lib'
require 'cru_auth_lib'

CruLib.configure do |config|
CruAuthLib.configure do |config|
config.redis_host = ENV.fetch('REDIS_PORT_6379_TCP_ADDR')
end
2 changes: 1 addition & 1 deletion spec/controllers/cas_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
get :proxy_callback, pgtIou: pgt_iou, pgtId: pgt_id
expect(response).to be_success
expect(response).to have_http_status(200)
expect(CruLib.redis_client.get(redis_key)).to eq(pgt_id)
expect(CruAuthLib.redis_client.get(redis_key)).to eq(pgt_id)
end
end

Expand Down
6 changes: 3 additions & 3 deletions spec/controllers/v1/tokens_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
stub_request(:any, "#{ENV['CAS_BASE_URL']}/proxyValidate")
.with(query: hash_including(ticket: service_ticket))
.to_return(status: 200, body: proxy_validate_response)
CruLib.redis_client.setex(redis_key, 30, pgt)
CruAuthLib.redis_client.setex(redis_key, 30, pgt)
get :new, st: service_ticket
expect(response).to be_success
expect(response).to have_http_status(200)
Expand Down Expand Up @@ -72,13 +72,13 @@
context '#destroy' do
it 'responds with an HTTP 200 and destroys the access_token' do
guid = '3719A628-9EFC-4D62-B019-0C7B8D066F55'
access_token = CruLib::AccessToken.new(key_guid: guid)
access_token = CruAuthLib::AccessToken.new(key_guid: guid)
token = access_token.attributes[:token]
request.env['HTTP_AUTHORIZATION'] = "Bearer #{token}"
delete :destroy
expect(response).to be_successful
expect(response).to have_http_status(200)
expect(CruLib::AccessToken.read(token)).to be_nil
expect(CruAuthLib::AccessToken.read(token)).to be_nil
end
end
end
Binary file added vendor/cache/cru-auth-lib-0.1.0.gem
Binary file not shown.
Binary file removed vendor/cache/global_registry-1.0.8.gem
Binary file not shown.
Binary file removed vendor/cache/redis-3.2.2.gem
Binary file not shown.
Binary file added vendor/cache/redis-3.3.3.gem
Binary file not shown.
Binary file removed vendor/cache/retryable-rb-1.1.0.gem
Binary file not shown.

0 comments on commit 66e7faa

Please sign in to comment.