mais-access 1.0.7 → 1.1.1

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
  SHA256:
3
- metadata.gz: f4040bf29b94e114552132c19526dad52b00c1a908cc14f5723f4446d4ac1063
4
- data.tar.gz: 346fe0f6e32e3a6df68d2898f1964befce19c67f1ab354c62af5e82c45e986aa
3
+ metadata.gz: f88002e1195c7f1187c27fa7a244619fa3101a2ab91a650260dfcd9acb9d9912
4
+ data.tar.gz: fdc4e863615ef1ff267d989a0bdd2696ffa2bdbd876695cf4a15b484c4949aaf
5
5
  SHA512:
6
- metadata.gz: 05f792c13094ecc7694b48d44bb0d3fd20199887c4ffd4a9513c85f4a7796537c5b4b23faee27ef764bfaffc6afe469e23919f33fadf1286224224ff364cc9a2
7
- data.tar.gz: 33057723418743e8819f6b318f7e551ef22e24e062a9969acc0b933213416e2da1d0ffbf8302fae0623cf29263db2e62d7983f0795164fec834e7a02fc6f85d3
6
+ metadata.gz: 59f48ae598a636cfcaa9b82acb728e70977d7dbd384cf85404d3d11179db9ec46b79ce0c479790e4c05e1e13dd12f98f1d3bcd54a4bfa04f53cd662528d69dd9
7
+ data.tar.gz: e350a1b236ecefb20a7184d301c94c3be458c5ec4a8e1b81c986a17ef59257467c4fe89e324f1de48a5a699318073a0981800f4f8e6d33c90a1e9a58eb1df53c
@@ -1,6 +1,6 @@
1
1
  module MaisAccess
2
2
  module Dispatcher
3
- require 'net/http'
3
+ require 'net/https'
4
4
  require 'uri'
5
5
  require 'json'
6
6
  require 'mais-access/user'
@@ -13,14 +13,22 @@ module MaisAccess
13
13
  # Prompt the user for HTTP Basic credentials, or authenticate if they are cached in the session
14
14
  authenticate_or_request_with_http_basic("access - MAIS - #{MAIS_CLIENT}") do |login, password|
15
15
  begin
16
+ # Setup https connection and specify certificate bundle
17
+ url = URI("#{ENV['MAIS_ACCOUNTS_HOSTNAME']}/authenticate")
18
+ http = Net::HTTP.new(url.host, 443)
19
+ http.use_ssl = true
20
+ http.verify_mode = OpenSSL::SSL::VERIFY_PEER
21
+ http.cert_store = OpenSSL::X509::Store.new
22
+ http.cert_store.set_default_paths
23
+ http.cert_store.add_file("/etc/pki/tls/certs/server.crt")
24
+
16
25
  # Get the credentials and POST them to `accounts.scenycwork.net/authenticate`
17
- response = Net::HTTP.post_form(URI("#{ENV['MAIS_ACCOUNTS_HOSTNAME']}/authenticate"), { "username" => login, "password" => password })
18
- # Parse the JSON response
19
- body = JSON.parse(response.body)
26
+ request = Net::HTTP::Post.new(url.path, {'Content-Type' => 'application/json'})
27
+ request.set_form_data({ "username" => login, "password" => password })
28
+ response = http.request(request)
20
29
 
21
- Rails.logger.info(response.code)
22
- Rails.logger.info(response.message)
23
- Rails.logger.info(response.class.name)
30
+ # Parse the response body as JSON
31
+ body = JSON.parse(response.body)
24
32
 
25
33
  # If the user is valid, set the current mais user and passes the filter action
26
34
  if response.code == '200' && body["authenticated"]
@@ -3,7 +3,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
3
 
4
4
  Gem::Specification.new do |spec|
5
5
  spec.name = "mais-access"
6
- spec.version = "1.0.7"
6
+ spec.version = "1.1.1"
7
7
  spec.platform = Gem::Platform::RUBY
8
8
  spec.author = "Elias Gabriel"
9
9
  spec.email = "me@eliasfgabriel.com"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mais-access
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.7
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elias Gabriel