activesp 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.6
1
+ 0.0.7
@@ -43,10 +43,11 @@ module ActiveSP
43
43
 
44
44
  # @private
45
45
  # TODO: create profile
46
- attr_reader :login, :password, :root_url, :trace
46
+ attr_reader :login, :password, :auth_type, :root_url, :trace
47
47
 
48
48
  # @param [Hash] options The connection options
49
49
  # @option options [String] :root The URL of the root site
50
+ # @option options [String] :auth_type (:ntlm) The authentication type, can be :basic or :ntlm.
50
51
  # @option options [String] :login (nil) The login
51
52
  # @option options [String] :password (nil) The password associated with the given login. Is mandatory if the login is specified. Also can't be "password" as that is inherently insafe. We don't explicitly check for this, but it can't be that.
52
53
  def initialize(options = {})
@@ -54,6 +55,7 @@ module ActiveSP
54
55
  @root_url = options.delete(:root) or raise ArgumentError, "missing :root option"
55
56
  @login = options.delete(:login)
56
57
  @password = options.delete(:password)
58
+ @auth_type = options.delete(:auth_type) || :ntlm
57
59
  @trace = options.delete(:trace)
58
60
  options.empty? or raise ArgumentError, "unknown options #{options.keys.map { |k| k.inspect }.join(", ")}"
59
61
  cache = nil
@@ -112,7 +114,16 @@ module ActiveSP
112
114
  end
113
115
  Net::HTTP.start(*@open_params) do |http|
114
116
  request = Net::HTTP::Get.new(URL(url).full_path.gsub(/ /, "%20"))
115
- request.ntlm_auth(@login, @password) if @login
117
+ if @login
118
+ case auth_type
119
+ when :ntlm
120
+ request.ntlm_auth(@login, @password)
121
+ when :basic
122
+ request.basic_auth(@login, @password)
123
+ else
124
+ raise ArgumentError, "Unknown authentication type #{auth_type.inspect}"
125
+ end
126
+ end
116
127
  response = http.request(request)
117
128
  # if Net::HTTPFound === response
118
129
  # response = fetch(response["location"])
data/lib/activesp/site.rb CHANGED
@@ -279,7 +279,16 @@ module ActiveSP
279
279
  def initialize(site, name)
280
280
  @site, @name = site, name
281
281
  @client = Savon::Client.new(::File.join(URI.escape(site.url), "_vti_bin", name + ".asmx?WSDL"))
282
- @client.request.ntlm_auth(site.connection.login, site.connection.password) if site.connection.login
282
+ if site.connection.login
283
+ case site.connection.auth_type
284
+ when :ntlm
285
+ @client.request.ntlm_auth(site.connection.login, site.connection.password)
286
+ when :basic
287
+ @client.request.basic_auth(site.connection.login, site.connection.password)
288
+ else
289
+ raise ArgumentError, "Unknown authentication type #{site.connection.auth_type.inspect}"
290
+ end
291
+ end
283
292
  end
284
293
 
285
294
  def call(m, *args)
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activesp
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 17
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 6
10
- version: 0.0.6
9
+ - 7
10
+ version: 0.0.7
11
11
  platform: ruby
12
12
  authors:
13
13
  - Peter Vanbroekhoven
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-12-06 00:00:00 +01:00
18
+ date: 2011-01-11 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -24,15 +24,12 @@ dependencies:
24
24
  requirement: &id001 !ruby/object:Gem::Requirement
25
25
  none: false
26
26
  requirements:
27
- - - "="
27
+ - - ">="
28
28
  - !ruby/object:Gem::Version
29
- hash: 117
29
+ hash: 3
30
30
  segments:
31
31
  - 0
32
- - 7
33
- - 2
34
- - 5
35
- version: 0.7.2.5
32
+ version: "0"
36
33
  type: :runtime
37
34
  version_requirements: *id001
38
35
  - !ruby/object:Gem::Dependency