<commit_before># Oa2c - OAuth2 Container

[![Build Status](https://secure.travis-ci.org/adie/oa2c.png)](http://travis-ci.org/adie/oa2c)

Rails OAuth2 provider engine to support embedded iframe applications from different sites. Just like games on Facebook.

Heavily depends on [rack-oauth2](https://github.com/nov/rack-oauth2) gem.

It's mostly extract from [rack-oauth2-sample](https://github.com/nov/rack-oauth2-sample).

Right now it supports only Mongoid 3 as ORM.

# Installation

First of all, add `gem 'oa2c'` to your Gemfile and bundle it.

Then add this to `config/application.rb`:

```ruby
config.middleware.use Oa2c::Middleware
```

And add this to your `config/routes.rb`:

```ruby
mount Oa2c::Engine => "/oauth"
```

And then you need to add this line to your user model:

```ruby
  include Oa2c::User
```

This will add `access_tokens` and `authorization_codes` associations.

# Configuration

To change some settings, e.g. user model, add an initializer `config/initializers/oa2c.rb`:

```ruby
Oa2c.setup do |config|
  config.user_model = "User"
  config.authentication_method = :authenticate_user!
  config.login_method = :sign_in
  config.current_user_method = :current_user
  config.find_for_user_password_authentication = proc {|username, password|
    user = Oa2c.user_model.constantize.where(email: username).first
    user if user.valid_password? password
  }
end
```

**Note**: these are defaults for Devise. You don't need to do anything if you use the same settings<commit_msg>Even more updates to README [ci skip]<commit_after># Oa2c - OAuth2 Container

[![Build Status](https://secure.travis-ci.org/adie/oa2c.png)](http://travis-ci.org/adie/oa2c)

Rails OAuth2 provider engine to support embedded iframe applications from different sites. Just like games on Facebook.

Heavily depends on [rack-oauth2](https://github.com/nov/rack-oauth2) gem.

It's mostly extract from [rack-oauth2-sample](https://github.com/nov/rack-oauth2-sample).

Right now it supports only Mongoid 3 as ORM.

# Installation

First of all, add `gem 'oa2c'` to your Gemfile and bundle it.

Then add this to `config/application.rb`:

```ruby
  config.middleware.use Oa2c::Middleware
```

And add this to your `config/routes.rb`:

```ruby
  mount Oa2c::Engine => "/oauth"
```

And then you need to add this line to your user model:

```ruby
  include Oa2c::User
```

This will add `access_tokens` and `authorization_codes` associations.

And finally add to your controllers that require OAuth2 authentictation:

```ruby
  include Oa2c::Authentication
```

# Configuration

To change some settings, e.g. user model, add an initializer `config/initializers/oa2c.rb`:

```ruby
Oa2c.setup do |config|
  config.user_model = "User"
  config.authentication_method = :authenticate_user!
  config.login_method = :sign_in
  config.current_user_method = :current_user
  config.find_user_for_password_authentication = proc {|username, password|
    user = Oa2c.user_model.constantize.where(email: username).first
    user if user.valid_password? password
  }
end
```

**Note**: these are defaults for Devise. You don't need to do anything if you use the same settings
{'fraction_non_alphanumeric': 0.11396825396825397, 'fraction_numerical': 0.011428571428571429, 'mean_word_length': 4.636851520572451, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3446936', 'n_tokens_mistral': 1084, 'n_tokens_neox': 1038, 'n_words': 316}