omniauth-cronofy 0.4.0 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a0e963beee307e1ef87bf7bc57d9000a8e25ee4d
4
- data.tar.gz: 7dd00cee896904e6b896579381ddf9f85d1e56a9
3
+ metadata.gz: f67090a55b55a905567850c52f637d06f517e6de
4
+ data.tar.gz: 7adb93310c05dcba6cdd1427fd1dcd327d2cf5d5
5
5
  SHA512:
6
- metadata.gz: 342d5d5108bf4c42773f87a03c06200d44b9c64859a9d018a545e9b1a587122d9b9964d290eab9940662d7ecd106123d81d76f428702380190bea2752c20d9fa
7
- data.tar.gz: 8875413cdd2af311049dc9d9c1aeb4beb2f5811c62250b89fadfc95b8e1c2d30c3a71277ba0a7c94d2fbbd4a0af58fcabc4e0a267497a958f2bafc61002f1675
6
+ metadata.gz: a9cf471c625f7179b1ef10caeb209f902557e8ceea357c8964d76e8fae35ccedc14ac3855bfc6f6dd82b003fb217f839137ce566335e7ee16da602f2f891d3fe
7
+ data.tar.gz: 9fbdd4d4d945104b0a7c30944235a09ebf53d2b3d6db2a0bf16628987ba682281fd20223b4418c940f397803fb6de67f9dbfcc4707aeaba85df7e37db751657f
@@ -0,0 +1,15 @@
1
+ # http://EditorConfig.org
2
+
3
+ # Top-most EditorConfig file
4
+ root = true
5
+
6
+ # Defaults
7
+ [*]
8
+ charset = utf-8
9
+ end_of_line = lf
10
+ insert_final_newline = true
11
+ indent_style = space
12
+
13
+ # Ruby files
14
+ [{Gemfile,*.{rake,rb}]
15
+ indent_size = 2
data/Gemfile CHANGED
@@ -2,3 +2,5 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in omniauth-cronofy.gemspec
4
4
  gemspec
5
+
6
+ gem 'rack', '~> 1.0'
data/README.md CHANGED
@@ -2,7 +2,10 @@
2
2
 
3
3
  Strategy to authenticate with Cronofy via OAuth2 in OmniAuth.
4
4
 
5
- Get your API accesss at: http://www.cronofy.com/developers
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
- ## Usage
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
- ## Configuration
44
+ ### Configuration
40
45
 
41
46
  Configurable options
42
47
 
43
- * `scope`: A space-separated list of permissions you want to request from the user. See the [API Authorization documentation](http://www.cronofy.com/developers/api#authorization) for a full list of available permissions.
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
- ## Auth Hash
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 )
@@ -1,3 +1,5 @@
1
- require 'omniauth'
1
+ require "omniauth"
2
+ require "omniauth-oauth2"
2
3
  require "omniauth-cronofy/version"
3
- require "omniauth/strategies/cronofy"
4
+ require "omniauth/strategies/cronofy"
5
+ require "omniauth/strategies/cronofy_service_account"
@@ -1,5 +1,5 @@
1
1
  module OmniAuth
2
2
  module Cronofy
3
- VERSION = '0.4.0'
3
+ VERSION = '0.6.0'.freeze
4
4
  end
5
5
  end
@@ -1,5 +1,3 @@
1
- require 'omniauth-oauth2'
2
-
3
1
  module OmniAuth
4
2
  module Strategies
5
3
  class Cronofy < OmniAuth::Strategies::OAuth2
@@ -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.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-04-11 00:00:00.000000000 Z
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: