No commit activity in last 3 years
No release in over 3 years
Setup your Rails application with one or multiple clients for Azure AD Graph API using OAuth2 service-to-service calls.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
 Dependencies

Development

~> 1.7
~> 4.2
~> 10.0
~> 0.8

Runtime

~> 1.0
 Project Readme

Azure Active Directory Graph API

Description

Simple Azure Active Directory Graph API wrapper for Ruby on Rails.

The API authentication protocol is a service to service call using OAuth2 client credentials. For more information go to Azure Documentation.

This library is in alpha. Future incompatible changes may be necessary.

Install

Add the gem to the Gemfile

gem 'azure-directory'

Configuration

First configure your API client in config/initializers/azure_directory.rb

Azure::Directory.configure do
	
	# OPTIONAL. Use a YAML file to store the requested access tokens. When the token is refreshed, this file will be updated.
	use_yaml Rails.root.join('config', 'google_directory.yaml')

	# Required attributes
	client_id       ''
	client_secret   ''
	tenant_id       ''
	resource_id     ''

end

Multiple API clients using scopes

Specify a single or multiple scopes in the configuration file.

Azure::Directory.configure do
	
	scope :domain_one do
		client_id       ''
		client_secret   ''
		# [...]
	end

	scope :domain_two do
		client_id       ''
		client_secret   ''
		# [...]
	end

end

Usage

azure = Azure::Directory::Client.new

azure.find_users

azure.find_user_groups_by_email("email")

azure.create_user("email", "given_name", "family_name", "password")

azure.update_user("email", update_data)

azure.update_user_password("email", "new_password")

Multiple Scopes

domain_one = Azure::Directory::Client.new(:domain_one)
domain_one.find_users

domain_two = Azure::Directory::Client.new(:domain_two)
domain_two.find_users

TO DO

  • use_active_model for database token store
  • Build the configuration generator
  • Implement the Azure's REST API calls
  • Abstract the API's Entities into ruby models Entity Reference
  • Better error handling
  • Testing