Integration of CAS login and verification.
Decidim::CasClient will be available as a Feature for a Participatory Space.
Add these lines to your application's Gemfile:
gem 'decidim-cas_client, git: "https://github.com/Som-Energia/decidim-cas-client"'
gem 'codit-devise-cas-authenticable, git: "https://github.com/Som-Energia/codit-devise-cas-authenticable"'
And then execute:
bundle
bundle exec rails decidim_cas_client:install:migrations
For the correct use of this CAS client, there is a migration that modifies the database in these ways:
- Added
username
(STRING
) field - Added
extra_attributes
(JSONB
) field - Added index for
username
field - Modified index for
email
andorganization_id
to not be unique
IMPORTANT:
This module makes use of the Deface gem. In conjuntion with other modules (we know Term Customizer is one of them) it might cause errors when precompiling assets for production sites. But only if during this process the compiling machine does not have access to the database.
It is easy to overcome this problem. Just add the following line to your
config/environments/production.rb
file:config.deface.enabled = ENV['DB_ADAPTER'].blank? || ENV['DB_ADAPTER'] == 'postgresql'Then precompile with these ENV enabled in your CI:
DB_ADAPTER=nulldb RAILS_ENV=production rake assets:precompileAlternatively, use any other ENV var to set up the
config.deface.enabled
tofalse
during the precompilation phase.
Bug reports and pull requests are welcome on GitHub at https://github.com/Som-Energia/decidim-cas-client.
To start contributing to this project, first:
- Install the basic dependencies (such as Ruby and PostgreSQL)
- Clone this repository
Decidim's main repository also provides a Docker configuration file if you prefer to use Docker instead of installing the dependencies locally on your machine.
You can create the development app by running the following commands after cloning this project:
bundle
DATABASE_USERNAME=<username> DATABASE_PASSWORD=<password> bundle exec rake development_app
Note that the database user has to have rights to create and drop a database in order to create the dummy test app database.
Then to test how the module works in Decidim, start the development server:
DATABASE_USERNAME=<username> DATABASE_PASSWORD=<password> bin/rails s
Note that bin/rails
is a convenient wrapper around the command cd development_app; bundle exec rails
.
In case you are using rbenv and have the
rbenv-vars plugin installed for it, you
can add the environment variables to the root directory of the project in a file
named .rbenv-vars
. If these are defined for the environment, you can omit
defining these in the commands shown above.
As latests versions of Decidim, this repository uses Webpacker for Rails. This means that compilation of assets is required everytime a Javascript or CSS file is modified. Usually, this happens automatically, but in some cases (specially when actively changes that type of files) you want to speed up the process.
To do that, start in a separate terminal than the one with bin/rails s
, and BEFORE it, the following command:
bin/webpack-dev-server
Please follow the code styling defined by the different linters that ensure we are all talking with the same language collaborating on the same project. This project is set to follow the same rules that Decidim itself follows.
Rubocop linter is used for the Ruby language.
You can run the code styling checks by running the following commands from the console:
bundle exec rubocop
To ease up following the style guide, you should install the plugin to your favorite editor, such as:
- Sublime Text - Sublime RuboCop
- Visual Studio Code - Rubocop for Visual Studio Code
There are other linters for Javascript and CSS. These run using NPM packages. You can run the following commands:
npm run lint
: Runs the linter for Javascript files.npm run lint-fix
: Automatically fix issues for Javascript files (if possible).npm run stylelint
: Runs the linter for SCSS files.npm run stylelint-fix
: Automatically fix issues for SCSS files (if possible).
To run the tests run the following in the gem development path:
bundle
DATABASE_USERNAME=<username> DATABASE_PASSWORD=<password> bundle exec rake test_app
DATABASE_USERNAME=<username> DATABASE_PASSWORD=<password> bundle exec rspec
Note that the database user has to have rights to create and drop a database in order to create the dummy test app database.
In case you are using rbenv and have the
rbenv-vars plugin installed for it, you
can add these environment variables to the root directory of the project in a
file named .rbenv-vars
. In this case, you can omit defining these in the
commands shown above.
Running tests automatically generates a code coverage report. To generate the complete report run all the tests using this command:
bundle exec rspec
This will generate a folder named coverage
in the project root which contains
the code coverage report.
If you would like to see this module in your own language, you can help with its translation at Crowdin:
https://crowdin.com/project/decidim-cas_client
See LICENSE-AGPLv3.txt.