workos 0.9.0 → 0.9.1

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
  SHA256:
3
- metadata.gz: 9fd3e38d33d428497a46f40df28c4d142bc9adaf90c166b61c05914030c50b25
4
- data.tar.gz: c445aa218658fe1fb57add7cc9081b1e63223641d29cac1e276429d3fb1244fd
3
+ metadata.gz: aa4a3df1bd438866ffdd87bea0cc2b4c0155a1a72073f22265335845711e0b07
4
+ data.tar.gz: e0330ab1c70938e2092f76102aa62559574a20dce5e9b6d3443c1c80792c82b7
5
5
  SHA512:
6
- metadata.gz: b94cf0c103286a457c3a73ab4ead5196ad2a8111f486ff22adbf4ecbdd5a21685dcb9483325b15813dcd5a25ea2383aec7d64fbc7545d4c80267731e97ed4a48
7
- data.tar.gz: 30d4256a4b9218890dd880a5513dd90a09052f746085dffc282532bbf9ed5683b04d690181cfe1b209f02edc1fd1e37e04149819c8731afb81f5aba5561a2c18
6
+ metadata.gz: c1e6953bd43faa02ba0f0a7e8e6fe192a05b68d6a5694f6a448a6da7d419a9adb409a7512b3a7a95caf8ba630cb56d9eb0a52cb5d32f7afc0205dcc4e7b80434
7
+ data.tar.gz: 3ff44f67cbe7f1fa8151d08579ee1e997d30d222b0c72d666a5d0cca21817a2201c97a1780aefe2965dcb20f42640cce71827e6092375eff87fbb114eed2cc0e
@@ -0,0 +1,5 @@
1
+ # See GitHub's docs for more details:
2
+ # https://help.github.com/en/github/creating-cloning-and-archiving-repositories/about-code-owners
3
+
4
+ # Rubyist Team
5
+ * @workos-inc/ruby
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- workos (0.9.0)
4
+ workos (0.9.1)
5
5
  sorbet-runtime (~> 0.5)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -42,50 +42,9 @@ Alternatively, you may set the key yourself, such as in an initializer in your a
42
42
  WorkOS.key = '[your api key]'
43
43
  ```
44
44
 
45
- ## The Audit Trail Module
46
-
47
- The Audit Trail Module provides methods for creating Audit Trail events on
48
- WorkOS.
49
-
50
- See our [Audit Trail
51
- Overview](https://docs.workos.com/audit-trail/overview) for
52
- more information.
53
-
54
- ```ruby
55
- payload = {
56
- group: 'Foo Corp',
57
- location: '127.0.0.1',
58
- action: 'user.created',
59
- action_type: 'C',
60
- actor_name: 'Foo',
61
- actor_id: 'user_12345',
62
- target_name: 'Bar',
63
- target_id: 'user_67890',
64
- occurred_at: '2020-01-10T15:30:00-05:00',
65
- metadata: {
66
- source: 'Email',
67
- }
68
- }
69
-
70
- WorkOS::AuditTrail.create_event(event: payload)
71
- ```
72
-
73
- ### Idempotency
74
-
75
- To perform an idempotent request, provide an additional idempotency_key
76
- parameter to the `create_event` options.
77
-
78
- ```ruby
79
- WorkOS::AuditTrail.create_event(event: payload, idempotency_key: 'key123456')
80
- ```
81
-
82
- See our [API
83
- Reference](https://docs.workos.com/audit-trail/api-reference#idempotency)
84
- for more information on idempotency keys.
85
-
86
45
  ## The SSO Module
87
46
 
88
- The SSO Module provides convenience methods for authenticating a Single Sign On (SSO) user via WorkOS. WorkOS SSO follows the Oauth 2.0 specification.
47
+ The SSO Module provides convenient methods for authenticating a Single Sign On (SSO) user via WorkOS. WorkOS SSO follows the OAuth 2.0 specification.
89
48
 
90
49
  First, you'll direct your SSO users to an `authorization_url`. They will sign in to their SSO account with their Identity Provider, and be redirected to a
91
50
  callback URL that you set in your WorkOS Dashboard. The user will be redirected with a `code` URL parameter, which you can then exchange for a WorkOS::Profile
@@ -137,7 +96,7 @@ the user to your callback URL with a `code` parameter. You'll use `WorkOS::SSO.p
137
96
  code for a `WorkOS::Profile`.
138
97
 
139
98
  ```ruby
140
- WorkOS::SSO.profile(code:, project_id:)</h4>
99
+ WorkOS::SSO.profile(code:, project_id:)
141
100
  ```
142
101
 
143
102
  > Fetch a WorkOS::Profile for an authorized user.
@@ -168,7 +127,7 @@ This method will return an instance of a `WorkOS::Profile` with the following at
168
127
  >
169
128
  ```
170
129
 
171
- Our Sintatra app can be extended to use this method:
130
+ Our Sinatra app can be extended to use this method:
172
131
 
173
132
  ```ruby
174
133
  DOMAIN = 'example.com'
