omniauth-cronofy 0.4.0 → 0.6.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 +4 -4
- data/.editorconfig +15 -0
- data/Gemfile +2 -0
- data/README.md +71 -6
- data/lib/omniauth-cronofy.rb +4 -2
- data/lib/omniauth-cronofy/version.rb +1 -1
- data/lib/omniauth/strategies/cronofy.rb +0 -2
- data/lib/omniauth/strategies/cronofy_service_account.rb +39 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f67090a55b55a905567850c52f637d06f517e6de
|
4
|
+
data.tar.gz: 7adb93310c05dcba6cdd1427fd1dcd327d2cf5d5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a9cf471c625f7179b1ef10caeb209f902557e8ceea357c8964d76e8fae35ccedc14ac3855bfc6f6dd82b003fb217f839137ce566335e7ee16da602f2f891d3fe
|
7
|
+
data.tar.gz: 9fbdd4d4d945104b0a7c30944235a09ebf53d2b3d6db2a0bf16628987ba682281fd20223b4418c940f397803fb6de67f9dbfcc4707aeaba85df7e37db751657f
|
data/.editorconfig
ADDED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -2,7 +2,10 @@
|
|
2
2
|
|
3
3
|
Strategy to authenticate with Cronofy via OAuth2 in OmniAuth.
|
4
4
|
|
5
|
-
|
5
|
+
Contains strategies for both [End User authorization](#end-user-authorization)
|
6
|
+
and [Service Account authorization](#service-account-authorization).
|
7
|
+
|
8
|
+
Get your API accesss at: https://www.cronofy.com/developers
|
6
9
|
|
7
10
|
## Installation
|
8
11
|
|
@@ -20,7 +23,9 @@ Or install it yourself as:
|
|
20
23
|
|
21
24
|
$ gem install omniauth-cronofy
|
22
25
|
|
23
|
-
##
|
26
|
+
## End User Authorization
|
27
|
+
|
28
|
+
### Usage
|
24
29
|
|
25
30
|
Here's an example for adding the middleware to a Rails app in `config/initializers/omniauth.rb`:
|
26
31
|
|
@@ -34,15 +39,16 @@ Rails.application.config.middleware.use OmniAuth::Builder do
|
|
34
39
|
end
|
35
40
|
```
|
36
41
|
|
37
|
-
Then to auth with Cronofy you would navigate to `/auth/cronofy
|
42
|
+
Then to auth with Cronofy you would navigate to `/auth/cronofy`.
|
38
43
|
|
39
|
-
|
44
|
+
### Configuration
|
40
45
|
|
41
46
|
Configurable options
|
42
47
|
|
43
|
-
* `scope`: A space-separated list of permissions you want to request
|
48
|
+
* `scope`: A space-separated list of permissions you want to request for the end-user. See the [API Authorization documentation](http://www.cronofy.com/developers/api#authorization) for a full list of available permissions.
|
49
|
+
|
44
50
|
|
45
|
-
|
51
|
+
### Auth Hash
|
46
52
|
|
47
53
|
```ruby
|
48
54
|
{
|
@@ -68,6 +74,65 @@ Configurable options
|
|
68
74
|
}
|
69
75
|
```
|
70
76
|
|
77
|
+
|
78
|
+
## Service Account Authorization
|
79
|
+
|
80
|
+
### Usage
|
81
|
+
|
82
|
+
Service Accounts allow you to use one set of credentials to access an entire organizations calendar service. This works with Google Apps, Office 365 and Exchange.
|
83
|
+
|
84
|
+
This can be used alongside standard end-user auth.
|
85
|
+
|
86
|
+
Typical configuration.
|
87
|
+
|
88
|
+
```ruby
|
89
|
+
Rails.application.config.middleware.use OmniAuth::Builder do
|
90
|
+
|
91
|
+
provider :cronofy_service_account, ENV["CRONOFY_CLIENT_ID"], ENV["CRONOFY_CLIENT_SECRET"], {
|
92
|
+
scope: "service_account/manage_accounts",
|
93
|
+
delegated_scope: "read_account read_events create_event delete_event"
|
94
|
+
}
|
95
|
+
|
96
|
+
end
|
97
|
+
```
|
98
|
+
|
99
|
+
Then to auth with Cronofy you would navigate to `/auth/cronofy_service_account`.
|
100
|
+
|
101
|
+
More information in Service Accounts documentation (link to follow).
|
102
|
+
|
103
|
+
### Configuration
|
104
|
+
|
105
|
+
Configurable options
|
106
|
+
|
107
|
+
* `scope`: A space-separated list of permissions you want to request for the service account. Doc link to follow.
|
108
|
+
|
109
|
+
* `delegated_scope` : A space-separated list of permissions you wish to request on the end-user accounts controlled by the Service Account. See the [API Authorization documentation](http://www.cronofy.com/developers/api#authorization) for a full list of available permissions.
|
110
|
+
|
111
|
+
### Auth Hash
|
112
|
+
|
113
|
+
```ruby
|
114
|
+
{
|
115
|
+
:provider => "cronofy_service_account",
|
116
|
+
:uid => "ser_382374827234",
|
117
|
+
:info => {
|
118
|
+
:domain => "company.com"
|
119
|
+
},
|
120
|
+
:credentials => {
|
121
|
+
:token => "token",
|
122
|
+
:refresh_token => "another_token",
|
123
|
+
:expires_at => 1424884727,
|
124
|
+
:expires => true
|
125
|
+
},
|
126
|
+
:extra => {
|
127
|
+
:raw_info => {
|
128
|
+
:sub = "ser_9324872847",
|
129
|
+
:cronofy.service_account.domain => "company.com",
|
130
|
+
:cronofy.type => "service_account"
|
131
|
+
}
|
132
|
+
}
|
133
|
+
}
|
134
|
+
```
|
135
|
+
|
71
136
|
## Contributing
|
72
137
|
|
73
138
|
1. Fork it ( https://github.com/[my-github-username]/omniauth-cronofy/fork )
|
data/lib/omniauth-cronofy.rb
CHANGED
@@ -0,0 +1,39 @@
|
|
1
|
+
module OmniAuth
|
2
|
+
module Strategies
|
3
|
+
class CronofyServiceAccount < OmniAuth::Strategies::OAuth2
|
4
|
+
option :name, "cronofy_service_account"
|
5
|
+
|
6
|
+
option :client_options, {
|
7
|
+
:site => ::OmniAuth::Strategies::Cronofy.app_url,
|
8
|
+
:authorize_url => "#{::OmniAuth::Strategies::Cronofy.app_url}/service_accounts/oauth/authorize",
|
9
|
+
}
|
10
|
+
|
11
|
+
def request_phase
|
12
|
+
options[:authorize_params] = { delegated_scope: options[:delegated_scope]} if options[:delegated_scope]
|
13
|
+
super
|
14
|
+
end
|
15
|
+
|
16
|
+
uid{ raw_info['sub'] }
|
17
|
+
|
18
|
+
info do
|
19
|
+
{
|
20
|
+
:domain => raw_info['cronofy.service_account.domain'],
|
21
|
+
}
|
22
|
+
end
|
23
|
+
|
24
|
+
def callback_url
|
25
|
+
options[:redirect_uri] || (full_host + script_name + callback_path)
|
26
|
+
end
|
27
|
+
|
28
|
+
extra do
|
29
|
+
{
|
30
|
+
'raw_info' => raw_info,
|
31
|
+
}
|
32
|
+
end
|
33
|
+
|
34
|
+
def raw_info
|
35
|
+
@raw_info ||= access_token.get("#{::OmniAuth::Strategies::Cronofy.api_url}/v1/userinfo").parsed
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: omniauth-cronofy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Bird
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-07-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: omniauth
|
@@ -73,6 +73,7 @@ executables: []
|
|
73
73
|
extensions: []
|
74
74
|
extra_rdoc_files: []
|
75
75
|
files:
|
76
|
+
- .editorconfig
|
76
77
|
- .gitignore
|
77
78
|
- .rspec
|
78
79
|
- .travis.yml
|
@@ -87,6 +88,7 @@ files:
|
|
87
88
|
- lib/omniauth-cronofy/version.rb
|
88
89
|
- lib/omniauth/.DS_Store
|
89
90
|
- lib/omniauth/strategies/cronofy.rb
|
91
|
+
- lib/omniauth/strategies/cronofy_service_account.rb
|
90
92
|
- omniauth-cronofy.gemspec
|
91
93
|
homepage: https://github.com/cronofy/omniauth-cronofy
|
92
94
|
licenses:
|