crowd-auth 0.0.3 → 0.0.4
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.
- data/README.markdown +25 -0
- data/crowd-auth.gemspec +2 -2
- data/lib/crowd-auth.rb +11 -8
- data/lib/crowd-auth/version.rb +1 -1
- metadata +5 -6
data/README.markdown
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# README
|
2
|
+
|
3
|
+
## How-to
|
4
|
+
|
5
|
+
> require 'crowd-auth'
|
6
|
+
|
7
|
+
> c = Crowd::Auth.new
|
8
|
+
> c.crowd_url = "http://your.crowd.url:8095"
|
9
|
+
> c.crowd_app_name = "app_name"
|
10
|
+
> c.crowd_app_pass = "app_password"
|
11
|
+
|
12
|
+
> resp = c.authenticate('username', 'password')
|
13
|
+
|
14
|
+
> puts resp.code
|
15
|
+
200
|
16
|
+
|
17
|
+
Anything but a 200 means authorization failed.
|
18
|
+
|
19
|
+
Overload `crowd_auth_uri` with your crowd's rest url.
|
20
|
+
|
21
|
+
By default, that is `/crowd/rest/usermanagement/latest/authentication`
|
22
|
+
|
23
|
+
## Thanks
|
24
|
+
|
25
|
+
[Kastner](http://metaatem.net "Kastner"), as always for the insight and help making things cleaner.
|
data/crowd-auth.gemspec
CHANGED
@@ -8,7 +8,7 @@ Gem::Specification.new do |s|
|
|
8
8
|
s.platform = Gem::Platform::RUBY
|
9
9
|
s.authors = ["Ian Meyer"]
|
10
10
|
s.email = ["ianmmeyer@gmail.com"]
|
11
|
-
s.homepage = ""
|
11
|
+
s.homepage = "https://github.com/imeyer/crowd-auth"
|
12
12
|
s.summary = %q{Simple authentication against Atlassian Crowd}
|
13
13
|
s.description = %q{Simple authentication against Atlassian Crowd}
|
14
14
|
|
@@ -20,4 +20,4 @@ Gem::Specification.new do |s|
|
|
20
20
|
s.require_paths = ["lib"]
|
21
21
|
|
22
22
|
s.add_dependency('rest-client', '>= 1.6.1')
|
23
|
-
end
|
23
|
+
end
|
data/lib/crowd-auth.rb
CHANGED
@@ -4,18 +4,21 @@ module Crowd
|
|
4
4
|
# This is some kind of comment
|
5
5
|
class Auth
|
6
6
|
attr_accessor :crowd_url, :crowd_app_name, :crowd_app_pass, :crowd_auth_uri
|
7
|
-
|
7
|
+
|
8
8
|
def initialize(options = {})
|
9
9
|
options.each { |key, value| instance_variable_set("@#{key}", value) }
|
10
10
|
@crowd_auth_uri ||= "/crowd/rest/usermanagement/latest/authentication"
|
11
11
|
end
|
12
|
-
|
12
|
+
|
13
13
|
def authenticate(username, password)
|
14
|
-
rest_client = RestClient::Resource.new
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
14
|
+
rest_client = RestClient::Resource.new("#{@crowd_url}", :user => @crowd_app_name, :password => @crowd_app_pass)
|
15
|
+
|
16
|
+
# Crowd returns 200 on correct authentication or 400 for incorrect
|
17
|
+
begin
|
18
|
+
return !!rest_client["#{@crowd_auth_uri}?username=#{username}"].post("{\"value\":\"#{password}\"}", :accept => "application/json", :content_type => "application/json")
|
19
|
+
rescue RestClient::BadRequest
|
20
|
+
return false
|
21
|
+
end
|
19
22
|
end
|
20
23
|
end
|
21
|
-
end
|
24
|
+
end
|
data/lib/crowd-auth/version.rb
CHANGED
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: crowd-auth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.4
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Ian Meyer
|
@@ -10,8 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date:
|
14
|
-
default_executable:
|
13
|
+
date: 2012-05-25 00:00:00 Z
|
15
14
|
dependencies:
|
16
15
|
- !ruby/object:Gem::Dependency
|
17
16
|
name: rest-client
|
@@ -36,12 +35,12 @@ extra_rdoc_files: []
|
|
36
35
|
files:
|
37
36
|
- .gitignore
|
38
37
|
- Gemfile
|
38
|
+
- README.markdown
|
39
39
|
- Rakefile
|
40
40
|
- crowd-auth.gemspec
|
41
41
|
- lib/crowd-auth.rb
|
42
42
|
- lib/crowd-auth/version.rb
|
43
|
-
|
44
|
-
homepage: ""
|
43
|
+
homepage: https://github.com/imeyer/crowd-auth
|
45
44
|
licenses: []
|
46
45
|
|
47
46
|
post_install_message:
|
@@ -64,7 +63,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
64
63
|
requirements: []
|
65
64
|
|
66
65
|
rubyforge_project: crowd-auth
|
67
|
-
rubygems_version: 1.
|
66
|
+
rubygems_version: 1.8.15
|
68
67
|
signing_key:
|
69
68
|
specification_version: 3
|
70
69
|
summary: Simple authentication against Atlassian Crowd
|