Skip to content
Snippets Groups Projects
Unverified Commit bf738906 authored by Aboobacker MK's avatar Aboobacker MK Committed by Stan Hu
Browse files

Merge branch '432722-add-token-authorization-for-actioncable' into 'master'

parent 85c5e20c
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -3,13 +3,14 @@
module ApplicationCable
class Connection < ActionCable::Connection::Base
include Logging
include Gitlab::Auth::AuthFinders
 
identified_by :current_user
 
public :request
 
def connect
self.current_user = find_user_from_session_store
self.current_user = find_user_from_bearer_token || find_user_from_session_store
end
 
private
Loading
Loading
Loading
Loading
@@ -43,6 +43,16 @@
end
end
 
context 'when bearer header is provided' do
let(:user_pat) { create(:personal_access_token) }
it 'finds user by PAT' do
connect(ActionCable.server.config.mount_path, headers: { Authorization: "Bearer #{user_pat.token}" })
expect(connection.current_user).to eq(user_pat.user)
end
end
context 'when session cookie is not set' do
it 'sets current_user to nil' do
connect
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment