Skip to content
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
7 changes: 3 additions & 4 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ GEM
rainbow (3.1.1)
regexp_parser (2.10.0)
rexml (3.4.1)
strscan
rspec (3.9.0)
rspec-core (~> 3.9.0)
rspec-expectations (~> 3.9.0)
Expand All @@ -59,11 +58,11 @@ GEM
rubocop-ast (1.37.0)
parser (>= 3.3.1.0)
ruby-progressbar (1.13.0)
strscan (3.1.0)
unicode-display_width (3.1.4)
unicode-emoji (~> 4.0, >= 4.0.4)
unicode-emoji (4.0.4)
vcr (5.0.0)
vcr (6.3.1)
base64
webmock (3.23.0)
addressable (>= 2.8.0)
crack (>= 0.3.2)
Expand All @@ -76,7 +75,7 @@ DEPENDENCIES
bundler (>= 2.0.1)
rspec (~> 3.9.0)
rubocop (~> 1.71)
vcr (~> 5.0.0)
vcr (~> 6.0)
webmock
workos!

Expand Down
4 changes: 4 additions & 0 deletions lib/workos/user_management.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ def load_sealed_session(client_id:, session_data:, cookie_password:)
# that is preserved and available to the client in the response.
# @param [String] login_hint Can be used to pre-fill the username/email address
# field of the IdP sign-in page for the user, if you know their username ahead of time.
# @param [String] screen_hint Specify which AuthKit screen users should land on upon redirection
# (Only applicable when provider is 'authkit').
# @param [String] domain_hint Can be used to pre-fill the domain field when
# initiating authentication with Microsoft OAuth, or with a GoogleSAML connection type.
# @param [Array<String>] provider_scopes An array of additional OAuth scopes to request from the provider.
Expand All @@ -94,6 +96,7 @@ def authorization_url(
client_id: nil,
domain_hint: nil,
login_hint: nil,
screen_hint: nil,
provider: nil,
connection_id: nil,
organization_id: nil,
Expand All @@ -114,6 +117,7 @@ def authorization_url(
state: state,
domain_hint: domain_hint,
login_hint: login_hint,
screen_hint: screen_hint,
provider: provider,
connection_id: connection_id,
organization_id: organization_id,
Expand Down
35 changes: 35 additions & 0 deletions spec/lib/workos/user_management_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,41 @@
end
end

context 'with a screen hint' do
let(:args) do
{
provider: 'authkit',
screen_hint: 'sign_up',
client_id: 'workos-proj-123',
redirect_uri: 'foo.com/auth/callback',
state: {
next_page: '/dashboard/edit',
}.to_s,
}
end
it 'returns a valid URL' do
authorization_url = described_class.authorization_url(**args)

expect(URI.parse(authorization_url)).to be_a URI
end

it 'returns the expected hostname' do
authorization_url = described_class.authorization_url(**args)

expect(URI.parse(authorization_url).host).to eq(WorkOS.config.api_hostname)
end

it 'returns the expected query string' do
authorization_url = described_class.authorization_url(**args)

expect(URI.parse(authorization_url).query).to eq(
'client_id=workos-proj-123&redirect_uri=foo.com%2Fauth%2Fcallback' \
'&response_type=code&state=%7B%3Anext_page%3D%3E%22%2Fdashboard%2F' \
'edit%22%7D&screen_hint=sign_up&provider=authkit',
)
end
end

context 'with neither connection_id, organization_id or provider' do
let(:args) do
{
Expand Down
2 changes: 1 addition & 1 deletion workos.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Gem::Specification.new do |spec|
spec.add_development_dependency 'bundler', '>= 2.0.1'
spec.add_development_dependency 'rspec', '~> 3.9.0'
spec.add_development_dependency 'rubocop', '~> 1.71'
spec.add_development_dependency 'vcr', '~> 5.0.0'
spec.add_development_dependency 'vcr', '~> 6.0'
spec.add_development_dependency 'webmock'

spec.required_ruby_version = '>= 3.1'
Expand Down
Loading