<commit_before># Omniauth::Dsds

This gem contains the DSDS strategy for OmniAuth.

## Installation

Add this line to your application's Gemfile:

```ruby
gem "omniauth-dsds", github: "ministryofjustice/defence-request-service-omniauth-dsds", tag: "v0.3.0"
```

And then execute:

    $ bundle

## Usage

### Register provider

Tell OmniAuth about this provider. For a Rails app, your
`config/initializers/omniauth.rb` file should look like this:

```ruby
Rails.application.config.middleware.use OmniAuth::Builder do
  provider :defence_request, AUTH_KEY, AUTH_SECRET
end
```

Replace `AUTH_KEY` and `AUTH_SECRET` with appropriate values
from the authentication service provider.

You will need to set environment variables in order for the gem
to know where the authentication service resides, and where Omniauth
needs to redirect back to after authenticating. These should be set as
`ENV[AUTHENTICATION_SITE_URL]` and `ENV[AUTHENTICATION_REDIRECT_URI]`
respectively.

### Controller mix-ins

Include the module in any controller:
```ruby
include Omniauth::Dsds::ControllerMethods
```

This will give access to a `current_user` method, which returns a User
object representing the currently logged in user.

It also provides a Devise-like `authenticate_user!` method, which redirects
to the login workflow for the Authentication application.

## Contributing

1. Fork it (https://github.com/[my-github-username]/omniauth-dsds/fork)
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create a new Pull Request<commit_msg>update README with override options and role explaination<commit_after># Omniauth::Dsds

This gem contains the DSDS strategy for OmniAuth.

## Installation

Add this line to your application's Gemfile:

```ruby
gem "omniauth-dsds", github: "ministryofjustice/defence-request-service-omniauth-dsds", tag: "v0.3.0"
```

And then execute:

    $ bundle

## Usage

### Register provider

Tell OmniAuth about this provider. For a Rails app, your
`config/initializers/omniauth.rb` file should look like this:

```ruby
Rails.application.config.middleware.use OmniAuth::Builder do
  provider :defence_request, AUTH_KEY, AUTH_SECRET
end
```

Replace `AUTH_KEY` and `AUTH_SECRET` with appropriate values
from the authentication service provider.

You will need to set environment variables in order for the gem
to know where the authentication service resides, and where Omniauth
needs to redirect back to after authenticating. These should be set as
`ENV[AUTHENTICATION_SITE_URL]` and `ENV[AUTHENTICATION_REDIRECT_URI]`
respectively.

### Controller mix-ins

Include the module in any controller:
```ruby
include Omniauth::Dsds::ControllerMethods
```

This will give access to a `current_user` method, which returns a User
object representing the currently logged in user.

It also provides a Devise-like `authenticate_user!` method, which redirects
to the login workflow for the Authentication application.

If the User does not have any roles for the application (as returned by the profile API response) then the session will be cleared and the User redirected to the login page.

Override the authentication_application_id and authentication_application_secret methods to customize where OAuth credentials are loaded from.

## Contributing

1. Fork it (https://github.com/[my-github-username]/omniauth-dsds/fork)
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create a new Pull Request
{'fraction_non_alphanumeric': 0.08108843537414966, 'fraction_numerical': 0.004353741496598639, 'mean_word_length': 5.167785234899329, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4055661', 'n_tokens_mistral': 1093, 'n_tokens_neox': 1031, 'n_words': 438}