azure-acs 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +11 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +30 -0
- data/LICENSE.txt +22 -0
- data/README.md +31 -0
- data/Rakefile +1 -0
- data/azure-acs.gemspec +22 -0
- data/lib/azure-acs.rb +4 -0
- data/lib/azure-acs/idp_feed.rb +34 -0
- data/lib/azure-acs/version.rb +5 -0
- data/spec/azure-acs/idp_feed_spec.rb +49 -0
- data/spec/spec_helper.rb +1 -0
- metadata +91 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
azure-acs (0.1.0)
|
5
|
+
typhoeus (~> 0.4.2)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
diff-lcs (1.1.3)
|
11
|
+
ffi (1.9.0)
|
12
|
+
mime-types (1.23)
|
13
|
+
rspec (2.12.0)
|
14
|
+
rspec-core (~> 2.12.0)
|
15
|
+
rspec-expectations (~> 2.12.0)
|
16
|
+
rspec-mocks (~> 2.12.0)
|
17
|
+
rspec-core (2.12.2)
|
18
|
+
rspec-expectations (2.12.1)
|
19
|
+
diff-lcs (~> 1.1.3)
|
20
|
+
rspec-mocks (2.12.2)
|
21
|
+
typhoeus (0.4.2)
|
22
|
+
ffi (~> 1.0)
|
23
|
+
mime-types (~> 1.18)
|
24
|
+
|
25
|
+
PLATFORMS
|
26
|
+
ruby
|
27
|
+
|
28
|
+
DEPENDENCIES
|
29
|
+
azure-acs!
|
30
|
+
rspec
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2011-2013 Keith Beckman, http://coding4streetcred.com/blog
|
2
|
+
All rights reserved. Released under the MIT license.
|
3
|
+
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# Azure-ACS #
|
2
|
+
|
3
|
+
Azure-ACS is a lightweight Ruby client library that exposes some some of the access control features
|
4
|
+
of Microsoft's [Windows Azure Active Directory](http://www.windowsazure.com/en-us/solutions/identity/)
|
5
|
+
(formerly Access Control Service).
|
6
|
+
|
7
|
+
### Features ###
|
8
|
+
|
9
|
+
* Ingegration with the ACS [Identity Provider JSON feed]
|
10
|
+
(http://msdn.microsoft.com/en-us/library/windowsazure/gg185963.aspx).
|
11
|
+
|
12
|
+
|
13
|
+
## Installation ##
|
14
|
+
|
15
|
+
Add this line to your application's Gemfile:
|
16
|
+
```ruby
|
17
|
+
gem 'azure-acs'
|
18
|
+
```
|
19
|
+
|
20
|
+
And then execute:
|
21
|
+
|
22
|
+
$ bundle install
|
23
|
+
|
24
|
+
Or install it globally as:
|
25
|
+
|
26
|
+
$ gem install azure-acs
|
27
|
+
|
28
|
+
|
29
|
+
## Authors and Credits ##
|
30
|
+
|
31
|
+
Authored by [Keith Beckman](https://github.com/kbeckman).
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
data/azure-acs.gemspec
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/azure-acs/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.name = 'azure-acs'
|
6
|
+
gem.version = Azure::Acs::VERSION
|
7
|
+
gem.description = 'A lightweight Ruby client library for Azure Active Directory ACS.'
|
8
|
+
gem.summary = 'Azure Active Directory ACS Ruby client library.'
|
9
|
+
|
10
|
+
gem.authors = ['Keith Beckman']
|
11
|
+
gem.email = ['kbeckman.c4sc@gmail.com']
|
12
|
+
gem.homepage = 'https://github.com/kbeckman/azure-acs'
|
13
|
+
|
14
|
+
gem.add_runtime_dependency 'typhoeus', '~> 0.4.2'
|
15
|
+
|
16
|
+
gem.add_development_dependency 'rspec'
|
17
|
+
|
18
|
+
gem.files = `git ls-files`.split($/)
|
19
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
20
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
21
|
+
gem.require_paths = ['lib']
|
22
|
+
end
|
data/lib/azure-acs.rb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'typhoeus'
|
2
|
+
require 'erb'
|
3
|
+
|
4
|
+
module AzureACS
|
5
|
+
|
6
|
+
class IdPFeed
|
7
|
+
|
8
|
+
include ERB::Util
|
9
|
+
|
10
|
+
def initialize(acs_namespace, realm, reply_to)
|
11
|
+
raise ArgumentError.new('Azure ACS namespace cannot be null.') if acs_namespace.nil? || acs_namespace == ''
|
12
|
+
raise ArgumentError.new('Relying party realm cannot be null.') if realm.nil? || realm == ''
|
13
|
+
raise ArgumentError.new('Relying party reply_to cannot be null.') if reply_to.nil? || reply_to == ''
|
14
|
+
|
15
|
+
realm = url_encode(realm)
|
16
|
+
reply_to = url_encode(reply_to)
|
17
|
+
|
18
|
+
url_base = "https://#{acs_namespace}.accesscontrol.windows.net:443/v2/metadata/IdentityProviders.js"
|
19
|
+
url_params = "protocol=wsfederation&realm=#{realm}&reply_to=#{reply_to}&context=&request_id=&version=1.0&callback="
|
20
|
+
@json_feed_url = "#{url_base}?#{url_params}"
|
21
|
+
end
|
22
|
+
|
23
|
+
def json_feed_url
|
24
|
+
@json_feed_url
|
25
|
+
end
|
26
|
+
|
27
|
+
def identity_providers
|
28
|
+
@identity_providers ||= Typhoeus::Request.get(@json_feed_url).body
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'erb'
|
3
|
+
|
4
|
+
describe AzureACS::IdPFeed do
|
5
|
+
|
6
|
+
describe 'Initialization' do
|
7
|
+
|
8
|
+
let(:acs_namespace) { 'example' }
|
9
|
+
let(:realm) { 'https://rp.example.com/app_name' }
|
10
|
+
let(:reply_to) { 'https://rp.example.com/auth/wsfed' }
|
11
|
+
|
12
|
+
context 'with invalid ctor params' do
|
13
|
+
|
14
|
+
it 'should raise an exception when ACS namespaces is nil or empty' do
|
15
|
+
expect { described_class.new(nil, realm, reply_to) }.to raise_error ArgumentError
|
16
|
+
expect { described_class.new('', realm, reply_to) }.to raise_error ArgumentError
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'should raise an exception when relying party realm is nil or empty' do
|
20
|
+
expect { described_class.new(acs_namespace, nil, reply_to) }.to raise_error ArgumentError
|
21
|
+
expect { described_class.new(acs_namespace, '', reply_to) }.to raise_error ArgumentError
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'should raise an exception when relying party reply_to is nil or empty' do
|
25
|
+
expect { described_class.new(acs_namespace, realm, nil) }.to raise_error ArgumentError
|
26
|
+
expect { described_class.new(acs_namespace, realm, '') }.to raise_error ArgumentError
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
context 'valid ctor params' do
|
32
|
+
|
33
|
+
it 'should set the JSON Feed URL property' do
|
34
|
+
described_class.new(acs_namespace, realm, reply_to).json_feed_url.should_not be_nil
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'should url_encode realm and reply_to' do
|
38
|
+
url_base = "https://#{acs_namespace}.accesscontrol.windows.net:443/v2/metadata/IdentityProviders.js"
|
39
|
+
url_params = "protocol=wsfederation&realm=#{ERB::Util.url_encode(realm)}&reply_to=#{ERB::Util.url_encode(reply_to)}&context=&request_id=&version=1.0&callback="
|
40
|
+
expected_json_feed_url = "#{url_base}?#{url_params}"
|
41
|
+
|
42
|
+
described_class.new(acs_namespace, realm, reply_to).json_feed_url.should == expected_json_feed_url
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'azure-acs'
|
metadata
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: azure-acs
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Keith Beckman
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-06-13 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: typhoeus
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 0.4.2
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 0.4.2
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rspec
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
description: A lightweight Ruby client library for Azure Active Directory ACS.
|
47
|
+
email:
|
48
|
+
- kbeckman.c4sc@gmail.com
|
49
|
+
executables: []
|
50
|
+
extensions: []
|
51
|
+
extra_rdoc_files: []
|
52
|
+
files:
|
53
|
+
- .gitignore
|
54
|
+
- Gemfile
|
55
|
+
- Gemfile.lock
|
56
|
+
- LICENSE.txt
|
57
|
+
- README.md
|
58
|
+
- Rakefile
|
59
|
+
- azure-acs.gemspec
|
60
|
+
- lib/azure-acs.rb
|
61
|
+
- lib/azure-acs/idp_feed.rb
|
62
|
+
- lib/azure-acs/version.rb
|
63
|
+
- spec/azure-acs/idp_feed_spec.rb
|
64
|
+
- spec/spec_helper.rb
|
65
|
+
homepage: https://github.com/kbeckman/azure-acs
|
66
|
+
licenses: []
|
67
|
+
post_install_message:
|
68
|
+
rdoc_options: []
|
69
|
+
require_paths:
|
70
|
+
- lib
|
71
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
73
|
+
requirements:
|
74
|
+
- - ! '>='
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
78
|
+
none: false
|
79
|
+
requirements:
|
80
|
+
- - ! '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
requirements: []
|
84
|
+
rubyforge_project:
|
85
|
+
rubygems_version: 1.8.25
|
86
|
+
signing_key:
|
87
|
+
specification_version: 3
|
88
|
+
summary: Azure Active Directory ACS Ruby client library.
|
89
|
+
test_files:
|
90
|
+
- spec/azure-acs/idp_feed_spec.rb
|
91
|
+
- spec/spec_helper.rb
|