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

Version 2.2.0 #28

Merged
merged 4 commits into from
Jul 9, 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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Change Log

## v2.2.0 (2024-07-09)

[Implements](https://github.com/RIPAGlobal/omniauth-azure-activedirectory-v2/pull/26) support for specifying `scope` via the authorisation URL, in addition to the prior support for static configuration or configuration via a custom provider class - thanks @nbgoodall!

## v2.1.0 (2023-09-16)

[Implements](https://github.com/RIPAGlobal/omniauth-azure-activedirectory-v2/pull/19) support for custom policies when using Microsoft Azure AD - thanks @stevenchanin!
Expand Down
19 changes: 16 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,15 @@ gem 'omniauth-azure-activedirectory-v2'

And then execute:

$ bundle install
```shell
$ bundle install
```

Or install it yourself as:

$ gem install omniauth-azure-activedirectory-v2

```shell
$ gem install omniauth-azure-activedirectory-v2
```


## Usage
Expand Down Expand Up @@ -162,6 +165,14 @@ In method `#authorize_params` above, the request object is used to look for a `l

> **NB:** Naming things is hard! The predecessor gem used the name `YouTenantProvider` since it was focused on custom tenant provision, but if using this in a more generic way, perhaps consider a more generic name such as, say, `CustomOmniAuthAzureProvider`.
#### Special case scope override

If required and more convenient, you can specify a custom `scope` value via generation of an authorisation URL including that required `scope`, rather than by using a custom provider class with `def scope...end` method. Include the `scope` value in your call to generate the URL thus:

```ruby
omniauth_authorize_url('resource_name_eg_user', 'azure_activedirectory_v2', scope: '...')
```



## Contributing
Expand All @@ -182,6 +193,8 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/RIPAGl
* Add tests and check that `bundle exec rspec` still runs successfully
* For new features (rather than bug fixes), update `README.md` with details



## License

The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
Expand Down
4 changes: 2 additions & 2 deletions lib/omniauth/azure_activedirectory_v2/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ module OmniAuth
module Azure
module Activedirectory
module V2
VERSION = "2.1.0"
DATE = "2023-09-16"
VERSION = "2.2.0"
DATE = "2024-07-09"
end
end
end
Expand Down
4 changes: 3 additions & 1 deletion lib/omniauth/strategies/azure_activedirectory_v2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ def client
options.authorize_params.prompt = request.params['prompt']
end

options.authorize_params.scope = if provider.respond_to?(:scope) && provider.scope
options.authorize_params.scope = if defined?(request) && request.params['scope']
request.params['scope']
elsif provider.respond_to?(:scope) && provider.scope
provider.scope
else
DEFAULT_SCOPE
Expand Down
6 changes: 6 additions & 0 deletions spec/omniauth/strategies/azure_activedirectory_v2_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,12 @@ def client_secret
it 'has correct token url' do
expect(subject.client.options[:token_url]).to eql('https://login.microsoftonline.com/common/oauth2/v2.0/token')
end

it 'has correct scope from request params' do
request.params['scope'] = 'openid email offline_access Calendars.Read'
subject.client
expect(subject.authorize_params[:scope]).to eql('openid email offline_access Calendars.Read')
end
end
end

Expand Down
Loading