workos 0.0.2 → 0.1.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 (79) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +5 -2
  3. data/Gemfile.lock +6 -2
  4. data/README.md +179 -8
  5. data/bin/docs +2 -2
  6. data/codecov.yml +1 -0
  7. data/docs/WorkOS.html +22 -26
  8. data/docs/WorkOS/APIError.html +160 -0
  9. data/docs/WorkOS/AuditLog.html +235 -0
  10. data/docs/WorkOS/AuthenticationError.html +160 -0
  11. data/docs/WorkOS/Base.html +27 -32
  12. data/docs/WorkOS/Client.html +493 -0
  13. data/docs/WorkOS/InvalidRequestError.html +160 -0
  14. data/docs/WorkOS/Profile.html +80 -17
  15. data/docs/WorkOS/RequestError.html +6 -6
  16. data/docs/WorkOS/SSO.html +118 -74
  17. data/docs/WorkOS/Types.html +9 -10
  18. data/docs/WorkOS/Types/ProfileStruct.html +6 -6
  19. data/docs/WorkOS/Types/Provider.html +135 -0
  20. data/docs/WorkOS/WorkOSError.html +447 -0
  21. data/docs/class_list.html +3 -3
  22. data/docs/css/style.css +2 -2
  23. data/docs/file.README.html +173 -13
  24. data/docs/file_list.html +2 -2
  25. data/docs/frames.html +2 -2
  26. data/docs/index.html +77 -16
  27. data/docs/js/app.js +14 -3
  28. data/docs/method_list.html +96 -8
  29. data/docs/top-level-namespace.html +6 -6
  30. data/lib/workos.rb +7 -2
  31. data/lib/workos/audit_log.rb +78 -0
  32. data/lib/workos/base.rb +5 -6
  33. data/lib/workos/client.rb +86 -0
  34. data/lib/workos/errors.rb +48 -0
  35. data/lib/workos/sso.rb +49 -27
  36. data/lib/workos/types.rb +2 -1
  37. data/lib/workos/types/provider_enum.rb +14 -0
  38. data/lib/workos/version.rb +2 -2
  39. data/sorbet/rbi/hidden-definitions/errors.txt +22108 -4368
  40. data/sorbet/rbi/hidden-definitions/hidden.rbi +32490 -6059
  41. data/sorbet/rbi/sorbet-typed/lib/rainbow/all/rainbow.rbi +1 -1
  42. data/sorbet/rbi/todo.rbi +5 -0
  43. data/spec/lib/workos/audit_log_spec.rb +140 -0
  44. data/spec/lib/workos/base_spec.rb +30 -0
  45. data/spec/lib/workos/sso_spec.rb +131 -36
  46. data/spec/spec_helper.rb +21 -1
  47. data/spec/support/fixtures/vcr_cassettes/audit_log/create_event.yml +65 -0
  48. data/spec/support/fixtures/vcr_cassettes/audit_log/create_event_custom_idempotency_key.yml +67 -0
  49. data/spec/support/fixtures/vcr_cassettes/audit_log/create_event_invalid.yml +68 -0
  50. data/spec/support/fixtures/vcr_cassettes/audit_log/create_events_duplicate_idempotency_key_and_payload.yml +131 -0
  51. data/spec/support/fixtures/vcr_cassettes/audit_log/create_events_duplicate_idempotency_key_different_payload.yml +134 -0
  52. data/spec/support/fixtures/vcr_cassettes/base/execute_request_unauthenticated.yml +66 -0
  53. data/workos.gemspec +2 -0
  54. metadata +57 -27
  55. data/lib/workos/request_error.rb +0 -5
  56. data/sorbet/rbi/gems/addressable.rbi +0 -198
  57. data/sorbet/rbi/gems/ast.rbi +0 -47
  58. data/sorbet/rbi/gems/codecov.rbi +0 -19
  59. data/sorbet/rbi/gems/crack.rbi +0 -47
  60. data/sorbet/rbi/gems/docile.rbi +0 -31
  61. data/sorbet/rbi/gems/hashdiff.rbi +0 -65
  62. data/sorbet/rbi/gems/jaro_winkler.rbi +0 -14
  63. data/sorbet/rbi/gems/parallel.rbi +0 -81
  64. data/sorbet/rbi/gems/parser.rbi +0 -856
  65. data/sorbet/rbi/gems/public_suffix.rbi +0 -102
  66. data/sorbet/rbi/gems/rack.rbi +0 -103
  67. data/sorbet/rbi/gems/rainbow.rbi +0 -117
  68. data/sorbet/rbi/gems/rake.rbi +0 -632
  69. data/sorbet/rbi/gems/rspec-core.rbi +0 -1661
  70. data/sorbet/rbi/gems/rspec-expectations.rbi +0 -388
  71. data/sorbet/rbi/gems/rspec-mocks.rbi +0 -823
  72. data/sorbet/rbi/gems/rspec-support.rbi +0 -266
  73. data/sorbet/rbi/gems/rspec.rbi +0 -14
  74. data/sorbet/rbi/gems/rubocop.rbi +0 -7083
  75. data/sorbet/rbi/gems/ruby-progressbar.rbi +0 -304
  76. data/sorbet/rbi/gems/simplecov-html.rbi +0 -30
  77. data/sorbet/rbi/gems/simplecov.rbi +0 -225
  78. data/sorbet/rbi/gems/unicode-display_width.rbi +0 -16
  79. data/sorbet/rbi/gems/webmock.rbi +0 -526
