Skip to content

Commit 20fee57

Browse files
committed
Updated default branch docs (manually)
1 parent f31d104 commit 20fee57

7 files changed

Lines changed: 84 additions & 57 deletions

File tree

esw-web-app-example/flows/auth-flow.html

Lines changed: 43 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@
126126
<ul style="display: none">
127127
<li class="md-nav__item md-version" id="project.version">
128128
<label class="md-nav__link" for="__version">
129-
<i class="md-icon" title="Version">label_outline</i> 0.1.0
129+
<i class="md-icon" title="Version">label_outline</i> 0.1.0*
130130
</label>
131131
</li>
132132
</ul>
@@ -156,7 +156,7 @@
156156
<div class="md-content__searchable">
157157
<h1><a href="#adding-authentication" name="adding-authentication" class="anchor"><span class="anchor-link"></span></a>Adding Authentication</h1>
158158
<p>Like the User Interface Gateway, a web application backend is a boundary between the public side of the observatory software system and the authenticated, protected control system. Because of this, a web application developer must be conscious of and support the authentication and authorization of its users according to the observatory security approach. </p>
159-
<p>It&rsquo;s okay to have unprotected routes that are read-only and can not cause any changes, but any route that can change the control system must be protected with the correct level of authorization. This flow describes how to integrate authentication and authorization through the use of CSW AAS Service.</p>
159+
<p>It&rsquo;s okay to have unprotected routes that are read-only and cannot cause any changes, but any route that can change the control system must be protected with the correct level of authorization. This flow describes how to integrate authentication and authorization through the use of CSW AAS Service.</p>
160160
<h2><a href="#add-a-protected-route-in-backend" name="add-a-protected-route-in-backend" class="anchor"><span class="anchor-link"></span></a>Add a Protected Route in Backend</h2>
161161
<p>To demonstrate authorization, we will need to create a &ldquo;protected&rdquo; route, that is, an endpoint that requires a valid authorization token to access.</p>
162162
<h3><a href="#add-new-route-with-protection" name="add-new-route-with-protection" class="anchor"><span class="anchor-link"></span></a>Add new route with protection</h3>
@@ -167,12 +167,10 @@ <h3><a href="#add-new-route-with-protection" name="add-new-route-with-protection
167167
<dl>
168168
<dt>Scala</dt>
169169
<dd>
170-
<pre class="prettyprint"><button class="snippet-button copy-snippet" title="Copy snippet to clipboard">copy</button><a class="snippet-button go-to-source" href="https://github.com/tmtsoftware/esw-web-app-example/tree/master/backend/src/main/scala/org/tmt/sample/http/SampleRoute.scala#L32-L40" target="_blank" title="Go to snippet source">source</a><code class="language-scala">path(&quot;securedRaDecValues&quot;) {
171-
post {
172-
securityDirectives.sPost(RealmRolePolicy(&quot;Esw-user&quot;)) { _ =&gt;
173-
entity(as[RaDecRequest]) { raDecRequest =&gt;
174-
complete(raDecService.raDecToString(raDecRequest))
175-
}
170+
<pre class="prettyprint"><button class="snippet-button copy-snippet" title="Copy snippet to clipboard">copy</button><a class="snippet-button go-to-source" href="https://github.com/tmtsoftware/esw-web-app-example/tree/master/backend/src/main/scala/org/tmt/sample/http/SampleRoute.scala#L32-L38" target="_blank" title="Go to snippet source">source</a><code class="language-scala">path(&quot;securedRaDecValues&quot;) {
171+
securityDirectives.sPost(RealmRolePolicy(&quot;Esw-user&quot;)) { _ =&gt;
172+
entity(as[RaDecRequest]) { raDecRequest =&gt;
173+
complete(raDecService.raDecToString(raDecRequest))
176174
}
177175
}
178176
}</code></pre></dd>
@@ -205,7 +203,7 @@ <h3><a href="#create-a-react-component-to-consume-our-secured-route" name="creat
205203
<dl>
206204
<dt>Typescript</dt>
207205
<dd>
208-
<pre class="prettyprint"><button class="snippet-button copy-snippet" title="Copy snippet to clipboard">copy</button><a class="snippet-button go-to-source" href="https://github.com/tmtsoftware/esw-web-app-example/tree/master/frontend/src/components/pages/SecuredRaDecInput.tsx#L11-L70" target="_blank" title="Go to snippet source">source</a><code class="language-tsx">export const SecuredRaDecInput = (): JSX.Element =&gt; {
206+
<pre class="prettyprint"><button class="snippet-button copy-snippet" title="Copy snippet to clipboard">copy</button><a class="snippet-button go-to-source" href="https://github.com/tmtsoftware/esw-web-app-example/tree/master/frontend/src/components/pages/SecuredRaDecInput.tsx#L11-L70" target="_blank" title="Go to snippet source">source</a><code class="language-tsx">export const SecuredRaDecInput = (): React.JSX.Element =&gt; {
209207
return (
210208
&lt;Form
211209
onFinish={onFinish}
@@ -234,7 +232,7 @@ <h3><a href="#use-secured-post-in-our-component" name="use-secured-post-in-our-c
234232
<dl>
235233
<dt>Typescript</dt>
236234
<dd>
237-
<pre class="prettyprint"><button class="snippet-button copy-snippet" title="Copy snippet to clipboard">copy</button><a class="snippet-button go-to-source" href="https://github.com/tmtsoftware/esw-web-app-example/tree/master/frontend/src/components/pages/SecuredRaDecInput.tsx#L11-L14" target="_blank" title="Go to snippet source">source</a><code class="language-tsx">export const SecuredRaDecInput = (): JSX.Element =&gt; {
235+
<pre class="prettyprint"><button class="snippet-button copy-snippet" title="Copy snippet to clipboard">copy</button><a class="snippet-button go-to-source" href="https://github.com/tmtsoftware/esw-web-app-example/tree/master/frontend/src/components/pages/SecuredRaDecInput.tsx#L11-L14" target="_blank" title="Go to snippet source">source</a><code class="language-tsx">export const SecuredRaDecInput = (): React.JSX.Element =&gt; {
238236
const locationService = useLocationService()
239237
const { auth } = useAuth()</code></pre></dd>
240238
</dl>
@@ -279,37 +277,57 @@ <h3><a href="#connect-our-new-component" name="connect-our-new-component" class=
279277
<dl>
280278
<dt>Typescript</dt>
281279
<dd>
282-
<pre class="prettyprint"><button class="snippet-button copy-snippet" title="Copy snippet to clipboard">copy</button><a class="snippet-button go-to-source" href="https://github.com/tmtsoftware/esw-web-app-example/tree/master/frontend/src/routes/Routes.tsx#L15" target="_blank" title="Go to snippet source">source</a><code class="language-tsx">&lt;ProtectedRoute path=&#39;/securedRaDec&#39; component={SecuredRaDecInput} /&gt;</code></pre></dd>
280+
<pre class="prettyprint"><button class="snippet-button copy-snippet" title="Copy snippet to clipboard">copy</button><a class="snippet-button go-to-source" href="https://github.com/tmtsoftware/esw-web-app-example/tree/master/frontend/src/routes/Routes.tsx#L15-L22" target="_blank" title="Go to snippet source">source</a><code class="language-tsx">&lt;Route
281+
path=&#39;/securedRaDec&#39;
282+
element={
283+
&lt;ProtectedRoute&gt;
284+
&lt;SecuredRaDecInput /&gt;
285+
&lt;/ProtectedRoute&gt;
286+
}
287+
/&gt;</code></pre></dd>
283288
</dl>
284289
<p>Add an action for our new route in <code>MenuBar.tsx</code> below the previously added RaDec <code>Menu.Item</code></p>
285290
<dl>
286291
<dt>Typescript</dt>
287292
<dd>
288-
<pre class="prettyprint"><button class="snippet-button copy-snippet" title="Copy snippet to clipboard">copy</button><a class="snippet-button go-to-source" href="https://github.com/tmtsoftware/esw-web-app-example/tree/master/frontend/src/components/menu/MenuBar.tsx#L18-L32" target="_blank" title="Go to snippet source">source</a><code class="language-tsx">&lt;Menu mode=&#39;horizontal&#39;&gt;
289-
&lt;Menu.Item key=&#39;raDec&#39;&gt;
290-
&lt;Link to=&#39;/&#39;&gt;RaDec&lt;/Link&gt;
291-
&lt;/Menu.Item&gt;
292-
&lt;Menu.Item key=&#39;securedRaDec&#39;&gt;
293-
&lt;Link to=&#39;/securedRaDec&#39;&gt;SecuredRaDec&lt;/Link&gt;
294-
&lt;/Menu.Item&gt;
295-
&lt;/Menu&gt;</code></pre></dd>
293+
<pre class="prettyprint"><button class="snippet-button copy-snippet" title="Copy snippet to clipboard">copy</button><a class="snippet-button go-to-source" href="https://github.com/tmtsoftware/esw-web-app-example/tree/master/frontend/src/components/menu/MenuBar.tsx#L14-L40" target="_blank" title="Go to snippet source">source</a><code class="language-tsx">const items: MenuItem[] = [
294+
{
295+
key: &#39;raDec&#39;,
296+
label: &lt;Link to=&#39;/&#39;&gt;RaDec&lt;/Link&gt;
297+
},
298+
{
299+
key: &#39;securedRaDec&#39;,
300+
label: &lt;Link to=&#39;/securedRaDec&#39;&gt;SecuredRaDec&lt;/Link&gt;
301+
},
302+
]</code></pre></dd>
296303
</dl>
297304
<h3><a href="#add-login-logout-functionality" name="add-login-logout-functionality" class="anchor"><span class="anchor-link"></span></a>Add Login &amp; Logout functionality</h3>
298305
<p>To get the authorization token the user needs to log in. To provide login and logout capabilities, we will make use of the generated <code>Login</code> and <code>Logout</code> components.</p>
299306
<p>Add menu item actions for logging in and logging out in <code>MenuBar.tsx</code> below the previously added SecuredRaDec <code>Menu.Item</code> The menu item will change depending on whether the user is logged in or not to show protected functionality.</p>
300307
<dl>
301308
<dt>Typescript</dt>
302309
<dd>
303-
<pre class="prettyprint"><button class="snippet-button copy-snippet" title="Copy snippet to clipboard">copy</button><a class="snippet-button go-to-source" href="https://github.com/tmtsoftware/esw-web-app-example/tree/master/frontend/src/components/menu/MenuBar.tsx#L24-L28" target="_blank" title="Go to snippet source">source</a><code class="language-tsx">&lt;Menu.Item key=&#39;securedRaDec&#39;&gt;
304-
&lt;Link to=&#39;/securedRaDec&#39;&gt;SecuredRaDec&lt;/Link&gt;
305-
&lt;/Menu.Item&gt;
306-
{isAuthenticated ? &lt;Logout logout={logout} /&gt; : &lt;Login login={login} /&gt;}</code></pre></dd>
310+
<pre class="prettyprint"><button class="snippet-button copy-snippet" title="Copy snippet to clipboard">copy</button><a class="snippet-button go-to-source" href="https://github.com/tmtsoftware/esw-web-app-example/tree/master/frontend/src/components/menu/MenuBar.tsx#L21-L36" target="_blank" title="Go to snippet source">source</a><code class="language-tsx">{
311+
key: &#39;securedRaDec&#39;,
312+
label: &lt;Link to=&#39;/securedRaDec&#39;&gt;SecuredRaDec&lt;/Link&gt;
313+
},
314+
isAuthenticated
315+
? {
316+
key: &#39;logout&#39;,
317+
label: &#39;Logout&#39;,
318+
onClick: logout
319+
}
320+
: {
321+
key: &#39;login&#39;,
322+
label: &#39;Login&#39;,
323+
onClick: login
324+
}</code></pre></dd>
307325
</dl>
308326
<p>Note the authorization hook is used again here to get a handle to the authorization store.</p>
309327
<dl>
310328
<dt>Typescript</dt>
311329
<dd>
312-
<pre class="prettyprint"><button class="snippet-button copy-snippet" title="Copy snippet to clipboard">copy</button><a class="snippet-button go-to-source" href="https://github.com/tmtsoftware/esw-web-app-example/tree/master/frontend/src/components/menu/MenuBar.tsx#L9-L11" target="_blank" title="Go to snippet source">source</a><code class="language-tsx">export const MenuBar = (): JSX.Element =&gt; {
330+
<pre class="prettyprint"><button class="snippet-button copy-snippet" title="Copy snippet to clipboard">copy</button><a class="snippet-button go-to-source" href="https://github.com/tmtsoftware/esw-web-app-example/tree/master/frontend/src/components/menu/MenuBar.tsx#L7-L9" target="_blank" title="Go to snippet source">source</a><code class="language-tsx">export const MenuBar = (): React.JSX.Element =&gt; {
313331
const { auth, login, logout } = useAuth()
314332
const isAuthenticated = auth?.isAuthenticated() ?? false</code></pre></dd>
315333
</dl>
@@ -330,7 +348,7 @@ <h2><a href="#try-it-out-" name="try-it-out-" class="anchor"><span class="anchor
330348
</div>
331349
<div class="print-only">
332350
<span class="md-source-file md-version">
333-
0.1.0
351+
0.1.0*
334352
</span>
335353
</div>
336354
</article>

0 commit comments

Comments
 (0)