zaikio-oauth_client 0.8.1 → 0.9.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 32791412d8324e894c609e9ba73c1bc2fabb756117b91d81012d208730dfd5c2
4
- data.tar.gz: a1af7430748c3bce9e0d8058de85edcbdf0e2ecc3b568b389184e13b8945753d
3
+ metadata.gz: 6e956bf122053d559c2dd918f4b90a23c10559bc5578442bc26dbe1530a3396b
4
+ data.tar.gz: 0d594a45ddf589b03d9e43817885377d963934345fa6cb936b367fe64761e08a
5
5
  SHA512:
6
- metadata.gz: 6a33fdbb048a31fb157b006606ecbebbe69ac7950e17a25e1c3817f02485b15d8e7726c10fc8277ca57b6ea0a4781264d3055f188a0883613b053605e9a990a6
7
- data.tar.gz: 6e404b985ce76339e9edf1612b2db4d0d686c9b75f67ae8f4ff131c80e806a5911a223681d2abbbbbf03b72c3e155c66a891e45a696da403cdac095c2b1513f2
6
+ metadata.gz: 38355e0660ea6b2fd2c1b13a23a75626b5d4ae4efd3e64eb21396893e4a2ffc39c34824f373e994f596e4064455a8ad596b63b5e595c16afa844ffcddc90e56a
7
+ data.tar.gz: 1cb76ea316682fc4a4394d27ad252cc67496e95fa9034ba7054ad6e9b472a211f78cb1c839c9f4c745b143804c04aef5c85616c4f6f344f378e19bf12420db53
data/README.md CHANGED
@@ -118,6 +118,19 @@ redirect_to zaikio_oauth_client.new_session_path(force_login: true)
118
118
  redirect_to zaikio_oauth_client.new_session_path(state: "something-my-app-uses")
119
119
  ```
120
120
 
121
+ You can also send them to the [Subscription Redirect
122
+ flow](https://docs.zaikio.com/api/directory/guides/subscriptions/redirect-flow/), which
123
+ behaves & redirects back like a regular Organization flow except it additionally sets up a
124
+ subscription for the organization:
125
+
126
+ ```ruby
127
+ # Require them to select a plan themselves...
128
+ redirect_to zaikio_oauth_client.new_subscription_path
129
+
130
+ # Or preselect a plan for them
131
+ redirect_to zaikio_oauth_client.new_subscription_path(plan: "free")
132
+ ```
133
+
121
134
  #### Session handling
122
135
 
123
136
  The Zaikio gem engine will set a cookie for the user after a successful OAuth flow: `cookies.encrypted[:zaikio_person_id]`.
@@ -254,7 +267,7 @@ To release a new version of the gem:
254
267
  - Update the version in `lib/zaikio/oauth_client/version.rb`
255
268
  - Update `CHANGELOG.md` to include the new version and its release date
256
269
  - Commit and push your changes
257
- - Create a [new release on GitHub](https://github.com/zaikio/zaikio-directory-models/releases/new)
270
+ - Create a [new release on GitHub](https://github.com/zaikio/zaikio-oauth_client/releases/new)
258
271
  - CircleCI will build the Gem package and push it Rubygems for you
259
272
 
260
273
  ## License
@@ -0,0 +1,20 @@
1
+ module Zaikio
2
+ module OAuthClient
3
+ class SubscriptionsController < ConnectionsController
4
+ def new
5
+ opts = params.permit(:client_name, :state, :plan)
6
+ client_name = opts.delete(:client_name)
7
+ plan = opts.delete(:plan)
8
+
9
+ subscription_scope = "Org.subscription_create"
10
+ subscription_scope << ".#{plan}" if plan.present?
11
+
12
+ redirect_to oauth_client.auth_code.authorize_url(
13
+ redirect_uri: approve_url(client_name),
14
+ scope: subscription_scope,
15
+ **opts
16
+ )
17
+ end
18
+ end
19
+ end
20
+ end
data/config/routes.rb CHANGED
@@ -1,15 +1,17 @@
1
1
  Zaikio::OAuthClient::Engine.routes.draw do
2
- sessions_controller = Zaikio::OAuthClient.configuration.sessions_controller_name
3
- connections_controller = Zaikio::OAuthClient.configuration.connections_controller_name
2
+ config = Zaikio::OAuthClient.configuration
4
3
 
5
- # People
6
- get "(/:client_name)/sessions/new", action: :new, controller: sessions_controller, as: :new_session
7
- get "(/:client_name)/sessions/approve", action: :approve, controller: sessions_controller, as: :approve_session
8
- delete "(/:client_name)/session", action: :destroy, controller: sessions_controller, as: :session
4
+ scope path: "(/:client_name)" do
5
+ # People
6
+ get "/sessions/new", action: :new, controller: config.sessions_controller_name, as: :new_session
7
+ get "/sessions/approve", action: :approve, controller: config.sessions_controller_name, as: :approve_session
8
+ delete "/session", action: :destroy, controller: config.sessions_controller_name, as: :session
9
9
 
10
- # Organizations
11
- get "(/:client_name)/connections/new", action: :new,
12
- controller: connections_controller, as: :new_connection
13
- get "(/:client_name)/connections/approve", action: :approve,
14
- controller: connections_controller, as: :approve_connection
10
+ # Organizations
11
+ get "/connections/new", action: :new, controller: config.connections_controller_name, as: :new_connection
12
+ get "/connections/approve", action: :approve, controller: config.connections_controller_name, as: :approve_connection
13
+
14
+ # Subscriptions
15
+ get "/subscriptions/new", action: :new, controller: config.subscriptions_controller_name, as: :new_subscription
16
+ end
15
17
  end
@@ -15,13 +15,14 @@ module Zaikio
15
15
  attr_accessor :host
16
16
  attr_writer :logger
17
17
  attr_reader :client_configurations, :environment, :around_auth_block,
18
- :sessions_controller_name, :connections_controller_name
18
+ :sessions_controller_name, :connections_controller_name, :subscriptions_controller_name
19
19
 
20
20
  def initialize
21
21
  @client_configurations = {}
22
22
  @around_auth_block = nil
23
23
  @sessions_controller_name = "sessions"
24
24
  @connections_controller_name = "connections"
25
+ @subscriptions_controller_name = "subscriptions"
25
26
  end
26
27
 
27
28
  def logger
@@ -58,6 +59,10 @@ module Zaikio
58
59
  @connections_controller_name = "/#{name}"
59
60
  end
60
61
 
62
+ def subscriptions_controller_name=(name)
63
+ @subscriptions_controller_name = "/#{name}"
64
+ end
65
+
61
66
  private
62
67
 
63
68
  def host_for(environment)
@@ -1,5 +1,5 @@
1
1
  module Zaikio
2
2
  module OAuthClient
3
- VERSION = "0.8.1".freeze
3
+ VERSION = "0.9.0".freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zaikio-oauth_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.1
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zaikio GmbH
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-03-31 00:00:00.000000000 Z
11
+ date: 2021-04-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionpack
@@ -144,6 +144,7 @@ files:
144
144
  - Rakefile
145
145
  - app/controllers/zaikio/oauth_client/connections_controller.rb
146
146
  - app/controllers/zaikio/oauth_client/sessions_controller.rb
147
+ - app/controllers/zaikio/oauth_client/subscriptions_controller.rb
147
148
  - app/helpers/zaikio/application_helper.rb
148
149
  - app/jobs/zaikio/application_job.rb
149
150
  - app/jobs/zaikio/cleanup_access_tokens_job.rb