UserManagement
Short description and motivation.
This gem provides generic functionality for EMRs user management to integrate with an LDAP server via the Single sign on Service (sss) just by plugging it into your application(s).
Usage
How to use my plugin.
The plugin needs to be mounted into your application and the api's it exposes will be available via the mounted point.
Installation
Add this line to your application's Gemfile:
gem 'user_management', :git => 'https://github.com/EGPAFMalawiHIS/emr_usermanagement_engine.git', :branch => 'main'
Add this line to your routes.rb file:
mount UserManagement::Engine, at: "/api/v1"
Create a file config/settings.yml and add the following structure:
secret_key: ""
duplicate_precision: 90
gateway_key: 'usermanagement'
sss_url: localhost:3001
-- Generate a key and put it on the secret_key value and update the other key as necessary use command 'rake secret'
Add the following code to your application_controller.rb
before_action :authorized_user
def authorized_user
token = request.headers[:Authorization]
response = JSON.parse(UserManagement::ApplicationController.authorized(token))
return render json: {status: 403, message: 'User not authorised or token expired'} if response['status'] == 403
return render json: {status: 401, message: 'Invalid username or password'} if response['status'] == 401
end
And then execute:
$ bundle i
In Rails.root of your application execute:
bin/rails user_management:install:migrations
bin/rails db:migrate
Contributing
Contribution directions go here.
License
The gem is available as open source under the terms of the MIT License.