workos 0.9.1 → 0.10.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.
Files changed (31) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +4 -0
  3. data/Gemfile.lock +2 -2
  4. data/README.md +15 -15
  5. data/docs/WorkOS/SSO.html +235 -235
  6. data/docs/file.README.html +20 -20
  7. data/lib/workos/audit_trail.rb +1 -0
  8. data/lib/workos/client.rb +22 -1
  9. data/lib/workos/connection.rb +0 -2
  10. data/lib/workos/organization.rb +0 -2
  11. data/lib/workos/passwordless.rb +0 -2
  12. data/lib/workos/portal.rb +0 -6
  13. data/lib/workos/profile.rb +2 -4
  14. data/lib/workos/sso.rb +119 -13
  15. data/lib/workos/version.rb +1 -1
  16. data/lib/workos.rb +1 -0
  17. data/spec/lib/workos/sso_spec.rb +198 -7
  18. data/spec/support/fixtures/vcr_cassettes/audit_trail/get_events.yml +2 -2
  19. data/spec/support/fixtures/vcr_cassettes/directory_sync/list_directories.yml +1 -1
  20. data/spec/support/fixtures/vcr_cassettes/directory_sync/list_directories_with_domain_param.yml +1 -1
  21. data/spec/support/fixtures/vcr_cassettes/sso/delete_connection_with_invalid_id.yml +72 -0
  22. data/spec/support/fixtures/vcr_cassettes/sso/delete_connection_with_valid_id.yml +70 -0
  23. data/spec/support/fixtures/vcr_cassettes/sso/get_connection_with_invalid_id.yml +72 -0
  24. data/spec/support/fixtures/vcr_cassettes/sso/get_connection_with_valid_id.yml +74 -0
  25. data/spec/support/fixtures/vcr_cassettes/sso/list_connections.yml +72 -0
  26. data/spec/support/fixtures/vcr_cassettes/sso/list_connections_with_after_param.yml +72 -0
  27. data/spec/support/fixtures/vcr_cassettes/sso/list_connections_with_before_param.yml +73 -0
  28. data/spec/support/fixtures/vcr_cassettes/sso/list_connections_with_connection_type_param.yml +72 -0
  29. data/spec/support/fixtures/vcr_cassettes/sso/list_connections_with_domain_param.yml +72 -0
  30. data/spec/support/fixtures/vcr_cassettes/sso/list_connections_with_limit_param.yml +72 -0
  31. metadata +23 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: aa4a3df1bd438866ffdd87bea0cc2b4c0155a1a72073f22265335845711e0b07
4
- data.tar.gz: e0330ab1c70938e2092f76102aa62559574a20dce5e9b6d3443c1c80792c82b7
3
+ metadata.gz: 72c11606b98be63db5dab6a2c68eb69cab12ce9f9afe20b73475ce6948b24794
4
+ data.tar.gz: c7ea54043041810b71e2390b3efe20152870d8617da9a48a9922c775fb01f5d4
5
5
  SHA512:
6
- metadata.gz: c1e6953bd43faa02ba0f0a7e8e6fe192a05b68d6a5694f6a448a6da7d419a9adb409a7512b3a7a95caf8ba630cb56d9eb0a52cb5d32f7afc0205dcc4e7b80434
7
- data.tar.gz: 3ff44f67cbe7f1fa8151d08579ee1e997d30d222b0c72d666a5d0cca21817a2201c97a1780aefe2965dcb20f42640cce71827e6092375eff87fbb114eed2cc0e
6
+ metadata.gz: 8721f09bdcabce0772ffd6218b11859bbbdddb096f7d85c1b56b1f1b28816b8e2d86ef45838311e37c5c7bb322ffb2836d4ff355d8268ee15bbfcded71f1f658
7
+ data.tar.gz: 74b8126bedbd7c2f36da24376af99f2502d5ba3ac062c9067515d1fa6c5c402684ae0c6a3d2cfa42ee0ea61cbf75329b861a6362aa8fd7af361e58f8fff0604d
data/.rubocop.yml CHANGED
@@ -10,8 +10,12 @@ Layout/LineLength:
10
10
  - '(\A|\s)/.*?/'
