Project

curupira

0.0
No commit activity in last 3 years
No release in over 3 years
Easy way to authentication and authorization
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

>= 0
>= 5.1.0, ~> 5.1
 Project Readme

curupira

Easy way to authentication and authorization for ActiveRecord based on Sorcery. Curupira will help you quickly develop an application that uses authentication and authorization rules with database.

By PrĂ³diga Sistemas.

Build Status Code Climate Test Coverage

Getting started

Curupira works with rails 4.0 or onwards. Add curupira to your Gemfile:

gem 'curupira'

And run:

bundle install

Environment preparation

It's necessary to setup user and password on database.yml. Ex:

user: "postgres"
password: "postgres"

After this, run:

rake db:create

Rails Configuration

rails generate curupira:install

The generator will install an initializer which describes ALL of Sorcery's configuration options, models and migrations for authentication and authorization solution.

So, run migrations:

rake db:migrate

You have to add an admin user to application. Edit the seeds.rb file:

User.create(username: "user", name: "Default Admin User", email: "user@mail.com", password: "123456", admin: true)

Then run:

rake db:seed

Run the following task:

rake curupira:db:generate_features

Replace your en.yml file by curupira/spec/dummy/config/locales/en.yml

Root path

If you dont't have root path configurations on your applications, follow these step:

Add this line to routes.rb file:

root to: "home#index"

Create the home controller:

class HomeController < ApplicationController
  def index
  end
end

Create the index home page:

app/views/home/index.html.erb

Controller filters and helpers

Curupira will provide some helpers to use inside controllers and views. To setup controller with user authentication, just add this before_action:

before_action :require_login

Curupira will provide all features and Sorcery api.

To authorization, add filter authorize on ApplicationController.

before_action :authorize

Configuring views

Curupira will generate views to add users, roles, groups and features in database. You can customize it.

rails generate curupira:views

For default, the curupira views use coccon for nested forms.

Configuring controllers

If the customization at the views level is not enough, you can customize each controller:

rails generate curupira:controllers

Partials

You should add in application.html.erb partials for menu, and helper for display flash messages:

<%- flash.each do |name, msg| -%>
  <%= content_tag :div, msg, id: "flash_#{name}" %>
<%- end -%>

<%= render "curupira/shared/session_links" %>
<%= render "curupira/shared/model_links" %>
<%= yield %>
  • Add to your application.js
//= require jquery
//= require cocoon

Using curupira

Open http://localhost:3000/session/new and inform the same user configured on seed file.

License

Curupira is released under the MIT License.