wm_okta_helper 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 07e5c43db022be49db574e0e2675796b4862d31c
4
- data.tar.gz: a8798501b5b694b2c5094e1c4e793a1c39ec26a6
3
+ metadata.gz: 6369d84a44dda8f3a16ccf5b232aa7a1446c45e5
4
+ data.tar.gz: de9f5bf350ced727a9d9a6604febe31d0ba9add3
5
5
  SHA512:
6
- metadata.gz: 313111f82b27a058c10ce84c10d887f40a3479cf49d9ff042715084c7b530f28db6bb83c4c4acf76c65630eea12e87defab4a165841c22f4fe121f11c8fd4c85
7
- data.tar.gz: db4f1aa9ff8d6c7e0b3c4aa0dc9f4f4f0295499aa71e04f8e67a807c1031347d7edfc5506ab9b618aa41fe24ce721d824a144c192b67f90fed798d8ca5c15661
6
+ metadata.gz: 00d9db751bccdb0241708e83c46f5e3e8863336032fc60faae229963328b6e5383433cd0fd141d3e7b88da0b12ad057eb5e53dacb71fdd0462b1418ecab1b760
7
+ data.tar.gz: b767230462343ccb9a56a51be2986bc6fd592ce9be9651f834d9673e749e295caf69bc7be96cbbcd8c601d47995cd3b2dbc7fcaabe5ab96b090382df904d3dbb
@@ -3,25 +3,35 @@
3
3
  module WmOktaHelper
4
4
  class CreateSession
5
5
  def initialize(options)
6
- @username = options[:username]
7
- @password = options[:password]
8
- @okta_org = options[:okta_org]
9
- @okta_domain = options[:okta_domain]
6
+ @options = options
10
7
  end
11
8
 
12
9
  def call
13
- PostRequest.new(
14
- url: url,
15
- request_body: request_body
16
- ).call
10
+ check_options
11
+ raise 'Not authorized' if response['sessionToken'].blank?
12
+ response
17
13
  end
18
14
 
19
15
  attr_accessor :username, :password, :okta_org, :okta_domain
20
16
 
21
17
  private
22
18
 
19
+ def available_options
20
+ %i[username password okta_org okta_domain]
21
+ end
22
+
23
+ def check_options
24
+ missing_options = available_options.select { |o| @options[o].blank? }
25
+ if missing_options.present?
26
+ raise "Missing configuration variable: #{missing_options}"
27
+ end
28
+ available_options.each do |o|
29
+ instance_variable_set("@#{o}", @options[o])
30
+ end
31
+ end
32
+
23
33
  def url
24
- "https://#{okta_org}.#{okta_domain}.com/api/v1/authn"
34
+ "https://#{@okta_org}.#{@okta_domain}.com/api/v1/authn"
25
35
  end
26
36
 
27
37
  def request_body
@@ -34,5 +44,12 @@ module WmOktaHelper
34
44
  }
35
45
  }
36
46
  end
47
+
48
+ def response
49
+ @response ||= PostRequest.new(
50
+ url: url,
51
+ request_body: request_body
52
+ ).call
53
+ end
37
54
  end
38
55
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module WmOktaHelper
4
- VERSION = '0.2.2'
4
+ VERSION = '0.2.3'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wm_okta_helper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jose C Fernandez
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-09-24 00:00:00.000000000 Z
11
+ date: 2018-10-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json-jwt
@@ -199,7 +199,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
199
199
  version: '0'
200
200
  requirements: []
201
201
  rubyforge_project:
202
- rubygems_version: 2.6.14
202
+ rubygems_version: 2.6.14.1
203
203
  signing_key:
204
204
  specification_version: 4
205
205
  summary: Helper library for validating Okta jwt token.