@@ -4,9 +4,9 @@
4
4
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
5
5
  <meta charset="utf-8" />
6
6
 
7
- <link rel="stylesheet" href="css/full_list.css" type="text/css" media="screen" charset="utf-8" />
7
+ <link rel="stylesheet" href="css/full_list.css" type="text/css" media="screen" />
8
8
 
9
- <link rel="stylesheet" href="css/common.css" type="text/css" media="screen" charset="utf-8" />
9
+ <link rel="stylesheet" href="css/common.css" type="text/css" media="screen" />
10
10
 
11
11
 
12
12
 
@@ -43,7 +43,7 @@
43
43
 
44
44
  <ul id="full_list" class="class">
45
45
  <li id="object_" class="odd"><div class="item" style="padding-left:30px"><span class='object_link'><a href="top-level-namespace.html" title="Top Level Namespace (root)">Top Level Namespace</a></span></div></li>
46
- <li id='object_WorkOS' class='even'><div class='item' style='padding-left:30px'><a class='toggle'></a> <span class='object_link'><a href="WorkOS.html" title="WorkOS (module)">WorkOS</a></span><small class='search_info'>Top Level Namespace</small></div><ul><li id='object_WorkOS::Base' class='collapsed odd'><div class='item' style='padding-left:45px'><span class='object_link'><a href="WorkOS/Base.html" title="WorkOS::Base (class)">Base</a></span> &lt; Object<small class='search_info'>WorkOS</small></div></li><li id='object_WorkOS::Profile' class='collapsed even'><div class='item' style='padding-left:45px'><span class='object_link'><a href="WorkOS/Profile.html" title="WorkOS::Profile (class)">Profile</a></span> &lt; Object<small class='search_info'>WorkOS</small></div></li><li id='object_WorkOS::RequestError' class='collapsed odd'><div class='item' style='padding-left:45px'><span class='object_link'><a href="WorkOS/RequestError.html" title="WorkOS::RequestError (class)">RequestError</a></span> &lt; StandardError<small class='search_info'>WorkOS</small></div></li><li id='object_WorkOS::SSO' class='collapsed even'><div class='item' style='padding-left:45px'><span class='object_link'><a href="WorkOS/SSO.html" title="WorkOS::SSO (module)">SSO</a></span><small class='search_info'>WorkOS</small></div></li><li id='object_WorkOS::Types' class='collapsed odd'><div class='item' style='padding-left:45px'><a class='toggle'></a> <span class='object_link'><a href="WorkOS/Types.html" title="WorkOS::Types (module)">Types</a></span><small class='search_info'>WorkOS</small></div><ul><li id='object_WorkOS::Types::ProfileStruct' class='collapsed'><div class='item' style='padding-left:60px'><span class='object_link'><a href="WorkOS/Types/ProfileStruct.html" title="WorkOS::Types::ProfileStruct (class)">ProfileStruct</a></span> &lt; Struct<small class='search_info'>WorkOS::Types</small></div></li></ul></li></ul></li>
46
+ <li id='object_WorkOS' class='even'><div class='item' style='padding-left:30px'><a class='toggle'></a> <span class='object_link'><a href="WorkOS.html" title="WorkOS (module)">WorkOS</a></span><small class='search_info'>Top Level Namespace</small></div><ul><li id='object_WorkOS::APIError' class='collapsed odd'><div class='item' style='padding-left:45px'><span class='object_link'><a href="WorkOS/APIError.html" title="WorkOS::APIError (class)">APIError</a></span> &lt; WorkOSError<small class='search_info'>WorkOS</small></div></li><li id='object_WorkOS::AuditLog' class='collapsed even'><div class='item' style='padding-left:45px'><span class='object_link'><a href="WorkOS/AuditLog.html" title="WorkOS::AuditLog (module)">AuditLog</a></span><small class='search_info'>WorkOS</small></div></li><li id='object_WorkOS::AuthenticationError' class='collapsed odd'><div class='item' style='padding-left:45px'><span class='object_link'><a href="WorkOS/AuthenticationError.html" title="WorkOS::AuthenticationError (class)">AuthenticationError</a></span> &lt; WorkOSError<small class='search_info'>WorkOS</small></div></li><li id='object_WorkOS::Base' class='collapsed even'><div class='item' style='padding-left:45px'><span class='object_link'><a href="WorkOS/Base.html" title="WorkOS::Base (module)">Base</a></span><small class='search_info'>WorkOS</small></div></li><li id='object_WorkOS::Client' class='collapsed odd'><div class='item' style='padding-left:45px'><span class='object_link'><a href="WorkOS/Client.html" title="WorkOS::Client (module)">Client</a></span><small class='search_info'>WorkOS</small></div></li><li id='object_WorkOS::InvalidRequestError' class='collapsed even'><div class='item' style='padding-left:45px'><span class='object_link'><a href="WorkOS/InvalidRequestError.html" title="WorkOS::InvalidRequestError (class)">InvalidRequestError</a></span> &lt; WorkOSError<small class='search_info'>WorkOS</small></div></li><li id='object_WorkOS::Profile' class='collapsed odd'><div class='item' style='padding-left:45px'><span class='object_link'><a href="WorkOS/Profile.html" title="WorkOS::Profile (class)">Profile</a></span> &lt; Object<small class='search_info'>WorkOS</small></div></li><li id='object_WorkOS::SSO' class='collapsed even'><div class='item' style='padding-left:45px'><span class='object_link'><a href="WorkOS/SSO.html" title="WorkOS::SSO (module)">SSO</a></span><small class='search_info'>WorkOS</small></div></li><li id='object_WorkOS::Types' class='collapsed odd'><div class='item' style='padding-left:45px'><a class='toggle'></a> <span class='object_link'><a href="WorkOS/Types.html" title="WorkOS::Types (module)">Types</a></span><small class='search_info'>WorkOS</small></div><ul><li id='object_WorkOS::Types::ProfileStruct' class='collapsed'><div class='item' style='padding-left:60px'><span class='object_link'><a href="WorkOS/Types/ProfileStruct.html" title="WorkOS::Types::ProfileStruct (class)">ProfileStruct</a></span> &lt; Struct<small class='search_info'>WorkOS::Types</small></div></li><li id='object_WorkOS::Types::Provider' class='collapsed'><div class='item' style='padding-left:60px'><span class='object_link'><a href="WorkOS/Types/Provider.html" title="WorkOS::Types::Provider (class)">Provider</a></span> &lt; Enum<small class='search_info'>WorkOS::Types</small></div></li></ul></li><li id='object_WorkOS::WorkOSError' class='collapsed even'><div class='item' style='padding-left:45px'><span class='object_link'><a href="WorkOS/WorkOSError.html" title="WorkOS::WorkOSError (class)">WorkOSError</a></span> &lt; StandardError<small class='search_info'>WorkOS</small></div></li></ul></li>
47
47
 
48
48
  </ul>
49
49
  </div>
@@ -422,8 +422,8 @@ li.r2 { background: #fafafa; }
422
422
  #toc ol { padding-left: 1.8em; }
423
423
  #toc li { font-size: 1.1em; line-height: 1.7em; }
424
424
  #toc > ol > li { font-size: 1.1em; font-weight: bold; }
425
- #toc ol > ol { font-size: 0.9em; }
426
- #toc ol ol > ol { padding-left: 2.3em; }
425
+ #toc ol > li > ol { font-size: 0.9em; }
426
+ #toc ol ol > li > ol { padding-left: 2.3em; }
427
427
  #toc ol + li { margin-top: 0.3em; }
428
428
  #toc.hidden { padding: 10px; background: #fefefe; box-shadow: none; }
429
429
  #toc.hidden:hover { background: #fafafa; }
@@ -6,15 +6,15 @@
6
6
  <title>
7
7
  File: README
8
8
 
9
- &mdash; Documentation by YARD 0.9.20
9
+ &mdash; Documentation by YARD 0.9.22
10
10
 
11
11
  </title>
12
12
 
13
- <link rel="stylesheet" href="css/style.css" type="text/css" charset="utf-8" />
13
+ <link rel="stylesheet" href="css/style.css" type="text/css" />
14
14
 
15
- <link rel="stylesheet" href="css/common.css" type="text/css" charset="utf-8" />
15
+ <link rel="stylesheet" href="css/common.css" type="text/css" />
16
16
 
17
- <script type="text/javascript" charset="utf-8">
17
+ <script type="text/javascript">
18
18
  pathId = "README";
19
19
  relpath = '';
20
20
  </script>
@@ -58,33 +58,193 @@
58
58
  </div>
59
59
 
60
60
  <div id="content"><div id='filecontents'>
61
- <h1 id="label-workos-rb">workos-rb</h1>
61
+ <h1 id="label-workos-ruby+rdoc-image-3Ahttps-3A-2F-2Fcodecov.io-2Fgh-2Fworkos-inc-2Fworkos-ruby-2Fbranch-2Fmaster-2Fgraph-2Fbadge.svg">workos-ruby <a href="https://codecov.io/gh/workos-inc/workos-ruby"><img src="https://codecov.io/gh/workos-inc/workos-ruby/branch/master/graph/badge.svg"></a></h1>
62
62
 
63
63
  <p>WorkOS official Ruby gem for interacting with WorkOS APIs</p>
64
64
 
65
+ <h2 id="label-Documentation">Documentation</h2>
66
+
67
+ <p>Complete documentation for the latest version of WorkOS Ruby Gem can be found <a href="https://workos-inc.github.io/workos-ruby/">here</a>.</p>
68
+
65
69
  <h2 id="label-Installation">Installation</h2>
66
70
 
67
- <p>You don&#39;t need this source code unless you want to modify the gem. If
68
- you just want to use the package, just run:</p>
71
+ <p>To get started, you can install the WorkOS gem via RubyGems with:</p>
69
72
 
70
73
  <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_gem'>gem</span> <span class='id identifier rubyid_install'>install</span> <span class='id identifier rubyid_workos'>workos</span>
71
74
  </code></pre>
72
75
 
73
- <p>If you want to build the gem from source:</p>
76
+ <p>If you&#39;re using Bundler to manage your application&#39;s gems, add the WorkOS gem to your Gemfile:</p>
77
+
78
+ <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_source'>source</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>https://rubygems.org</span><span class='tstring_end'>&#39;</span></span>
79
+
80
+ <span class='id identifier rubyid_gem'>gem</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>workos</span><span class='tstring_end'>&#39;</span></span>
81
+ </code></pre>
82
+
83
+ <h2 id="label-Configuration">Configuration</h2>
84
+
85
+ <p>To use the SDK you must first provide your API key from the <a href="https://dashboard.workos.com/api-keys">WorkOS Developer Dashboard</a>.</p>
86
+
87
+ <p>You can do this through the <code>WORKOS_KEY</code> environment variable or by calling <code>WorkOS.key = [your API key]</code>.</p>
88
+
89
+ <p>The WorkOS Gem will read the environment variable <code>WORKOS_KEY</code>:</p>
90
+
91
+ <pre class="code ruby"><code class="ruby">$ WORKOS_KEY=[your api key] ruby app.rb
92
+ </code></pre>
93
+
94
+ <p>Alternatively, you may set the key yourself, such as in an initializer in your application load path:</p>
95
+
96
+ <pre class="code ruby"><code class="ruby"><span class='comment'># /config/initializers/workos.rb
97
+ </span>
98
+ <span class='const'><span class='object_link'><a href="WorkOS.html" title="WorkOS (module)">WorkOS</a></span></span><span class='period'>.</span><span class='id identifier rubyid_key'><span class='object_link'><a href="WorkOS.html#key-class_method" title="WorkOS.key (method)">key</a></span></span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>[your api key]</span><span class='tstring_end'>&#39;</span></span>
99
+ </code></pre>
100
+
101
+ <h2 id="label-The+Audit+Log+Module">The Audit Log Module</h2>
102
+
103
+ <p>The Audit Log Module provides methods for creating Audit Log events on WorkOS.</p>
104
+
105
+ <p>See our <a href="https://dashboard.workos.com/docs/audit-log/quickstart">Audit Log Quickstart</a> for more information.</p>
106
+
107
+ <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_payload'>payload</span> <span class='op'>=</span> <span class='lbrace'>{</span>
108
+ <span class='label'>group:</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>Foo Corp</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span>
109
+ <span class='label'>location:</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>127.0.0.1</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span>
110
+ <span class='label'>action:</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>user.created</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span>
111
+ <span class='label'>action_type:</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>C</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span>
112
+ <span class='label'>actor_name:</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>Foo</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span>
113
+ <span class='label'>actor_id:</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>user_12345</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span>
114
+ <span class='label'>target_name:</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>Bar</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span>
115
+ <span class='label'>target_id:</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>user_67890</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span>
116
+ <span class='label'>occurred_at:</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>2020-01-10T15:30:00-05:00</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span>
117
+ <span class='label'>metadata:</span> <span class='lbrace'>{</span>
118
+ <span class='label'>source:</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>Email</span><span class='tstring_end'>&#39;</span></span><span class='comma'>,</span>
119
+ <span class='rbrace'>}</span>
120
+ <span class='rbrace'>}</span>
121
+
122
+ <span class='const'><span class='object_link'><a href="WorkOS.html" title="WorkOS (module)">WorkOS</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="WorkOS/AuditLog.html" title="WorkOS::AuditLog (module)">AuditLog</a></span></span><span class='period'>.</span><span class='id identifier rubyid_create_event'><span class='object_link'><a href="WorkOS/AuditLog.html#create_event-class_method" title="WorkOS::AuditLog.create_event (method)">create_event</a></span></span><span class='lparen'>(</span><span class='label'>event:</span> <span class='id identifier rubyid_payload'>payload</span><span class='rparen'>)</span>
123
+ </code></pre>
124
+
125
+ <h3 id="label-Idempotency">Idempotency</h3>
126
+
127
+ <p>To perform an idempotent request, provide an additional idempotency_key parameter to the <code>create_event</code> options.</p>
128
+
129
+ <pre class="code ruby"><code class="ruby"><span class='const'><span class='object_link'><a href="WorkOS.html" title="WorkOS (module)">WorkOS</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="WorkOS/AuditLog.html" title="WorkOS::AuditLog (module)">AuditLog</a></span></span><span class='period'>.</span><span class='id identifier rubyid_create_event'><span class='object_link'><a href="WorkOS/AuditLog.html#create_event-class_method" title="WorkOS::AuditLog.create_event (method)">create_event</a></span></span><span class='lparen'>(</span><span class='label'>event:</span> <span class='id identifier rubyid_payload'>payload</span><span class='comma'>,</span> <span class='label'>idempotency_key:</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>key123456</span><span class='tstring_end'>&#39;</span></span><span class='rparen'>)</span>
130
+ </code></pre>
131
+
132
+ <p>See our <a href="https://dashboard.workos.com/docs/api-reference#idempotency">API Reference</a> for more information on idempotency keys.</p>
133
+
134
+ <h2 id="label-The+SSO+Module">The SSO Module</h2>
135
+
136
+ <p>The SSO Module provides convenience methods for authenticating a Single Sign On (SSO) user via WorkOS. WorkOS SSO follows the Oauth 2.0 specification.</p>
137
+
138
+ <p>First, you&#39;ll direct your SSO users to an <code>authorization_url</code>. They will sign in to their SSO account with their Identity Provider, and be redirected to a callback URL that you set in your WorkOS Dashboard. The user will be redirected with a <code>code</code> URL parameter, which you can then exchange for a WorkOS::Profile using the <code>WorkOS::SSO.get_profile</code> method.</p>
139
+
140
+ <p>See our Ruby SSO example app for a <a href="https://github.com/workos-inc/ruby-sso-example">complete example</a>.</p>
141
+
142
+ <pre class="code ruby"><code class="ruby">WorkOS::SSO.authorization_url(domain:, project_id:, redirect_uri:, state: {})
143
+ </code></pre>
144
+
145
+ <blockquote>
146
+ <p>Generate an authorization URL to intitiate the WorkOS OAuth2 workflow.</p>
147
+ </blockquote>
148
+
149
+ <p><code>WorkOS::SSO.authorization_url</code> accepts four arguments:</p>
150
+ <ul><li>
151
+ <p><code>domain</code> (string) — the authenticating user&#39;s company domain, without protocol (ex. <code>example.com</code>)</p>
152
+ </li><li>
153
+ <p><code>project_id</code> (string) — your application&#39;s WorkOS <a href="https://dashboard.workos.com/sso/configuration">Project ID</a> (ex. <code>project_01JG3BCPTRTSTTWQR4VSHXGWCQ</code>)</p>
154
+ </li><li>
155
+ <p><code>state</code> (optional, hash) — an optional hash used to manage state across authorization transactions (ex. <code>{ next_page: &#39;/docs&#39;}</code>)</p>
156
+ </li><li>
157
+ <p><code>redirect_uri</code> (string) — a callback URL where your application redirects the user-agent after an authorization code is granted (ex. <code>workos.dev/callback</code>). This must match one of your configured callback URLs for the associated project on your WorkOS dashboard.</p>
158
+ </li></ul>
159
+
160
+ <p>This method will return an OAuth2 query string of the form:</p>
161
+
162
+ <p><code>https://${domain}/sso/authorize?response_type=code&client_id=${projectID}&redirect_uri=${redirectURI}&state=${state}</code></p>
74
163
 
75
- <pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_gem'>gem</span> <span class='id identifier rubyid_build'>build</span> <span class='id identifier rubyid_workos'>workos</span><span class='period'>.</span><span class='id identifier rubyid_gemspec'>gemspec</span>
164
+ <p>For example, when used in a <a href="http://sinatrarb.com/">Sinatra app</a>:</p>
165
+
166
+ <pre class="code ruby"><code class="ruby"><span class='const'>DOMAIN</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>example.com</span><span class='tstring_end'>&#39;</span></span>
167
+ <span class='const'>PROJECT_ID</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>{projectId}</span><span class='tstring_end'>&#39;</span></span>
168
+ <span class='const'>REDIRECT_URI</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>http://localhost:4567/callback</span><span class='tstring_end'>&#39;</span></span>
169
+
170
+ <span class='id identifier rubyid_get'>get</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>/auth</span><span class='tstring_end'>&#39;</span></span> <span class='kw'>do</span>
171
+ <span class='id identifier rubyid_authorization_url'>authorization_url</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="WorkOS.html" title="WorkOS (module)">WorkOS</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="WorkOS/SSO.html" title="WorkOS::SSO (module)">SSO</a></span></span><span class='period'>.</span><span class='id identifier rubyid_authorization_url'><span class='object_link'><a href="WorkOS/SSO.html#authorization_url-class_method" title="WorkOS::SSO.authorization_url (method)">authorization_url</a></span></span><span class='lparen'>(</span>
172
+ <span class='label'>domain:</span> <span class='const'>DOMAIN</span><span class='comma'>,</span>
173
+ <span class='label'>project_id:</span> <span class='const'>PROJECT_ID</span><span class='comma'>,</span>
174
+ <span class='label'>redirect_uri:</span> <span class='const'>REDIRECT_URI</span><span class='comma'>,</span>
175
+ <span class='rparen'>)</span>
176
+
177
+ <span class='id identifier rubyid_redirect'>redirect</span> <span class='id identifier rubyid_authorization_url'>authorization_url</span>
178
+ <span class='kw'>end</span>
76
179
  </code></pre>
77
180
 
78
- <h3 id="label-Requirements">Requirements</h3>
181
+ <p>The user would be redirected to:</p>
182
+
183
+ <p><code>https://api.workos.com/sso/authorize?response_type=code&client_id={projectID}&redirect_uri=http://localhost:4567/callback</code></p>
184
+
185
+ <p>WorkOS takes over from here, sending the user to authenticate with their IDP, and on successful login, returns the user to your callback URL with a <code>code</code> parameter. You&#39;ll use <code>WorkOS::SSO.profile</code> to exchange the code for a <code>WorkOS::Profile</code>.</p>
186
+
187
+ <pre class="code ruby"><code class="ruby">WorkOS::SSO.profile(code:, project_id:)&lt;/h4&gt;
188
+ </code></pre>
189
+
190
+ <blockquote>
191
+ <p>Fetch a WorkOS::Profile for an authorized user.</p>
192
+ </blockquote>
193
+
194
+ <p><code>WorkOS::SSO.profile</code> accepts two arguments:</p>
79
195
  <ul><li>
80
- <p>Ruby 2.3+.</p>
196
+ <p><code>code</code> (string) — an opaque string provided by the authorization server; will be exchanged for an Access Token when the user&#39;s profile is sent</p>
197
+ </li><li>
198
+ <p><code>project_id</code> (string) — your application&#39;s WorkOS <a href="https://dashboard.workos.com/sso/configuration">Project ID</a> (ex. <code>project_01JG3BCPTRTSTTWQR4VSHXGWCQ</code>)</p>
81
199
  </li></ul>
200
+
201
+ <p>This method will return an instance of a <code>WorkOS::Profile</code> with the following attributes:</p>
202
+
203
+ <pre class="code ruby"><code class="ruby">&lt;WorkOS::Profile:0x00007fb6e4193d20
204
+ @id=&quot;prof_01DRA1XNSJDZ19A31F183ECQW5&quot;,
205
+ @email=&quot;demo@workos-okta.com&quot;,
206
+ @first_name=&quot;WorkOS&quot;,
207
+ @connection_type=&quot;OktaSAML&quot;,
208
+ @last_name=&quot;Demo&quot;,
209
+ @idp_id=&quot;00u1klkowm8EGah2H357&quot;,
210
+ &gt;
211
+ </code></pre>
212
+
213
+ <p>Our Sintatra app can be extended to use this method:</p>
214
+
215
+ <pre class="code ruby"><code class="ruby"><span class='const'>DOMAIN</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>example.com</span><span class='tstring_end'>&#39;</span></span>
216
+ <span class='const'>PROJECT_ID</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>{projectId}</span><span class='tstring_end'>&#39;</span></span>
217
+ <span class='const'>REDIRECT_URI</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>http://localhost:4567/callback</span><span class='tstring_end'>&#39;</span></span>
218
+
219
+ <span class='id identifier rubyid_get'>get</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>/auth</span><span class='tstring_end'>&#39;</span></span> <span class='kw'>do</span>
220
+ <span class='id identifier rubyid_authorization_url'>authorization_url</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="WorkOS.html" title="WorkOS (module)">WorkOS</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="WorkOS/SSO.html" title="WorkOS::SSO (module)">SSO</a></span></span><span class='period'>.</span><span class='id identifier rubyid_authorization_url'><span class='object_link'><a href="WorkOS/SSO.html#authorization_url-class_method" title="WorkOS::SSO.authorization_url (method)">authorization_url</a></span></span><span class='lparen'>(</span>
221
+ <span class='label'>domain:</span> <span class='const'>DOMAIN</span><span class='comma'>,</span>
222
+ <span class='label'>project_id:</span> <span class='const'>PROJECT_ID</span><span class='comma'>,</span>
223
+ <span class='label'>redirect_uri:</span> <span class='const'>REDIRECT_URI</span><span class='comma'>,</span>
224
+ <span class='rparen'>)</span>
225
+
226
+ <span class='id identifier rubyid_redirect'>redirect</span> <span class='id identifier rubyid_authorization_url'>authorization_url</span>
227
+ <span class='kw'>end</span>
228
+
229
+ <span class='id identifier rubyid_get'>get</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>/callback</span><span class='tstring_end'>&#39;</span></span> <span class='kw'>do</span>
230
+ <span class='id identifier rubyid_profile'>profile</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="WorkOS.html" title="WorkOS (module)">WorkOS</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="WorkOS/SSO.html" title="WorkOS::SSO (module)">SSO</a></span></span><span class='period'>.</span><span class='id identifier rubyid_profile'><span class='object_link'><a href="WorkOS/SSO.html#profile-class_method" title="WorkOS::SSO.profile (method)">profile</a></span></span><span class='lparen'>(</span>
231
+ <span class='label'>code:</span> <span class='id identifier rubyid_params'>params</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>code</span><span class='tstring_end'>&#39;</span></span><span class='rbracket'>]</span><span class='comma'>,</span>
232
+ <span class='label'>project_id:</span> <span class='const'>PROJECT_ID</span><span class='comma'>,</span>
233
+ <span class='rparen'>)</span>
234
+
235
+ <span class='id identifier rubyid_session'>session</span><span class='lbracket'>[</span><span class='symbol'>:user</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_profile'>profile</span><span class='period'>.</span><span class='id identifier rubyid_to_json'>to_json</span>
236
+
237
+ <span class='id identifier rubyid_redirect'>redirect</span> <span class='tstring'><span class='tstring_beg'>&#39;</span><span class='tstring_content'>/</span><span class='tstring_end'>&#39;</span></span>
238
+ <span class='kw'>end</span>
239
+ </code></pre>
240
+
241
+ <p>Given the <code>WorkOS::Profile</code>, you can now sign the user in according to your own authentication setup.</p>
82
242
  </div></div>
83
243
 
84
244
  <div id="footer">
85
- Generated on Wed Dec 18 08:33:35 2019 by
245
+ Generated on Thu Jan 30 09:12:47 2020 by
86
246
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
87
- 0.9.20 (ruby-2.4.9).
247
+ 0.9.22 (ruby-2.6.5).
88
248
  </div>
89
249
 
90
250
  </div>
@@ -4,9 +4,9 @@
4
4
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
5
5
  <meta charset="utf-8" />
6
6
 
7
- <link rel="stylesheet" href="css/full_list.css" type="text/css" media="screen" charset="utf-8" />
7
+ <link rel="stylesheet" href="css/full_list.css" type="text/css" media="screen" />
8
8
 
9
- <link rel="stylesheet" href="css/common.css" type="text/css" media="screen" charset="utf-8" />
9
+ <link rel="stylesheet" href="css/common.css" type="text/css" media="screen" />
10
10
 
11
11
 
12
12
 
@@ -2,9 +2,9 @@
2
2
  <html>
3
3
  <head>
4
4
  <meta charset="utf-8">
5
- <title>Documentation by YARD 0.9.20</title>
5
+ <title>Documentation by YARD 0.9.22</title>
6
6
  </head>
7
- <script type="text/javascript" charset="utf-8">
7
+ <script type="text/javascript">
8
8
  var match = unescape(window.location.hash).match(/^#!(.+)/);
9
9
  var name = match ? match[1] : 'index.html';
10
10
  name = name.replace(/^(\w+):\/\//, '').replace(/^\/\//, '');
@@ -4,15 +4,15 @@
4
4
  <meta charset="utf-8">
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
6
  <title>
7
- Documentation by YARD 0.9.20
7
+ Documentation by YARD 0.9.22
8
8
 
9
9
  </title>
10
10
 
11
- <link rel="stylesheet" href="css/style.css" type="text/css" charset="utf-8" />
11
+ <link rel="stylesheet" href="css/style.css" type="text/css" />
12
12
 
13
- <link rel="stylesheet" href="css/common.css" type="text/css" charset="utf-8" />
13
+ <link rel="stylesheet" href="css/common.css" type="text/css" />
14
14
 
15
- <script type="text/javascript" charset="utf-8">
15
+ <script type="text/javascript">
16
16
  pathId = null;
17
17
  relpath = '';
18
18
  </script>
@@ -52,7 +52,7 @@
52
52
  <div class="clear"></div>
53
53
  </div>
54
54
 
55
- <div id="content"><h1 class="noborder title">Documentation by YARD 0.9.20</h1>
55
+ <div id="content"><h1 class="noborder title">Documentation by YARD 0.9.22</h1>
56
56
  <div id="listing">
57
57
  <h1 class="alphaindex">Alphabetic Index</h1>
58
58
 
@@ -76,12 +76,41 @@
76
76
  <td valign='top' width="33%">
77
77
 
78
78
 
79
+ <ul id="alpha_A" class="alpha">
80
+ <li class="letter">A</li>
81
+ <ul>
82
+
83
+ <li>
84
+ <span class='object_link'><a href="WorkOS/APIError.html" title="WorkOS::APIError (class)">APIError</a></span>
85
+
86
+ <small>(WorkOS)</small>
87
+
88
+ </li>
89
+
90
+ <li>
91
+ <span class='object_link'><a href="WorkOS/AuditLog.html" title="WorkOS::AuditLog (module)">AuditLog</a></span>
92
+
93
+ <small>(WorkOS)</small>
94
+
95
+ </li>
96
+
97
+ <li>
98
+ <span class='object_link'><a href="WorkOS/AuthenticationError.html" title="WorkOS::AuthenticationError (class)">AuthenticationError</a></span>
99
+
100
+ <small>(WorkOS)</small>
101
+
102
+ </li>
103
+
104
+ </ul>
105
+ </ul>
106
+
107
+
79
108
  <ul id="alpha_B" class="alpha">
80
109
  <li class="letter">B</li>
81
110
  <ul>
82
111
 
83
112
  <li>
84
- <span class='object_link'><a href="WorkOS/Base.html" title="WorkOS::Base (class)">Base</a></span>
113
+ <span class='object_link'><a href="WorkOS/Base.html" title="WorkOS::Base (module)">Base</a></span>
85
114
 
86
115
  <small>(WorkOS)</small>
87
116
 
@@ -91,21 +120,29 @@
91
120
  </ul>
92
121
 
93
122
 
94
- <ul id="alpha_P" class="alpha">
95
- <li class="letter">P</li>
123
+ <ul id="alpha_C" class="alpha">
124
+ <li class="letter">C</li>
96
125
  <ul>
97
126
 
98
127
  <li>
99
- <span class='object_link'><a href="WorkOS/Profile.html" title="WorkOS::Profile (class)">Profile</a></span>
128
+ <span class='object_link'><a href="WorkOS/Client.html" title="WorkOS::Client (module)">Client</a></span>
100
129
 
101
130
  <small>(WorkOS)</small>
102
131
 
103
132
  </li>
104
133
 
134
+ </ul>
135
+ </ul>
136
+
137
+
138
+ <ul id="alpha_I" class="alpha">
139
+ <li class="letter">I</li>
140
+ <ul>
141
+
105
142
  <li>
106
- <span class='object_link'><a href="WorkOS/Types/ProfileStruct.html" title="WorkOS::Types::ProfileStruct (class)">ProfileStruct</a></span>
143
+ <span class='object_link'><a href="WorkOS/InvalidRequestError.html" title="WorkOS::InvalidRequestError (class)">InvalidRequestError</a></span>
107
144
 
108
- <small>(WorkOS::Types)</small>
145
+ <small>(WorkOS)</small>
109
146
 
110
147
  </li>
111
148
 
@@ -113,17 +150,31 @@
113
150
  </ul>
114
151
 
115
152
 
116
- <ul id="alpha_R" class="alpha">
117
- <li class="letter">R</li>
153
+ <ul id="alpha_P" class="alpha">
154
+ <li class="letter">P</li>
118
155
  <ul>
119
156
 
120
157
  <li>
121
- <span class='object_link'><a href="WorkOS/RequestError.html" title="WorkOS::RequestError (class)">RequestError</a></span>
158
+ <span class='object_link'><a href="WorkOS/Profile.html" title="WorkOS::Profile (class)">Profile</a></span>
122
159
 
123
160
  <small>(WorkOS)</small>
124
161
 
125
162
  </li>
126
163
 
164
+ <li>
165
+ <span class='object_link'><a href="WorkOS/Types/ProfileStruct.html" title="WorkOS::Types::ProfileStruct (class)">ProfileStruct</a></span>
166
+
167
+ <small>(WorkOS::Types)</small>
168
+
169
+ </li>
170
+
171
+ <li>
172
+ <span class='object_link'><a href="WorkOS/Types/Provider.html" title="WorkOS::Types::Provider (class)">Provider</a></span>
173
+
174
+ <small>(WorkOS::Types)</small>
175
+
176
+ </li>
177
+
127
178
  </ul>
128
179
  </ul>
129
180
 
@@ -158,6 +209,9 @@
158
209
  </ul>
159
210
 
160
211
 
212
+ </td><td valign='top' width="33%">
213
+
214
+
161
215
  <ul id="alpha_W" class="alpha">
162
216
  <li class="letter">W</li>
163
217
  <ul>
@@ -167,6 +221,13 @@
167
221
 
168
222
  </li>
169
223
 
224
+ <li>
225
+ <span class='object_link'><a href="WorkOS/WorkOSError.html" title="WorkOS::WorkOSError (class)">WorkOSError</a></span>
226
+
227
+ <small>(WorkOS)</small>
228
+
229
+ </li>
230
+
170
231
  </ul>
171
232
  </ul>
172
233
 
@@ -179,9 +240,9 @@
179
240
  </div>
180
241
 
181
242
  <div id="footer">
182
- Generated on Wed Dec 18 08:33:35 2019 by
243
+ Generated on Thu Jan 30 09:12:46 2020 by
183
244
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
184
- 0.9.20 (ruby-2.4.9).
245
+ 0.9.22 (ruby-2.6.5).
185
246
  </div>
186
247
 
187
248
  </div>