Skip to content

Commit

Permalink
More cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
ulrikstrid committed Dec 17, 2024
1 parent 7e70a8b commit e12b2a7
Show file tree
Hide file tree
Showing 28 changed files with 9 additions and 1,168 deletions.
35 changes: 0 additions & 35 deletions Dockerfile

This file was deleted.

4 changes: 0 additions & 4 deletions dune-project
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,3 @@
yojson
logs
piaf))

(package
(version 0.1.0)
(name morph-oidc))
12 changes: 7 additions & 5 deletions executable/DreamOauthClient.ml
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,29 @@ let () =
let params =
Oidc.Parameters.make
~scope:[ `S "repo"; `S "read:user" ]
client
~client_id:client.id
~redirect_uri
()
in
let uri = Uri.of_string "https://github.com/login/oauth/authorize" in
let redirect_uri =
Uri.with_query uri (Oidc.Parameters.to_query params)
in
Dream.redirect request (Uri.to_string redirect_uri) )
; ( Dream.get "/auth/callback" @@ fun request ->
match Dream.query "code" request with
match Dream.query request "code" with
| None -> Dream.html ~status:`Unauthorized "error"
| Some code ->
let uri =
Uri.of_string "https://github.com/login/oauth/access_token"
in
let request_body =
Oidc.Token.Request.make
~client
~grant_type:"code"
~scope:[ `S "repo" ]
~redirect_uri
~code
client
|> Oidc.Token.Request.to_body_string
in
let open Lwt.Syntax in
Expand All @@ -54,7 +55,9 @@ let () =
in
let* body = Cohttp_lwt.Body.to_string (snd token_response) in
let () = Dream.info (fun m -> m "body: %s" body) in
let token_response = Oidc.Token.Response.of_string body in
let token_response =
Oidc.Token.Response.of_string body |> Result.get_ok
in
let access_token = Option.get token_response.access_token in
let* user =
Cohttp_lwt_unix.Client.get
Expand All @@ -68,4 +71,3 @@ let () =
let+ response = Dream.html ("auth callback " ^ user) in
response )
]
@@ Dream.not_found
123 changes: 0 additions & 123 deletions executable/DreamOidcClient.ml

This file was deleted.

113 changes: 0 additions & 113 deletions executable/DreamOidcMiddleware.ml

This file was deleted.

58 changes: 0 additions & 58 deletions executable/Logger.ml

This file was deleted.

Loading

0 comments on commit e12b2a7

Please sign in to comment.