{"body":"","html":"<p><a href=\"https://tide.org/blog/ineffable-cryptography\">&lt; Back to Part 4: I got 99 problems, but a breach ain’t one</a></p><hr><h4><span style=\"color:#005ce3;\">Getting Started</span></h4><p>So, you want to build the most secure digital platforms on the planet, without the burden of worrying about security, and simultaneously grant your users sovereignty over their identities? Great!</p><p>This developer guide will take you through the minimal steps to build your own Single-Page React application, secured with TideCloak - <strong>all in under 10 minutes</strong>.</p><p>TideCloak gives you a plug and play tool that incorporates all the concepts and technology discussed in this series. It allows you to manage your web users' roles and permissions - It's an adaptation of Redhat's open-source KeyCloak, one of the most robust, powerful and feature-rich Identity and Access Management system. But best of all it's secured by Tide's Cybersecurity Fabric so no-one holds the keys to the kingdom.</p><hr><h5>Prerequisites</h5><p>Before starting, make sure you have:</p><ul><li data-list-item-id=\"e4699c58975a8019d00f10473090f2566\">Docker installed and running on your machine</li><li data-list-item-id=\"ed315409216eebac29fdb32c599053623\">NPM installed</li><li data-list-item-id=\"ed44943652bcee8d5e93cce1257d0a8c5\">Internet connectivity</li></ul><p>For the purpose of this guide, we assume to run on a Debian linux host (either under Windows WSL or not).</p><h4>1. Getting TideCloak up and running</h4><p>Start a TideCloak-Dev docker container that already includes all the basic configuration and settings to get you going. To get it, open your Docker/WSL/Linux terminal and run the following command:</p><pre><code class=\"language-bash language-plaintext\">\nsudo docker run \\\n  -d \\\n  -v .:/opt/keycloak/data/h2 \\\n  -p 8080:8080 \\\n  -e KC_BOOTSTRAP_ADMIN_USERNAME=admin \\\n  -e KC_BOOTSTRAP_ADMIN_PASSWORD=password \\\n  tideorg/tidecloak-dev:latest\n</code></pre><p><br>This will take a minute or two, and when it's done, you'll be able to go to TideCloak's console at:&nbsp;<a href=\"http://localhost:8080/\" rel=\"nofollow\">http://localhost:8080</a></p><h4>2. Activate your TideCloak license</h4><p>To get your TideCloak host to tap into Tide's Cybersecurity Fabric, you'll need to activate your license. Tide offers free developer license for up to 100 users. To do that, you'll need to:</p><ul><li data-list-item-id=\"e046bb8d554bdf36e5bbebaca3c18df13\">Access your TideCloak administration console at&nbsp;<a href=\"http://localhost:8080/admin/master/console/#/myrealm/identity-providers/tide/tide/settings\" rel=\"nofollow\">http://localhost:8080/admin/master/console/#/myrealm/identity-providers/tide/tide/settings</a></li><li data-list-item-id=\"eccf1128e2346c82ce420e1a20b5be820\">Log in using your admin credentials (Username: admin, Password: password, if you haven't changed it) (You should be automatically navigated to: myrealm realm → Identity Providers → tide IdP → Settings screen)</li><li data-list-item-id=\"e5e508d63cf324b2c2d3224a3dfb309fa\">Click on the&nbsp;<code>Manage License</code>&nbsp;button next to&nbsp;<code>License</code></li><li data-list-item-id=\"ed0f98c0a69ffa5109b500e6d0fe87466\">Click on the blue&nbsp;<code>Request License</code>&nbsp;button</li><li data-list-item-id=\"e9e06118c875c675a8f57ae0027be88e8\">Go through the checkout process by providing a contact email</li></ul><p>Within few seconds, you'll get your TideCloak host licenced and activated!</p><h4>3. Create your React JS project</h4><p>Note: You can find deep dives on the provider props, hook return values, TypeScript types, and more in the <a href=\"https://github.com/tide-foundation/tidecloak-js/blob/main/packages/tidecloak-react/README.md\" target=\"_blank\">TideCloak React SDK docs</a>.</p><h5>a. Create a React app using Vite:</h5><p>Run the following commands to create a new React app using Vite:</p><div class=\"code-snippet-container\"><div class=\"snippet-with-button\"><pre><code class=\"language-bash language-plaintext\">\nnpm create vite@latest tidecloak-react -- --template react-ts\ncd tidecloak-react\nnpm install @tidecloak/react\n</code></pre></div></div><h5>b. Export your TideCloak adapter:</h5><p>Export your specific TideCloak settings and hardcode it in your project:</p><ol><li data-list-item-id=\"eca3111853a609f9cff26e934bf57e334\">Go to your&nbsp;<a href=\"http://localhost:8080/admin/master/console/#/myrealm/clients\" rel=\"nofollow\">Clients</a>&nbsp;menu →&nbsp;<code>mytest</code>&nbsp;client ID</li><li data-list-item-id=\"e9a620784c6b4b53ddef740071a5e0c54\">Update&nbsp;<code>Valid redirect URIs</code>&nbsp;to&nbsp;<code>http://localhost:5173/*</code></li><li data-list-item-id=\"e12a42276647530a150c146790a6e36dc\">Update&nbsp;<code>Web origins</code>&nbsp;to&nbsp;<code>http://localhost:5173</code></li><li data-list-item-id=\"ed4aec53e0eaad8a9f3bfce3c2a45aea4\">In your&nbsp;<a href=\"http://localhost:8080/admin/master/console/#/myrealm/clients\" rel=\"nofollow\">Clients</a>&nbsp;menu →&nbsp;<code>mytest</code>&nbsp;client ID →&nbsp;<code>Action</code>&nbsp;dropdown →&nbsp;<code>Download adaptor configs</code>&nbsp;option (keep it as&nbsp;<code>keycloak-oidc-keycloak-json</code>&nbsp;format)</li><li data-list-item-id=\"e0a5a524cd214a57c76922f15e6e69ba3\"><code>Download</code>&nbsp;or copy the details of that config and paste it in your project's root folder under&nbsp;<code>tidecloak.json</code>&nbsp;.</li></ol><h5><br>c. Update main.tsx via&nbsp;<code>nano src/main.tsx</code></h5><p>Change the file based on the below insertions / deletions:</p><div class=\"code-snippet-container\"><p>src/main.tsx</p><div class=\"snippet-with-button\"><p>&nbsp;</p><pre><code class=\"language-tsx language-typescript language-diff-jsx\">\n import { StrictMode } from 'react'\n import { createRoot } from 'react-dom/client'\n import './index.css'\n- import App from './App.tsx'\n+ import { TideCloakContextProvider, useTideCloak, Authenticated, Unauthenticated } from '@tidecloak/react'\n+ import tidecloakConfig from \"../tidecloak.json\"\n+\n+ function UserInfo() {\n+   const { logout, getValueFromIdToken, hasRealmRole } = useTideCloak();\n+   const IsAllowedToViewProfile = () =&gt; (hasRealmRole(\"default-roles-myrealm\") ? \"Yes\" : \"No\");\n+\n+   return (\n+     &lt;div&gt;\n+       &lt;p&gt;Signed in as &lt;b&gt;{getValueFromIdToken(\"preferred_username\") ?? '…'}&lt;/b&gt;&lt;/p&gt;\n+       &lt;p&gt;Has Default Roles? &lt;b&gt;{IsAllowedToViewProfile()}&lt;/b&gt;&lt;/p&gt;\n+       &lt;button onClick={logout}&gt;Logout&lt;/button&gt;\n+     &lt;/div&gt;\n+   );\n+ }\n+\n+ function Welcome() {\n+   const { login } = useTideCloak();\n+   return (\n+     &lt;div&gt;\n+       &lt;h1&gt;Hello!&lt;/h1&gt;\n+       &lt;p&gt;Please authenticate yourself!&lt;/p&gt;\n+       &lt;p&gt;&lt;button onClick={login}&gt;Login&lt;/button&gt;&lt;/p&gt;\n+     &lt;/div&gt;\n+   );\n+ }\n \n createRoot(document.getElementById('root')!).render(\n-   &lt;App /&gt;\n+   &lt;StrictMode&gt;\n+     &lt;TideCloakContextProvider config={tidecloakConfig}&gt;\n+       &lt;Authenticated&gt;\n+         &lt;UserInfo/&gt;\n+       &lt;/Authenticated&gt;\n+       &lt;Unauthenticated&gt;\n+         &lt;Welcome/&gt;\n+       &lt;/Unauthenticated&gt;\n+     &lt;/TideCloakContextProvider&gt;\n+   &lt;/StrictMode&gt;,\n )\n    </code></pre></div></div><h4><br>4. Build your NPM environment</h4><p>Download and install all the dependencies for this project:</p><div class=\"code-snippet-container\"><div class=\"snippet-with-button\"><p>&nbsp;</p><pre><code class=\"language-bash language-plaintext\">npm install</code></pre></div></div><h4><br>5. Run your project</h4><p>Build and run your project:</p><div class=\"code-snippet-container\"><div class=\"snippet-with-button\"><p>&nbsp;</p><pre><code class=\"language-bash language-plaintext\">npm run dev</code></pre></div></div><p><br>All done!</p><h4>6. Play!</h4><ol><li data-list-item-id=\"e49449f03d11e661110dc70d1c829672f\">Go to&nbsp;<a href=\"http://localhost:5173/\" rel=\"nofollow\">http://localhost:5173</a>&nbsp;You should see a \"Hello!\" message.</li><li data-list-item-id=\"ea6d9f586fe4c4496ba8433d69b685e52\">Click on the&nbsp;<code>Login</code>&nbsp;button</li><li data-list-item-id=\"ec22ff9a61903894b4b8abcfa747225b8\">Click on&nbsp;<code>Create an account</code></li><li data-list-item-id=\"edfe94c80bce7b8c3eb55095f79ce60f0\">Provide a new username, password, recovery email</li></ol><p>It will now show you that you're \"Signed in\" and it will show you your anonymous Tide username for this app.</p><h4>Project recap</h4><p>Let's review what just happened and what you've just accomplished:</p><ol><li data-list-item-id=\"e48054636fb0e19adec5e5b078388e3ed\">You have programmed, compiled, built and deployed, from the ground-up, a fully-functional ReactJS Single-Page-Application (SPA).</li><li data-list-item-id=\"ef71940a7bfcb158cd2dbb480c4bcf0b7\">Web users can now sign up and sign in to your SPA, being served customized content to authenticated and unauthenticated users and based on their predefined roles.</li><li data-list-item-id=\"e46c147a8e409e36a1d2bed2acfe0aeeb\">Your web users' roles and permissions are managed locally on your very own self-hosted instance of TideCloak - one of the most robust, powerful and feature-rich Identity and Access Management system which you have downloaded, installed, configured and deployed locally.</li><li data-list-item-id=\"e41ca1751ca6b49705361b24f66d010bd\">Your web users enjoy fully-secured Tide accounts, with their identity and access-credentials sitting outside of anyone's reach.</li><li data-list-item-id=\"e41bdea89648eff1fa9976c14d98df2d7\">Your TideCloak instance is secured by the global Tide Cybersecurity Fabric that you have activated and licensed.</li></ol><p>&nbsp;</p><h4><span style=\"color:#005ce3;\">What next?</span></h4><p>There's two additional layers of protection you can configure through TideCloak:</p><ol><li data-list-item-id=\"edfe75f092c174e2408ca8b2eac037f98\"><strong>Identity Governance:</strong> Establish workflow processes ensuring that no compromised administrator can cause damage.</li><li data-list-item-id=\"e572ce1bf83f23e0db356030fd2578f3d\"><strong>User walletization:</strong> Ability to lock user data with unique user keys secured by Tide's Cybersecurity Fabric - so ownership and privacy can be guaranteed.</li></ol><p>&nbsp;</p><hr><h4>Authors:</h4><p style=\"font-size:12px;\"><em>This 5-part series outlining the worry-free future of cybersecurity for platform developers is an adaptation of Tide Foundation Co-Founders Michael Loewy and Yuval Hertzog’s keynote at ACM SIGCOMM 2024</em></p><p><a href=\"https://www.linkedin.com/in/michaelloewy/\" target=\"_blank\">Michael Loewy</a> is a Co-Founder of Tide Foundation and serves on the advisory board of the Children’s Medical Research Institute.</p><p><a href=\"https://www.linkedin.com/in/uvhertzog/\" target=\"_blank\">Yuval Hertzog</a> is a Co-Founder of Tide Foundation and one of the inventors of VoIP.</p><h4>Series shortcuts:</h4><ul><li data-list-item-id=\"e091690163ece711af2b974904a96545f\"><a href=\"https://tide.org/blog/rethinking-cybersecurity-for-developers\">Part 1: It’s time to rethink cybersecurity for platform developers</a></li><li data-list-item-id=\"e0e74039dfddff64624575420f47df0ac\"><a href=\"https://tide.org/blog/cybersecuritys-kryptonite-decoupling-authority\">Part 2: It’s cybersecurity’s kryptonite: Why are you still holding it?</a></li><li data-list-item-id=\"ed8f33672218fe97b1c5887012b1f967d\"><a href=\"https://tide.org/blog/swarm-intelligence-future-security\">Part 3: How nature holds the key to cybersecurity’s future</a></li><li data-list-item-id=\"eee5e0256ec117c8b4ec5e6b223ced668\"><a href=\"https://tide.org/blog/ineffable-cryptography\">Part 4: I got 99 problems, but a breach ain’t one</a></li><li data-list-item-id=\"e1376b19735df98d735891b2d55d2e0c2\">Part 5: Future proofing your platform</li></ul>"}