mais-access 1.0.7 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/mais-access/dispatcher.rb +15 -7
- data/mais-access.gemspec +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f88002e1195c7f1187c27fa7a244619fa3101a2ab91a650260dfcd9acb9d9912
|
4
|
+
data.tar.gz: fdc4e863615ef1ff267d989a0bdd2696ffa2bdbd876695cf4a15b484c4949aaf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 59f48ae598a636cfcaa9b82acb728e70977d7dbd384cf85404d3d11179db9ec46b79ce0c479790e4c05e1e13dd12f98f1d3bcd54a4bfa04f53cd662528d69dd9
|
7
|
+
data.tar.gz: e350a1b236ecefb20a7184d301c94c3be458c5ec4a8e1b81c986a17ef59257467c4fe89e324f1de48a5a699318073a0981800f4f8e6d33c90a1e9a58eb1df53c
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module MaisAccess
|
2
2
|
module Dispatcher
|
3
|
-
require 'net/
|
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
|
-
|
18
|
-
|
19
|
-
|
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
|
-
|
22
|
-
|
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"]
|
data/mais-access.gemspec
CHANGED
@@ -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.
|
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"
|