Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix revoke_session by including authorization headers #283

Merged
merged 2 commits into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion lib/workos/user_management.rb
Original file line number Diff line number Diff line change
Expand Up @@ -510,14 +510,17 @@ def get_logout_url(session_id:)
# @param [String] session_id The session ID can be found in the `sid`
# claim of the access token
def revoke_session(session_id:)
execute_request(
response = execute_request(
request: post_request(
path: '/user_management/sessions/revoke',
body: {
session_id: session_id,
},
auth: true,
),
)

response.is_a? Net::HTTPSuccess
end

# Get the JWKS URL
Expand Down
29 changes: 29 additions & 0 deletions spec/lib/workos/user_management_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1145,4 +1145,33 @@
end
end
end

describe '.revoke_session' do
context 'with valid payload' do
it 'revokes session' do
VCR.use_cassette 'user_management/revoke_session/valid' do
result = described_class.revoke_session(
session_id: 'session_01HRX85ATNADY1GQ053AHRFFN6',
)

expect(result).to be true
end
end
end

context 'with a non-existant session' do
it 'returns an error' do
VCR.use_cassette 'user_management/revoke_session/not_found' do
expect do
described_class.revoke_session(
session_id: 'session_01H5JQDV7R7ATEYZDEG0W5PRYS',
)
end.to raise_error(
WorkOS::APIError,
/Session not found/,
)
end
end
end
end
end

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.