Skip to content

Commit

Permalink
Add support for screen_hint=signup param (#103)
Browse files Browse the repository at this point in the history
* Add support for screen_hint=signup param

* Update codecov

* Update README

* Update existing specs to include screen_hint

Co-authored-by: David Patrick <[email protected]>
  • Loading branch information
bbean86 and davidpatrick authored Sep 22, 2020
1 parent 7f41561 commit fb70eac
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 10 deletions.
10 changes: 5 additions & 5 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ GEM
addressable (2.7.0)
public_suffix (>= 2.0.2, < 5.0)
ast (2.4.0)
codecov (0.1.16)
codecov (0.2.7)
colorize
json
simplecov
url
coderay (1.1.2)
colorize (0.8.1)
crack (0.4.3)
safe_yaml (~> 1.0.0)
daemons (1.3.1)
Expand Down Expand Up @@ -44,7 +45,7 @@ GEM
hashdiff (1.0.1)
hashie (4.1.0)
jaro_winkler (1.5.4)
json (2.3.0)
json (2.3.1)
jwt (2.2.1)
listen (3.1.5)
rb-fsevent (~> 0.9, >= 0.9.4)
Expand Down Expand Up @@ -119,7 +120,7 @@ GEM
shellany (0.0.1)
shotgun (0.9.2)
rack (>= 1.0)
simplecov (0.18.5)
simplecov (0.19.0)
docile (~> 1.1)
simplecov-html (~> 0.11)
simplecov-html (0.12.2)
Expand All @@ -135,7 +136,6 @@ GEM
thor (1.0.1)
tilt (2.0.10)
unicode-display_width (1.7.0)
url (0.3.2)
webmock (3.8.3)
addressable (>= 2.3.6)
crack (>= 0.3.2)
Expand Down
19 changes: 15 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# OmniAuth Auth0

An [OmniAuth](https://github.com/intridea/omniauth) strategy for authenticating with [Auth0](https://auth0.com). This strategy is based on the [OmniAuth OAuth2](https://github.com/omniauth/omniauth-oauth2) strategy.
An [OmniAuth](https://github.com/intridea/omniauth) strategy for authenticating with [Auth0](https://auth0.com). This strategy is based on the [OmniAuth OAuth2](https://github.com/omniauth/omniauth-oauth2) strategy.

> :warning: **Important security note:** This solution uses a 3rd party library with an unresolved [security issue(s)](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2015-9284). Please review the details of the vulnerability, including [Auth0](https://github.com/auth0/omniauth-auth0/issues/82 ) and other recommended [mitigations](https://github.com/omniauth/omniauth/wiki/Resolving-CVE-2015-9284), before implementing the solution.
Expand Down Expand Up @@ -46,7 +46,7 @@ Then install:
$ bundle install
```

See our [contributing guide](CONTRIBUTING.md) for information on local installation for development.
See our [contributing guide](CONTRIBUTING.md) for information on local installation for development.

## Getting Started

Expand All @@ -64,7 +64,7 @@ All of these tasks and more are covered in our [Ruby on Rails Quickstart](https:
To send additional parameters during login, you can specify them when you register the provider:

```ruby
provider
provider
:auth0,
ENV['AUTH0_CLIENT_ID'],
ENV['AUTH0_CLIENT_SECRET'],
Expand Down Expand Up @@ -122,6 +122,17 @@ The Auth0 strategy will provide the standard OmniAuth hash attributes:
}
```

### Query Parameter Options

In some scenarios, you may need to pass specific query parameters to `/authorize`. The following parameters are available to enable this:

- `connection`
- `connection_scope`
- `prompt`
- `screen_hint` (only relevant to New Universal Login Experience)

Simply pass these query parameters to your OmniAuth redirect endpoint to enable their behavior.

## Contribution

We appreciate feedback and contribution to this repo! Before you get started, please see the following:
Expand All @@ -134,7 +145,7 @@ We appreciate feedback and contribution to this repo! Before you get started, pl

- Use [Community](https://community.auth0.com/) for usage, questions, specific cases.
- Use [Issues](https://github.com/auth0/omniauth-auth0/issues) here for code-level support and bug reports.
- Paid customers can use [Support](https://support.auth0.com/) to submit a trouble ticket for production-affecting issues.
- Paid customers can use [Support](https://support.auth0.com/) to submit a trouble ticket for production-affecting issues.

## Vulnerability Reporting

Expand Down
2 changes: 1 addition & 1 deletion lib/omniauth/strategies/auth0.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def client
def authorize_params
params = super
parsed_query = Rack::Utils.parse_query(request.query_string)
%w[connection connection_scope prompt].each do |key|
%w[connection connection_scope prompt screen_hint].each do |key|
params[key] = parsed_query[key] if parsed_query.key?(key)
end

Expand Down
18 changes: 18 additions & 0 deletions spec/omniauth/strategies/auth0_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@
expect(redirect_url).to have_query('redirect_uri')
expect(redirect_url).not_to have_query('auth0Client')
expect(redirect_url).not_to have_query('connection')
expect(redirect_url).not_to have_query('connection_scope')
expect(redirect_url).not_to have_query('prompt')
expect(redirect_url).not_to have_query('screen_hint')
end

it 'redirects to hosted login page' do
Expand All @@ -97,7 +99,9 @@
expect(redirect_url).to have_query('redirect_uri')
expect(redirect_url).to have_query('connection', 'abcd')
expect(redirect_url).not_to have_query('auth0Client')
expect(redirect_url).not_to have_query('connection_scope')
expect(redirect_url).not_to have_query('prompt')
expect(redirect_url).not_to have_query('screen_hint')
end

it 'redirects to the hosted login page with connection_scope' do
Expand All @@ -123,6 +127,20 @@
expect(redirect_url).not_to have_query('connection')
end

it 'redirects to hosted login page with screen_hint=signup' do
get 'auth/auth0?screen_hint=signup'
expect(last_response.status).to eq(302)
redirect_url = last_response.headers['Location']
expect(redirect_url).to start_with('https://samples.auth0.com/authorize')
expect(redirect_url).to have_query('response_type', 'code')
expect(redirect_url).to have_query('state')
expect(redirect_url).to have_query('client_id')
expect(redirect_url).to have_query('redirect_uri')
expect(redirect_url).to have_query('screen_hint', 'signup')
expect(redirect_url).not_to have_query('auth0Client')
expect(redirect_url).not_to have_query('connection')
end

describe 'callback' do
let(:access_token) { 'access token' }
let(:expires_in) { 2000 }
Expand Down

0 comments on commit fb70eac

Please sign in to comment.