workos 0.9.0 → 0.9.1
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/.github/CODEOWNERS +5 -0
- data/Gemfile.lock +1 -1
- data/README.md +107 -44
- data/lib/workos/passwordless.rb +3 -0
- data/lib/workos/version.rb +1 -1
- data/spec/lib/workos/passwordless_spec.rb +1 -0
- metadata +3 -3
- data/CODEOWNERS +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aa4a3df1bd438866ffdd87bea0cc2b4c0155a1a72073f22265335845711e0b07
|
4
|
+
data.tar.gz: e0330ab1c70938e2092f76102aa62559574a20dce5e9b6d3443c1c80792c82b7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c1e6953bd43faa02ba0f0a7e8e6fe192a05b68d6a5694f6a448a6da7d419a9adb409a7512b3a7a95caf8ba630cb56d9eb0a52cb5d32f7afc0205dcc4e7b80434
|
7
|
+
data.tar.gz: 3ff44f67cbe7f1fa8151d08579ee1e997d30d222b0c72d666a5d0cca21817a2201c97a1780aefe2965dcb20f42640cce71827e6092375eff87fbb114eed2cc0e
|
data/.github/CODEOWNERS
ADDED
data/Gemfile.lock
CHANGED
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
|
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:)
|
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
|
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.
|
data/lib/workos/passwordless.rb
CHANGED
@@ -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
|
data/lib/workos/version.rb
CHANGED
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.
|
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-
|
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
|