ldsconnect 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/ldsconnect.rb +39 -0
  3. metadata +59 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d63e0f6406c118fb0d63ef069baa293f608250f3
4
+ data.tar.gz: 968def5993c07bebabc357d9675719e9a8e9f28f
5
+ SHA512:
6
+ metadata.gz: cef016add6cb48fbce9af2c5183f61d76f30a84234b8e7ebbdbf6d301f0fcecd089d21df4ce35f4c5b2ba65377f352388763a2441bb96d97a850f7fdba59dc7b
7
+ data.tar.gz: 27c87e1cf002ccc5f8efc823e8fcd12b8b9fe1b3f49a6015e390f2af84273748d7623a0d77da4f081310b04c72ce2d496a5d1b03f6096140d331dd37302cfbe7
@@ -0,0 +1,39 @@
1
+ require "oauth2"
2
+
3
+ class LdsConnect
4
+ attr_reader :client
5
+ attr_accessor :options
6
+
7
+ SITE_URL = "https://ldsconnect.org"
8
+ AUTHORIZE_URL = "#{SITE_URL}/dialog/authorize"
9
+
10
+ def initialize(client_id, client_secret, options={})
11
+ client_options = {
12
+ site: SITE_URL,
13
+ authorize_url: AUTHORIZE_URL
14
+ }
15
+ @options = options
16
+ if @options[:scope]
17
+ client_options[:scope] = @options[:scope]
18
+ end
19
+ @client = OAuth2::Client.new(client_id, client_secret, client_options)
20
+ end
21
+
22
+ def authorize_url
23
+ redirect_uri ||= @options[:redirect_uri]
24
+ @client.auth_code.authorize_url(redirect_uri: redirect_uri)
25
+ end
26
+
27
+ def get_token(code)
28
+ @client.auth_code.get_token(code)
29
+ end
30
+
31
+ def get_profile(token)
32
+ OAuth2::AccessToken.new(@client, token).get("/api/ldsconnect/me")
33
+ end
34
+
35
+ def get_resource(token, path)
36
+ OAuth2::AccessToken.new(@client, token).get("/api/ldsconnect/#{path}")
37
+ end
38
+
39
+ end
metadata ADDED
@@ -0,0 +1,59 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ldsconnect
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - AJ ONeal
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-02-17 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: oauth2
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '='
18
+ - !ruby/object:Gem::Version
19
+ version: 1.0.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '='
25
+ - !ruby/object:Gem::Version
26
+ version: 1.0.0
27
+ description:
28
+ email: coolaj86@gmail.com
29
+ executables: []
30
+ extensions: []
31
+ extra_rdoc_files: []
32
+ files:
33
+ - lib/ldsconnect.rb
34
+ homepage: https://github.com/LDSorg/lds-connect-gem
35
+ licenses:
36
+ - Apache2
37
+ metadata: {}
38
+ post_install_message:
39
+ rdoc_options: []
40
+ require_paths:
41
+ - lib
42
+ required_ruby_version: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - '>='
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ required_rubygems_version: !ruby/object:Gem::Requirement
48
+ requirements:
49
+ - - '>='
50
+ - !ruby/object:Gem::Version
51
+ version: '0'
52
+ requirements: []
53
+ rubyforge_project:
54
+ rubygems_version: 2.0.14
55
+ signing_key:
56
+ specification_version: 4
57
+ summary: OAuth2 (Facebook Connect) authentication strategy for connecting to lds.org
58
+ thru LDS Connect with Ruby / Sinatra / etc
59
+ test_files: []