@@ -198,3 +157,107 @@ end
198
157
  ```
199
158
 
200
159
  Given the `WorkOS::Profile`, you can now sign the user in according to your own authentication setup.
160
+
161
+ ## The Magic Link Module
162
+
163
+ The Magic Link Module provides methods for authenticating a Passwordless user via WorkOS.
164
+
165
+ First, you'll create a Passwordless Session for a Magic Link connection.
166
+ Then, using the session ID, you'll email a user the Magic Link confirmation URL.
167
+ The user can then click on that link to be authenticated to your application.
168
+
169
+ > Create a Passwordless Session for a Magic Link Connection.
170
+
171
+ `WorkOS::Passwordless.create_session` accepts four arguments:
172
+
173
+ - `email` (string) - the email of the user to authenticate.
174
+ - `type` (string) - The type of Passwordless Session to create. Currently, the only supported value is `MagicLink`.
175
+ - `state` (optional, string) - Optional parameter that a Developer can choose to include in their authorization URL. If included, then the redirect URI received from WorkOS will contain the exact `state` that was passed in the authorization URL.
176
+ - `redirect_uri` (string) - a callback URL where your application redirects the user-agent after an authorization code is granted (ex. `workos.dev/callback`). This must match one of your configured callback URLs for the associated project on your WorkOS dashboard.
177
+
178
+ This method will return a Passwordless Session object, containing the following attributes:
179
+
180
+ - `id` (string) - the unique ID of the session.
181
+ - `email` (string) - the email address of the user for the session.
182
+ - `expires_at` (date) - the ISO-8601 datetime at which the session expires.
183
+ - `link` (string) - the link for the user to authenticate with. You can use this link to send a custom email to the user, or send an email using the `WorkOS::Passwordless.send_session` method, described below.
184
+
185
+ > Email a user the Magic Link confirmation URL.
186
+
187
+ `WorkOS::Passwordless.send_session` accepts one argument:
188
+
189
+ - `id` (string) - the unique identifier of the Passwordless Session to send an email for.
190
+
191
+ This method will return a boolean confirming the Magic Link was sent.
192
+
193
+ > Example with Sinatra application
194
+
195
+ Our Sinatra app can be altered to use Magic Link:
196
+
197
+ ```ruby
198
+ PROJECT_ID = '{projectId}'
199
+ REDIRECT_URI = 'http://localhost:4567/callback'
200
+
201
+ post '/passwordless-auth' do
202
+ session = WorkOS::Passwordless.create_session(
203
+ email: params[:email],
204
+ type: 'MagicLink',
205
+ redirect_uri: REDIRECT_URI
206
+ )
207
+ WorkOS::Passwordless.send_session(session.id)
208
+
209
+ redirect '/check-email'
210
+ end
211
+
212
+ get '/callback' do
213
+ profile = WorkOS::SSO.profile(
214
+ code: params['code'],
215
+ project_id: PROJECT_ID,
216
+ )
217
+
218
+ session[:user] = profile.to_json
219
+
220
+ redirect '/'
221
+ end
222
+ ```
223
+
224
+ ## The Audit Trail Module
225
+
226
+ The Audit Trail Module provides methods for creating Audit Trail events on
227
+ WorkOS.
228
+
229
+ See our [Audit Trail
230
+ Overview](https://docs.workos.com/audit-trail/overview) for
231
+ more information.
232
+
233
+ ```ruby
234
+ payload = {
235
+ group: 'Foo Corp',
236
+ location: '127.0.0.1',
237
+ action: 'user.created',
238
+ action_type: 'C',
239
+ actor_name: 'Foo',
240
+ actor_id: 'user_12345',
241
+ target_name: 'Bar',
242
+ target_id: 'user_67890',
243
+ occurred_at: '2020-01-10T15:30:00-05:00',
244
+ metadata: {
245
+ source: 'Email',
246
+ }
247
+ }
248
+
249
+ WorkOS::AuditTrail.create_event(event: payload)
250
+ ```
251
+
252
+ ### Idempotency
253
+
254
+ To perform an idempotent request, provide an additional idempotency_key
255
+ parameter to the `create_event` options.
256
+
257
+ ```ruby
258
+ WorkOS::AuditTrail.create_event(event: payload, idempotency_key: 'key123456')
259
+ ```
260
+
261
+ See our [API
262
+ Reference](https://docs.workos.com/audit-trail/api-reference#idempotency)
263
+ for more information on idempotency keys.
@@ -25,6 +25,9 @@ module WorkOS
25
25
  # redirects.
26
26
  # @option options [String] type The type of Passwordless Session to
27
27
  # create. Currently, the only supported value is 'MagicLink'.
28
+ # @option options [String] redirect_uri The URI where users are directed
29
+ # after completing the authentication step. Must match a
30
+ # configured redirect URI on your WorkOS dashboard.
28
31
  #
29
32
  # @return Hash
30
33
  sig do
@@ -2,5 +2,5 @@
2
2
  # typed: strong
3
3
 
4
4
  module WorkOS
5
- VERSION = '0.9.0'
5
+ VERSION = '0.9.1'
6
6
  end
@@ -16,6 +16,7 @@ describe WorkOS::Passwordless do
16
16
  {
17
17
  email: 'demo@workos-okta.com',
18
18
  type: 'MagicLink',
19
+ redirect_uri: 'foo.com/auth/callback',
19
20
  }
20
21
  end
21
22
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: workos
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - WorkOS
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-10-15 00:00:00.000000000 Z
11
+ date: 2020-12-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sorbet-runtime
@@ -161,6 +161,7 @@ executables:
161
161
  extensions: []
162
162
  extra_rdoc_files: []
163
163
  files:
164
+ - ".github/CODEOWNERS"
164
165
  - ".github/renovate.json"
165
166
  - ".gitignore"
166
167
  - ".rspec"
@@ -168,7 +169,6 @@ files:
168
169
  - ".ruby-version"
169
170
  - ".semaphore/rubygems.yml"
170
171
  - ".semaphore/semaphore.yml"
171
- - CODEOWNERS
172
172
  - Gemfile
173
173
  - Gemfile.lock
174
174
  - LICENSE
data/CODEOWNERS DELETED
@@ -1 +0,0 @@
1
- @marktran