billingsystem-remote 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -14,7 +14,7 @@ Hands a specific amount of control to Billingsystem so that it can operate upon
14
14
 
15
15
  This gem adds a controller called Frontend::UsersController to your app. The remote app (in this case, Billingsystem) must send an API using HTTP Basic Auth credentials and the preferred username and password.
16
16
 
17
- Step 1. Create your predefined key
17
+ Step 1. Create HTTP Basic Auth credentials
18
18
 
19
19
  $ script/console # open up a Rails console
20
20
  >> ActiveSupport::SecureRandom.hex
@@ -28,7 +28,25 @@ class Frontend::UsersController < ApplicationController
28
28
 
29
29
  def authenticate
30
30
  authenticate_or_request_with_http_basic do |username, password|
31
- username == BillingSystem::Remote::Config::USERNAME && password == BillingSystem::Remote::Config::PASSWORD
31
+ # +_+ #
32
+ # get username & pw from config file
33
+ config_filename = "config/billingsystem-remote.yml"
34
+ config = nil
35
+ begin
36
+ config = YAML::load_file(config_filename)
37
+ rescue => e
38
+ raise "Failed to load config file for HTTP Basic Auth #{config_filename}: #{e}"
39
+ end
40
+ # +_+ #
41
+ ret = (username == config["username"] && password == config["password"])
42
+ # +_+ #
43
+ if ret
44
+ Rails.logger.info("[#{Time.now}]: Frontend::UsersController: accepted HTTP Basic Auth username & password.")
45
+ else
46
+ Rails.logger.info("[#{Time.now}]: Frontend::UsersController: rejected HTTP Basic Auth username & password.")
47
+ end
48
+ # +_+ #
49
+ ret
32
50
  end
33
51
  end
34
52
 
@@ -2,5 +2,5 @@ $:.unshift(File.dirname(__FILE__)) unless
2
2
  $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
3
3
 
4
4
  module BillingsystemRemote
5
- VERSION = '0.0.2'
5
+ VERSION = '0.0.3'
6
6
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: billingsystem-remote
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 2
10
- version: 0.0.2
9
+ - 3
10
+ version: 0.0.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Commander Johnson
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-02-24 00:00:00 +01:00
18
+ date: 2012-02-26 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency