Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

decidim-odoo

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

decidim-odoo

  • 0.2.2
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

Decidim::Odoo

Gem Version [CI] Lint [CI] Test Maintainability codecov

A Decidim module to sync Odoo users who connect to the platform using Keycloak OpenID OAuth.

This module allows the user to sign up in Decidim using the Odoo data. The process is described below:

Sequence Diagram

When a user logs in to the system using Odoo Keycloak OAuth, the information of the user provided by the Odoo API is stored in a model.

With this information, we can check if the user is a member or not depending on the values of the properties member and coop_candidate. If any of them is true, we will determine whether the user is a member. Taking this into account, every time we update the Odoo information of the user, we check this condition to create an authorization: odoo_member or delete it if the user is no longer a member.

The Odoo information of a user is updated automatically the first time the user signs up in the system via OAuth, but it can be manually updated as described below:

  • By an admin in the /admin/odoo/members route syncing a single user or all the users in the system
  • Using the rake task: decidim:odoo:sync:members. It will update all the users from all the organizations, so we recommend using it when the traffic in the platform is low. You can easily schedule it using whenever adding the lines:
every :day, at: "2:00am" do
  rake "decidim:odoo:sync:members"
end

Installation

Add this line to your application's Gemfile:

gem "decidim-odoo", "~> 0.2.0"

And then execute:

bundle

Install (and run) migrations:

bundle exec rails decidim_odoo:install:migrations
bundle exec rails db:migrate

Depending on your Decidim version, choose the corresponding version to ensure compatibility:

VersionCompatible decidim versions
0.2.xv0.27.x
0.1.xv0.25.x, v0.26.x

Configuration

In order to make the Odoo OAuth method with Keycloak available you need to add to your config/secrets.yml the entry below:

  omniauth:
    odoo_keycloak:
      enabled: true
      icon_path: media/images/odoo_logo.svg

The rest of the configuration can be done with an initializer file as the ones in this directory or with environment variables:

ENVDescriptionExample
OMNIAUTH_ODOO_KEYCLOAK_CLIENT_IDThe Keycloak client IDyour-client-id
OMNIAUTH_ODOO_KEYCLOAK_CLIENT_SECRETThe Keycloak client secretyour-client-secret
OMNIAUTH_ODOO_KEYCLOAK_SITEThe Keycloak sitehttps://example.org/oauth
OMNIAUTH_ODOO_KEYCLOAK_REALMThe Keycloak realmexample-realm
OMNIAUTH_ODOO_KEYCLOAK_ICON_PATHOptional. The icon path for the "Sign in with Odoo" button. In order to replace the default one, you need to include it under app/packs/images directory and reference it here as media/images/your-icon.svgmedia/images/odoo_logo.svg
ODOO_API_BASE_URLThe base URL for the Odoo APIhttps://example.org/api
ODOO_API_API_KEYThe API key to authenticate with the APIyour-api-key

IMPORTANT: Remember to activate the verification method odoo_member in the Decidim /system admin page for your organization.

Contributing

See Decidim.

Developing

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:

$ cd development_app
$ DATABASE_USERNAME=<username> DATABASE_PASSWORD=<password> bundle exec rails s

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.

Code Styling

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:

Testing

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.

License

This engine is distributed under the GNU AFFERO GENERAL PUBLIC LICENSE.

FAQs

Package last updated on 28 May 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc