Skip to content

Commit c917e01

Browse files
committed
improved oauth documentations and examples
1 parent fb79cec commit c917e01

File tree

3 files changed

+134
-33
lines changed

3 files changed

+134
-33
lines changed

docs/oauth_instructions.html

Lines changed: 120 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ <h2> Demo </h2>
9999
</ul>
100100
<h2> Short Version </h2>
101101
<ul>
102-
<li> Register your app with an Authorization Provider such as https://bitbucket.org </li>
102+
<li> Register your app with an Authorization Provider such as Microsoft Active Directory </li>
103103
<li> Create <span class='mono orange'> index.html </span>containing <span class='mono orange'> &lt;rapi-doc&gt;</span> element (<a href="#index-html"> view </a>)</li>
104104
<li> Create another html and name it <span class='mono orange'> oauth-receiver.html </span> containing <span class='mono orange'> &lt;oauth-receiver&gt;</span> element (<a href="#auth-receiver-html"> view </a>)</li>
105105
</ul>
@@ -113,28 +113,29 @@ <h3>Register client with Authorization Server</h3>
113113
<p>
114114
<ul>
115115
<li>
116-
For this demo I am going to use <b>BitBucket</b> as the OAuth provider, so SignUp with https://bitbucket.org/ if you dont have an account
116+
For this demo I am going to use <a href="https://demo.identityserver.io/" target="_blank"> <b>IdentityServer</b> </a> as the OAuth provider.
117+
This is a demo Identity provider which is pre-configured with some users and supports various oAuth authentication flows
117118
</li>
118119
<li>
119-
<b>Register OAuth Client in Bitbucket: </b> In my case the client is https://mrin9.github.io. <br/>
120-
In your case it could be localhost:{port} or the domain from where you are hosting your html containing RapiDoc element
121-
<ul>
122-
<li>
123-
While registering provide the <span class="blue">Redirect URL</span> as the url of <span class="blue mono"> oauth-receiver.html </span> that you created above
124-
</li>
125-
<li>
126-
Upon successful registration, you should be provided with a client_id and client_secret
127-
</li>
128-
</ul>
120+
<b>Register OAuth Client with identity Provider:</b> Normally you need to register your client application with the Identity provider which will provide you with a <span class='mono bold'> client-id and client-secret</span>
121+
but in our case we donot need to do so because our demo identity server is pre-configured with some sample client-id and secret
129122
</li>
130123
</ul>
131124
</p>
132125

133-
<h3> Setup Client </h3>
134-
<b>Client: </b> This is the app's domain that host the html containing <span class='mono'> &lt;rapi-doc&gt;</span>
135-
element.<br/>
136-
In case of RapiDoc OAuth demo, since we host it from Github pages, it is https://mrin9.github.io<br/><br/>
137-
Below are the two files that our server must have<br/><br/>
126+
<h3> Setup RapiDoc </h3>
127+
Below are the two files that you need to have<br/>
128+
<ul>
129+
<li>
130+
<span class="mono bold">index.html </span>
131+
<span class="gray"> (I am using the name index.html but you are free to use any name, it is the html that contain &lt;rapi-doc&gt; element) </span>
132+
</li>
133+
<li>
134+
<span class="mono bold">oauth-receiver.html </span>
135+
<span class="gray">(It is important that you name this file exactly as oauth-receiver.html and place in the same location where the above file is)</span>
136+
</li>
137+
</ul>
138+
<br/>
138139

139140
<a id='index-html' class="blue mono">index.html</a>
140141
(This is our main file that contains the <span class='mono'> &lt;rapi-doc&gt;</span> element )
@@ -169,6 +170,108 @@ <h3> Setup Client </h3>
169170
&lt;/body&gt;
170171
</code>
171172
</pre>
173+
174+
<h3> The OpenAPI spec </h3>
175+
Our demo Identity server provides few sample APIs for testing.
176+
<br/>
177+
Below is the OpenAPI spec which contains couple of APIs protected with identity server.
178+
You can check out how these are rendered through RapiDoc and how rapidoc exchanges oAuth tokens with the demo IdentityServer
179+
| <a href="./examples/oauth-demo.html" target="_blank"> Demo </a>
180+
<pre>
181+
<code class="language-yaml code-block">
182+
openapi: 3.0.0
183+
info:
184+
title: Identity 4 Server
185+
description: Works only on `http://localhost...`
186+
version: "1.0"
187+
servers:
188+
- url: https://demo.identityserver.io
189+
paths:
190+
/api/test:
191+
get:
192+
summary: Test API
193+
security:
194+
- short-lived-oauth:
195+
- api
196+
- long-lived-oauth:
197+
- api
198+
- client-credential-oauth:
199+
- api
200+
responses:
201+
'200':
202+
description: Successful operation
203+
/connect/userinfo:
204+
get:
205+
summary: Get User Info
206+
security:
207+
- short-lived-oauth:
208+
- openid
209+
- email
210+
- profile
211+
- long-lived-oauth:
212+
- openid
213+
- email
214+
- profile
215+
- client-credential-oauth:
216+
- openid
217+
- email
218+
- profile
219+
- basic: []
220+
- api-key1: []
221+
responses:
222+
'200':
223+
description: Successful operation
224+
components:
225+
securitySchemes:
226+
short-lived-oauth:
227+
type: oauth2
228+
description: Provides OAuth token valid for short duration ~75 seconds
229+
# vendor-extension x-client-id and x-client-secret to prefill data
230+
x-client-id: interactive.confidential.short
231+
x-client-secret: secret
232+
flows:
233+
authorizationCode:
234+
authorizationUrl: https://demo.identityserver.io/connect/authorize
235+
tokenUrl: https://demo.identityserver.io/connect/token
236+
scopes:
237+
openid: OpenID
238+
email: Email
239+
profile: Profile
240+
api: API
241+
long-lived-oauth:
242+
type: oauth2
243+
description: Provides an OAuth token thats valid for long durations
244+
x-client-id: interactive.confidential
245+
x-client-secret: secret
246+
flows:
247+
authorizationCode:
248+
authorizationUrl: https://demo.identityserver.io/connect/authorize
249+
tokenUrl: https://demo.identityserver.io/connect/token
250+
scopes:
251+
openid: OpenID
252+
email: Email
253+
profile: Profile
254+
api: API
255+
client-credential-oauth:
256+
type: oauth2
257+
description: Provides an OAuth token thats valid for long duration
258+
x-client-id: m2m
259+
x-client-secret: secret
260+
flows:
261+
clientCredentials:
262+
tokenUrl: https://demo.identityserver.io/connect/token
263+
scopes:
264+
openid: OpenID
265+
email: Email
266+
profile: Profile
267+
api: API
268+
</code>
269+
</pre>
270+
271+
272+
273+
274+
172275
</div>
173276
</body>
174277

0 commit comments

Comments
 (0)