Skip to content

Commit

Permalink
Add docstrings (#259)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sohalt authored Mar 14, 2024
1 parent 7c1c9bb commit d1ae6f5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 2 additions & 2 deletions example/auth_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@
{:status 200 :headers {"content-type" "text/html"}
:body (garden-id/->html [:div.text-center
[:h2.font-bold.text-white.text-xl.mb-2.text-center
(format "Hi %s 👋" (or (garden-id/get-user req) "Stranger"))]
(format "Hi %s 👋" (or (:name (garden-id/get-user req)) "Stranger"))]
[:p.text-white.mb-6.text-center
(format "You have visited %s times" (or (:visits session) "unknown"))]
(if (garden-id/logged-in? req)
(garden-id/render-link-button {:href garden-id/logout-uri :label "Logout"})
(garden-id/render-link-button {:href garden-id/login-uri :label "Login"}))])
:session session})

{:status 400 :body "not found"}))
{:status 404 :body "not found"}))

(defn start [_]
(httpkit/run-server (-> consuming-app
Expand Down
10 changes: 10 additions & 0 deletions src/nextjournal/garden_id.clj
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,16 @@
(app req))))

(defn wrap-auth
"Ring middleware to add authentication (and optional authorization)
To restrict login to members of a GitHub org or team pass `:github` in `opts`
`{:github [[\"organization\"]... [\"organization\" \"team\"]...]}`
To restrict login to people with Apple ID pass `:apple` in `opts`
`{:apple []}`
Request handlers can check if a user is logged in using `logged-in?`
and access user details using `get-user`"
([app]
(wrap-auth app {}))
([app opts]
Expand Down

0 comments on commit d1ae6f5

Please sign in to comment.