From 907d21d6378d3b88f73cd20d6e83737757d7d035 Mon Sep 17 00:00:00 2001 From: Sarmad Sabih Date: Fri, 7 Aug 2020 13:21:12 +0500 Subject: [PATCH 1/2] Added ability to: Pass custom state to BambooId::Urls::AuthUrl --- lib/bamboo_id/urls/auth_url.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/bamboo_id/urls/auth_url.rb b/lib/bamboo_id/urls/auth_url.rb index 70c803f..7aab1c7 100644 --- a/lib/bamboo_id/urls/auth_url.rb +++ b/lib/bamboo_id/urls/auth_url.rb @@ -13,13 +13,14 @@ class AuthUrl include BambooUrl include BaseAuthUrl - def initialize(subdomain) + def initialize(subdomain, state = nil) self.subdomain = subdomain + self.state = state end private - attr_accessor :subdomain + attr_accessor :subdomain, :state def additional_params { @@ -44,7 +45,7 @@ def redirect_uri end def state_code - StateCode.new(subdomain).to_s + state || StateCode.new(subdomain).to_s end end end From 4db1e5e4a8874475e54b1237c32b68ebdd9b9cbc Mon Sep 17 00:00:00 2001 From: Sarmad Sabih Date: Mon, 10 Aug 2020 16:00:26 +0500 Subject: [PATCH 2/2] Version and readme.md update --- README.md | 11 +++++++++-- lib/bamboo_id/version.rb | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 34f7f2a..b1bfdab 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ Or install it yourself as: ### Configuration -`Bamboo::Configuration.redirect_url` must be set. +`BambooId::Configuration.redirect_url` must be set. The following environment variables are also required: - `BAMBOO_APPLICATION_KEY` @@ -33,13 +33,20 @@ The following environment variables are also required: To get the initial authorization URL, use `BambooId::Urls::AuthUrl.new(subdomain).to_s` +You can also pass an optional custom `state` attribute to this URL like this: + +```ruby +state = "my_custom_state" +BambooId::Urls::AuthUrl.new(subdomain, state).to_s +``` + In the callback controller, you can use `BambooId::ApiKeyFetcher` to get an API key using the code passed to you like so: ```ruby ::BambooId::ApiKeyFetcher.new( code: params[:code], - integration: current_company.user_management_integration + subdomain: subdomain, ).fetch ``` diff --git a/lib/bamboo_id/version.rb b/lib/bamboo_id/version.rb index dc7aa44..6551ac3 100644 --- a/lib/bamboo_id/version.rb +++ b/lib/bamboo_id/version.rb @@ -1,3 +1,3 @@ module BambooId - VERSION = "0.1.3" + VERSION = "0.1.4" end