You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -105,3 +126,8 @@ <h3 id="user-content-from-the-repl">From the REPL</h3>
105
126
<p>And move your text editor's cursor over any of the letters in <code>-main</code> and press the keyboard shortcut for "sending the text under the cursor" to the REPL server. The http server will start and you can navigate to <code>http://localhost:1337</code></p>
Copy file name to clipboardExpand all lines: docs/authentication.html
+85-2
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,81 @@
1
-
<h1id="user-content-authentication">Authentication</h1><ul><li><ahref='#user-content-libraries'>Libraries</a></li><li><ahref='#user-content-setup'>Setup</a></li><li><ahref='#user-content-password-hashing'>Password Hashing</a></li><li><ahref='#user-content-complete-example'>Complete Example</a></li></ul><p>Coast does not have authentication built in. It's up to you to determine how you want to authenticate people.</p><p>Typically for clojure database-backed web applications, there are a few options:</p><ul><li>Sessions</li><li>JWT Tokens (this guide does not cover this)</li><li>Basic HTTP Auth (also not covered by this guide)</li></ul><h2id="user-content-libraries">Libraries</h2><p>Let's get into it. In the clojure world, there are two popular web application authentication libraries</p><ul><li><ahref='https://github.com/cemerick/friend'>Friend</a></li><li><ahref='https://github.com/funcool/buddy'>Buddy</a></li></ul><p>Coast lends itself more to buddy, so that's what this guide covers.</p><p>Buddy is composed of several different libraries:</p><ul><li><code>buddy-core</code></li><li><code>buddy-hashers</code></li><li><code>buddy-sign</code></li><li><code>buddy-auth</code></li></ul><p>Setting up authentication middleware with Coast only really needs <code>buddy-hashers</code>, so that's the library we'll choose</p><h2id="user-content-setup">Setup</h2><p>Here's how to set up buddy for use with a Coast application</p><p>Install the <code>buddy-hashers</code> dependency in your <code>deps.edn</code> file</p><pre><codeclass="clojure">; deps.edn
<h1id="user-content-authentication">Authentication</h1><ul><li><ahref='#user-content-libraries'>Libraries</a></li><li><ahref='#user-content-setup'>Setup</a></li><li><ahref='#user-content-password-hashing'>Password Hashing</a></li><li><ahref='#user-content-complete-example'>Complete Example</a></li></ul><p>Coast does not have authentication built in. It's up to you to determine how you want to authenticate people.</p><p>Typically for clojure database-backed web applications, there are a few options:</p><ul><li>Sessions</li><li>JWT Tokens (this guide does not cover this)</li><li>Basic HTTP Auth (also not covered by this guide)</li></ul><h2id="user-content-libraries">Libraries</h2><p>Let's get into it. In the clojure world, there are two popular web application authentication libraries</p><ul><li><ahref='https://github.com/cemerick/friend'>Friend</a></li><li><ahref='https://github.com/funcool/buddy'>Buddy</a></li></ul><p>Coast lends itself more to buddy, so that's what this guide covers.</p><p>Buddy is composed of several different libraries:</p><ul><li><code>buddy-core</code></li><li><code>buddy-hashers</code></li><li><code>buddy-sign</code></li><li><code>buddy-auth</code></li></ul><p>Setting up authentication middleware with Coast only really needs <code>buddy-hashers</code>, so that's the library we'll choose</p><h2id="user-content-setup">Setup</h2><p>Here's how to set up buddy for use with a Coast application</p><p>Install the <code>buddy-hashers</code> dependency in your <code>deps.edn</code> file</p><pre><codeclass="clojure">; deps.edn
</code></pre><p>Notice the use of <code>hashers/check</code> to check the plaintext password from the form against the password from the existing hashed password in the database.</p><p>...and finally the sign out handler</p><pre><codeclass="clojure">(defn delete [request]
112
189
(-> (coast/redirect-to ::build)
113
190
(assoc :session nil)))
114
-
</code></pre><p>This is not the only way to implement authentication in your Coast app, but it is a complete example of one way of doing authentication.</p>
191
+
</code></pre><p>This is not the only way to implement authentication in your Coast app, but it is a complete example of one way of doing authentication.</p>
0 commit comments