omniauth-camdram 1.0.0
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.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE +21 -0
- data/README.md +43 -0
- data/examples/sinatra/Gemfile +6 -0
- data/examples/sinatra/README.md +12 -0
- data/examples/sinatra/config.ru +28 -0
- data/lib/omniauth-camdram.rb +2 -0
- data/lib/omniauth-camdram/version.rb +5 -0
- data/lib/omniauth/strategies/camdram.rb +47 -0
- data/omniauth-camdram.gemspec +29 -0
- metadata +167 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: ec242a381b498fe1b3ab75f5cd57ee545cb19f7038089b973b372725836df780
|
4
|
+
data.tar.gz: 67772bf15435739ff38629ada6d957af330b300d2ceb9ad0ba16ee753aca595b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d9a0dcb837780f006a6fb89d5f9ed3c0644f8cff18e4dc88eb34f5098d4413d2293bd2b01e1589112645e4c4d31c05a5c01a2e91c1e14b308f4705983409f594
|
7
|
+
data.tar.gz: 3643f046493761658d01d9a0c70f5a3de4900ba7d1defe546d17893bee9bc5ef3cf3578117e19f61a75fc8c9e73932c296c90bca2fd17819216472146dd20a31
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2018 Charlie Jonas
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
# Camdram's Omniauth strategy
|
2
|
+
|
3
|
+
This is the official Ruby OmniAuth strategy for authenticating to [Camdram](https://www.camdram.net).
|
4
|
+
|
5
|
+
Before you can start developing your API client for Camdram, you need to [create an application](https://www.camdram.net/api/apps/new) and copy the application ID and secret key.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add the strategy to your `Gemfile`:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'omniauth-camdram'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then run `bundle install`.
|
16
|
+
|
17
|
+
## Usage
|
18
|
+
|
19
|
+
You can integrate the strategy into your middleware in a `config.ru`:
|
20
|
+
|
21
|
+
```ruby
|
22
|
+
use OmniAuth::Builder do
|
23
|
+
provider :camdram, SETTINGS['CAMDRAM_APP_ID'], SETTINGS['CAMDRAM_APP_SECRET'], scope: "user_shows user_orgs user_email write write_org"
|
24
|
+
end
|
25
|
+
```
|
26
|
+
|
27
|
+
If you're using Rails, you'll want to add to the middleware stack:
|
28
|
+
|
29
|
+
```ruby
|
30
|
+
Rails.application.config.middleware.use OmniAuth::Builder do
|
31
|
+
provider :camdram, SETTINGS['CAMDRAM_APP_ID'], SETTINGS['CAMDRAM_APP_SECRET'], scope: "user_shows user_orgs user_email write write_org"
|
32
|
+
end
|
33
|
+
```
|
34
|
+
|
35
|
+
You can see a description of the different types of scope on the [Camdram repository](https://github.com/camdram/camdram/blob/master/src/Acts/CamdramApiBundle/Resources/views/Authorize/authorize.html.twig).
|
36
|
+
|
37
|
+
For additional information, please refer to the [OmniAuth wiki](https://github.com/intridea/omniauth/wiki).
|
38
|
+
|
39
|
+
See the [example](https://github.com/camdram/omniauth-camdram/blob/master/examples/sinatra/config.ru) Sinatra app for full examples.
|
40
|
+
|
41
|
+
## License
|
42
|
+
|
43
|
+
omniauth-camdram is released under the MIT License.
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# Sinatra Example
|
2
|
+
|
3
|
+
This example clearly demonstrates how to use the omniauth-camdram strategy with a simple Sinatra web app.
|
4
|
+
You will need to create a new API app at https://www.camdram.net/api/apps before you continue.
|
5
|
+
|
6
|
+
## Setup
|
7
|
+
|
8
|
+
1. `git clone https://github.com/camdram/omniauth-camdram.git`
|
9
|
+
2. `cd omniauth-camdram/examples/sinatra`
|
10
|
+
3. Set the ENV variables CAMDRAM_APP_ID and CAMDRAM_APP_SECRET
|
11
|
+
4. Run the `rackup` command
|
12
|
+
5. Navigate to http://localhost:4567 and complete the login process
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler/setup'
|
3
|
+
require 'sinatra'
|
4
|
+
require 'omniauth-camdram'
|
5
|
+
|
6
|
+
class CamdramExample < Sinatra::Base
|
7
|
+
use Rack::Session::Cookie
|
8
|
+
|
9
|
+
get '/' do
|
10
|
+
redirect '/auth/camdram'
|
11
|
+
end
|
12
|
+
|
13
|
+
get '/auth/:provider/callback' do
|
14
|
+
content_type 'text/plain'
|
15
|
+
request.env['omniauth.auth'].to_hash.inspect rescue "No Data"
|
16
|
+
end
|
17
|
+
|
18
|
+
get '/auth/failure' do
|
19
|
+
content_type 'text/plain'
|
20
|
+
request.env['omniauth.auth'].to_hash.inspect rescue "No Data"
|
21
|
+
end
|
22
|
+
|
23
|
+
use OmniAuth::Builder do
|
24
|
+
provider OmniAuth::Strategies::Camdram, ENV["CAMDRAM_APP_ID"], ENV["CAMDRAM_APP_SECRET"], scope: "user_shows user_orgs"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
run CamdramExample.run!
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'omniauth-oauth2'
|
2
|
+
|
3
|
+
module OmniAuth
|
4
|
+
module Strategies
|
5
|
+
#
|
6
|
+
# Authenticate to Camdram via OAuth and retrieve basic user information.
|
7
|
+
# Usage:
|
8
|
+
# use OmniAuth::Strategies::Camdram, 'app-id-key', 'app-secret-key', :scope => 'user_shows user_orgs', :display => 'plain'
|
9
|
+
#
|
10
|
+
class Camdram < OmniAuth::Strategies::OAuth2
|
11
|
+
BASE_URL = "https://www.camdram.net"
|
12
|
+
|
13
|
+
option :name, "camdram"
|
14
|
+
|
15
|
+
unless OmniAuth.config.test_mode
|
16
|
+
option :client_options, {
|
17
|
+
:authorize_url => "#{BASE_URL}/oauth/v2/auth",
|
18
|
+
:token_url => "#{BASE_URL}/oauth/v2/token",
|
19
|
+
:site => BASE_URL
|
20
|
+
}
|
21
|
+
else
|
22
|
+
option :client_options, {
|
23
|
+
:authorize_url => "http://localhost:3000/oauth/v2/auth",
|
24
|
+
:token_url => "http://localhost:3000/oauth/v2/token",
|
25
|
+
:site => "http://localhost:3000"
|
26
|
+
}
|
27
|
+
end
|
28
|
+
|
29
|
+
uid do
|
30
|
+
raw_info['id']
|
31
|
+
end
|
32
|
+
|
33
|
+
info do
|
34
|
+
{
|
35
|
+
:name => raw_info['name'],
|
36
|
+
:email => raw_info['email'],
|
37
|
+
:type => raw_info['_type']
|
38
|
+
}
|
39
|
+
end
|
40
|
+
|
41
|
+
def raw_info
|
42
|
+
@raw_info ||= access_token.get('/auth/account.json').parsed
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
lib = File.expand_path('../lib', __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require 'omniauth-camdram/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "omniauth-camdram"
|
7
|
+
spec.version = Omniauth::Camdram::VERSION
|
8
|
+
spec.authors = ["Charlie Jonas"]
|
9
|
+
spec.email = ["devel@charliejonas.co.uk"]
|
10
|
+
spec.summary = %q{Official OmniAuth strategy for Camdram}
|
11
|
+
spec.description = %q{Official OmniAuth strategy for Camdram}
|
12
|
+
spec.homepage = ""
|
13
|
+
spec.license = "MIT"
|
14
|
+
|
15
|
+
spec.files = `git ls-files`.split($/)
|
16
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
|
20
|
+
spec.add_dependency "omniauth", "~> 1.0"
|
21
|
+
spec.add_dependency "omniauth-oauth2", "~> 1.0"
|
22
|
+
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.5"
|
24
|
+
spec.add_development_dependency "rake"
|
25
|
+
spec.add_development_dependency "rspec", "~> 2.7"
|
26
|
+
spec.add_development_dependency "rack-test"
|
27
|
+
spec.add_development_dependency "simplecov"
|
28
|
+
spec.add_development_dependency "webmock"
|
29
|
+
end
|
metadata
ADDED
@@ -0,0 +1,167 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: omniauth-camdram
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Charlie Jonas
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-06-15 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: omniauth
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.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'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: omniauth-oauth2
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.5'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.5'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '2.7'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '2.7'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rack-test
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: simplecov
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: webmock
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
description: Official OmniAuth strategy for Camdram
|
126
|
+
email:
|
127
|
+
- devel@charliejonas.co.uk
|
128
|
+
executables: []
|
129
|
+
extensions: []
|
130
|
+
extra_rdoc_files: []
|
131
|
+
files:
|
132
|
+
- ".gitignore"
|
133
|
+
- Gemfile
|
134
|
+
- LICENSE
|
135
|
+
- README.md
|
136
|
+
- examples/sinatra/Gemfile
|
137
|
+
- examples/sinatra/README.md
|
138
|
+
- examples/sinatra/config.ru
|
139
|
+
- lib/omniauth-camdram.rb
|
140
|
+
- lib/omniauth-camdram/version.rb
|
141
|
+
- lib/omniauth/strategies/camdram.rb
|
142
|
+
- omniauth-camdram.gemspec
|
143
|
+
homepage: ''
|
144
|
+
licenses:
|
145
|
+
- MIT
|
146
|
+
metadata: {}
|
147
|
+
post_install_message:
|
148
|
+
rdoc_options: []
|
149
|
+
require_paths:
|
150
|
+
- lib
|
151
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
152
|
+
requirements:
|
153
|
+
- - ">="
|
154
|
+
- !ruby/object:Gem::Version
|
155
|
+
version: '0'
|
156
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
157
|
+
requirements:
|
158
|
+
- - ">="
|
159
|
+
- !ruby/object:Gem::Version
|
160
|
+
version: '0'
|
161
|
+
requirements: []
|
162
|
+
rubyforge_project:
|
163
|
+
rubygems_version: 2.7.6
|
164
|
+
signing_key:
|
165
|
+
specification_version: 4
|
166
|
+
summary: Official OmniAuth strategy for Camdram
|
167
|
+
test_files: []
|