liangzan_omniauth-smugmug 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/Gemfile +2 -0
- data/README.md +36 -0
- data/lib/omniauth-smugmug.rb +2 -0
- data/lib/omniauth-smugmug/version.rb +5 -0
- data/lib/omniauth/strategies/smugmug.rb +48 -0
- data/omniauth-smugmug.gemspec +22 -0
- metadata +70 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
OmniAuth SmugMug
|
2
|
+
================
|
3
|
+
|
4
|
+
This is an [OmniAuth 1.0](https://github.com/intridea/omniauth) strategy for authenticating to SmugMug.
|
5
|
+
|
6
|
+
Get a SmugMug API key [here](http://www.smugmug.com/hack/apikeys)
|
7
|
+
|
8
|
+
This fork adds the access and permissions options during the authorization phase.
|
9
|
+
|
10
|
+
|
11
|
+
Usage
|
12
|
+
-----
|
13
|
+
|
14
|
+
In a Rack application:
|
15
|
+
|
16
|
+
```ruby
|
17
|
+
use OmniAuth::Builder do
|
18
|
+
provider :smugmug, ENV['SMUGMUG_KEY'], ENV['SMUGMUG_SECRET'], access: 'Full', permissions: 'Modify'
|
19
|
+
end
|
20
|
+
```
|
21
|
+
|
22
|
+
For Rails, put this in `config/initializers/omniauth.rb`:
|
23
|
+
|
24
|
+
```ruby
|
25
|
+
Rails.application.config.middleware.use OmniAuth::Builder do
|
26
|
+
provider :smugmug, ENV['SMUGMUG_KEY'], ENV['SMUGMUG_SECRET'], access: 'Full', permissions: 'Modify'
|
27
|
+
end
|
28
|
+
```
|
29
|
+
|
30
|
+
|
31
|
+
License
|
32
|
+
-------
|
33
|
+
|
34
|
+
Copyright (c) 2014 Wong Liang Zan.
|
35
|
+
|
36
|
+
This source code released under an MIT license.
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'omniauth-oauth'
|
2
|
+
require 'multi_json'
|
3
|
+
|
4
|
+
module OmniAuth
|
5
|
+
module Strategies
|
6
|
+
class SmugMug < OmniAuth::Strategies::OAuth
|
7
|
+
option :name, 'smugmug'
|
8
|
+
option :client_options, {
|
9
|
+
:site => 'http://api.smugmug.com',
|
10
|
+
:request_token_path => "/services/oauth/getRequestToken.mg",
|
11
|
+
:access_token_path => "/services/oauth/getAccessToken.mg",
|
12
|
+
:authorize_path => "/services/oauth/authorize.mg"
|
13
|
+
}
|
14
|
+
|
15
|
+
uid { user['id'] }
|
16
|
+
|
17
|
+
info do
|
18
|
+
{
|
19
|
+
'uid' => user['id'],
|
20
|
+
'nickname' => user['NickName'],
|
21
|
+
'name' => user['Name'],
|
22
|
+
'urls' => {
|
23
|
+
'website' => user['URL'],
|
24
|
+
}
|
25
|
+
}
|
26
|
+
end
|
27
|
+
|
28
|
+
extra do
|
29
|
+
{ 'user_hash' => user }
|
30
|
+
end
|
31
|
+
|
32
|
+
def user
|
33
|
+
@user_hash ||= MultiJson.decode(@access_token.get('http://api.smugmug.com/services/api/json/1.2.2/?method=smugmug.auth.checkAccessToken').body)['Auth']['User']
|
34
|
+
end
|
35
|
+
|
36
|
+
def request_phase
|
37
|
+
options[:authorize_params] = {
|
38
|
+
Access: options['access'],
|
39
|
+
Permissions: options['permissions']
|
40
|
+
}
|
41
|
+
super
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
OmniAuth.config.add_camelization 'smugmug', 'SmugMug'
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "omniauth-smugmug/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |gem|
|
6
|
+
gem.name = "liangzan_omniauth-smugmug"
|
7
|
+
gem.version = Omniauth::SmugMug::VERSION
|
8
|
+
gem.authors = ["Will Butler", "Wong Liang Zan"]
|
9
|
+
gem.email = ["wbutler@birdbox.com", "zan@liangzan.net"]
|
10
|
+
gem.homepage = "https://github.com/liangzan/omniauth-smugmug"
|
11
|
+
gem.description = %q{OmniAuth strategy for SmugMug (OAuth 1.0)}
|
12
|
+
gem.summary = gem.description
|
13
|
+
|
14
|
+
gem.files = `git ls-files`.split("\n")
|
15
|
+
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
16
|
+
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
17
|
+
gem.require_paths = ["lib"]
|
18
|
+
|
19
|
+
gem.add_runtime_dependency 'omniauth-oauth', '~> 1.0.1'
|
20
|
+
|
21
|
+
gem.required_rubygems_version = Gem::Requirement.new('>= 1.3.6') if gem.respond_to? :required_rubygems_version=
|
22
|
+
end
|
metadata
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: liangzan_omniauth-smugmug
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Will Butler
|
9
|
+
- Wong Liang Zan
|
10
|
+
autorequire:
|
11
|
+
bindir: bin
|
12
|
+
cert_chain: []
|
13
|
+
date: 2014-03-08 00:00:00.000000000 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: omniauth-oauth
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
|
+
none: false
|
19
|
+
requirements:
|
20
|
+
- - ~>
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 1.0.1
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
27
|
+
requirements:
|
28
|
+
- - ~>
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
version: 1.0.1
|
31
|
+
description: OmniAuth strategy for SmugMug (OAuth 1.0)
|
32
|
+
email:
|
33
|
+
- wbutler@birdbox.com
|
34
|
+
- zan@liangzan.net
|
35
|
+
executables: []
|
36
|
+
extensions: []
|
37
|
+
extra_rdoc_files: []
|
38
|
+
files:
|
39
|
+
- .gitignore
|
40
|
+
- Gemfile
|
41
|
+
- README.md
|
42
|
+
- lib/omniauth-smugmug.rb
|
43
|
+
- lib/omniauth-smugmug/version.rb
|
44
|
+
- lib/omniauth/strategies/smugmug.rb
|
45
|
+
- omniauth-smugmug.gemspec
|
46
|
+
homepage: https://github.com/liangzan/omniauth-smugmug
|
47
|
+
licenses: []
|
48
|
+
post_install_message:
|
49
|
+
rdoc_options: []
|
50
|
+
require_paths:
|
51
|
+
- lib
|
52
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
53
|
+
none: false
|
54
|
+
requirements:
|
55
|
+
- - ! '>='
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: '0'
|
58
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
59
|
+
none: false
|
60
|
+
requirements:
|
61
|
+
- - ! '>='
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: 1.3.6
|
64
|
+
requirements: []
|
65
|
+
rubyforge_project:
|
66
|
+
rubygems_version: 1.8.24
|
67
|
+
signing_key:
|
68
|
+
specification_version: 3
|
69
|
+
summary: OmniAuth strategy for SmugMug (OAuth 1.0)
|
70
|
+
test_files: []
|