11
11
  Metrics/BlockLength:
12
12
  ExcludedMethods: ['describe', 'context']
13
+ Metrics/MethodLength:
14
+ Max: 15
13
15
  Metrics/ModuleLength:
14
16
  Max: 150
17
+ Metrics/ParameterLists:
18
+ Max: 6
15
19
  Style/TrailingCommaInArguments:
16
20
  EnforcedStyleForMultiline: 'consistent_comma'
17
21
  Style/TrailingCommaInHashLiteral:
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- workos (0.9.1)
4
+ workos (0.10.0)
5
5
  sorbet-runtime (~> 0.5)
6
6
 
7
7
  GEM
@@ -54,7 +54,7 @@ GEM
54
54
  simplecov-html (0.12.2)
55
55
  sorbet (0.5.5560)
56
56
  sorbet-static (= 0.5.5560)
57
- sorbet-runtime (0.5.5943)
57
+ sorbet-runtime (0.5.6189)
58
58
  sorbet-static (0.5.5560-universal-darwin-14)
59
59
  unicode-display_width (1.6.0)
60
60
  vcr (5.0.0)
data/README.md CHANGED
@@ -53,7 +53,7 @@ using the `WorkOS::SSO.get_profile` method.
53
53
  See our Ruby SSO example app for a [complete example](https://github.com/workos-inc/ruby-sso-example).
54
54
 
55
55
  ```ruby
56
- WorkOS::SSO.authorization_url(domain:, project_id:, redirect_uri:, state: {})
56
+ WorkOS::SSO.authorization_url(domain:, client_id:, redirect_uri:, state: {})
57
57
  ```
58
58
 
59
59
  > Generate an authorization URL to intitiate the WorkOS OAuth2 workflow.
@@ -61,25 +61,25 @@ WorkOS::SSO.authorization_url(domain:, project_id:, redirect_uri:, state: {})
61
61
  `WorkOS::SSO.authorization_url` accepts four arguments:
62
62
 
63
63
  - `domain` (string) — the authenticating user's company domain, without protocol (ex. `example.com`)
64
- - `project_id` (string) — your application's WorkOS [Project ID](https://dashboard.workos.com/sso/configuration) (ex. `project_01JG3BCPTRTSTTWQR4VSHXGWCQ`)
64
+ - `client_id` (string) — your application's WorkOS [Client ID](https://dashboard.workos.com/sso/configuration) (ex. `project_01JG3BCPTRTSTTWQR4VSHXGWCQ`)
65
65
  - `state` (optional, hash) — an optional hash used to manage state across authorization transactions (ex. `{ next_page: '/docs'}`)
66
- - `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.
66
+ - `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 environment on your WorkOS dashboard.
67
67
 
68
68
  This method will return an OAuth2 query string of the form:
69
69
 
70
- `https://${domain}/sso/authorize?response_type=code&client_id=${projectID}&redirect_uri=${redirectURI}&state=${state}`
70
+ `https://${domain}/sso/authorize?response_type=code&client_id=${clientID}&redirect_uri=${redirectURI}&state=${state}`
71
71
 
72
72
  For example, when used in a [Sinatra app](http://sinatrarb.com/):
73
73
 
74
74
  ```ruby
75
75
  DOMAIN = 'example.com'
76
- PROJECT_ID = '{projectId}'
76
+ CLIENT_ID = '{clientId}'
77
77
  REDIRECT_URI = 'http://localhost:4567/callback'
78
78
 
79
79
  get '/auth' do
80
80
  authorization_url = WorkOS::SSO.authorization_url(
81
81
  domain: DOMAIN,
82
- project_id: PROJECT_ID,
82
+ client_id: CLIENT_ID,
83
83
  redirect_uri: REDIRECT_URI,
84
84
  )
85
85
 
@@ -89,14 +89,14 @@ end
89
89
 
90
90
  The user would be redirected to:
91
91
 
92
- `https://api.workos.com/sso/authorize?response_type=code&client_id={projectID}&redirect_uri=http://localhost:4567/callback`
92
+ `https://api.workos.com/sso/authorize?response_type=code&client_id={clientID}&redirect_uri=http://localhost:4567/callback`
93
93
 
94
94
  WorkOS takes over from here, sending the user to authenticate with their IDP, and on successful login, returns
95
95
  the user to your callback URL with a `code` parameter. You'll use `WorkOS::SSO.profile` to exchange the
96
96
  code for a `WorkOS::Profile`.
97
97
 
98
98
  ```ruby
99
- WorkOS::SSO.profile(code:, project_id:)
99
+ WorkOS::SSO.profile(code:, client_id:)
100
100
  ```
101
101
 
102
102
  > Fetch a WorkOS::Profile for an authorized user.
@@ -104,7 +104,7 @@ WorkOS::SSO.profile(code:, project_id:)
104
104
  `WorkOS::SSO.profile` accepts two arguments:
105
105
 
106
106
  - `code` (string) — an opaque string provided by the authorization server; will be exchanged for an Access Token when the user's profile is sent
107
- - `project_id` (string) — your application's WorkOS [Project ID](https://dashboard.workos.com/sso/configuration) (ex. `project_01JG3BCPTRTSTTWQR4VSHXGWCQ`)
107
+ - `client_id` (string) — your application's WorkOS [Client ID](https://dashboard.workos.com/sso/configuration) (ex. `project_01JG3BCPTRTSTTWQR4VSHXGWCQ`)
108
108
 
109
109
  This method will return an instance of a `WorkOS::Profile` with the following attributes:
110
110
 
@@ -131,13 +131,13 @@ Our Sinatra app can be extended to use this method:
131
131
 
132
132
  ```ruby
133
133
  DOMAIN = 'example.com'
134
- PROJECT_ID = '{projectId}'
134
+ CLIENT_ID = '{clientId}'
135
135
  REDIRECT_URI = 'http://localhost:4567/callback'
136
136
 
137
137
  get '/auth' do
138
138
  authorization_url = WorkOS::SSO.authorization_url(
139
139
  domain: DOMAIN,
140
- project_id: PROJECT_ID,
140
+ client_id: CLIENT_ID,
141
141
  redirect_uri: REDIRECT_URI,
142
142
  )
143
143
 
@@ -147,7 +147,7 @@ end
147
147
  get '/callback' do
148
148
  profile = WorkOS::SSO.profile(
149
149
  code: params['code'],
150
- project_id: PROJECT_ID,
150
+ client_id: CLIENT_ID,
151
151
  )
152
152
 
153
153
  session[:user] = profile.to_json
@@ -173,7 +173,7 @@ The user can then click on that link to be authenticated to your application.
173
173
  - `email` (string) - the email of the user to authenticate.
174
174
  - `type` (string) - The type of Passwordless Session to create. Currently, the only supported value is `MagicLink`.
175
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.
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 environment on your WorkOS dashboard.
177
177
 
178
178
  This method will return a Passwordless Session object, containing the following attributes:
179
179
 
@@ -195,7 +195,7 @@ This method will return a boolean confirming the Magic Link was sent.
195
195
  Our Sinatra app can be altered to use Magic Link:
196
196
 
197
197
  ```ruby
198
- PROJECT_ID = '{projectId}'
198
+ CLIENT_ID = '{clientId}'
199
199
  REDIRECT_URI = 'http://localhost:4567/callback'
200
200
 
201
201
  post '/passwordless-auth' do
@@ -212,7 +212,7 @@ end
212
212
  get '/callback' do
213
213
  profile = WorkOS::SSO.profile(
214
214
  code: params['code'],
215
- project_id: PROJECT_ID,
215
+ client_id: CLIENT_ID,
216
216
  )
217
217
 
218
218
  session[:user] = profile.to_json