Skip to content

Commit

Permalink
Get everything compiling
Browse files Browse the repository at this point in the history
  • Loading branch information
matheus23 committed Jan 25, 2022
1 parent ba6e4ba commit c94705f
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 28 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module Fission.Web.Server.Auth.Token.UCAN (handler) where

import Web.DID.Types
import Web.DID.Types as DID
import Web.UCAN.Resolver as UCAN
import qualified Web.UCAN.Types as UCAN
import qualified Web.UCAN.Validation as UCAN
Expand Down Expand Up @@ -42,7 +42,7 @@ handler (Bearer.Token jwt rawContent) = do
toAuthorization jwt

toAuthorization ::
( UCAN.Resolver m
( UCAN.Resolver m
, MonadThrow m
, MonadLogger m
, MonadDB t m
Expand All @@ -56,7 +56,7 @@ toAuthorization jwt@UCAN.UCAN {claims = UCAN.Claims {..}} = do
Left err ->
throwM err

Right UCAN.UCAN {claims = UCAN.Claims {sender = DID {publicKey = pk}}} ->
Right UCAN.UCAN {claims = UCAN.Claims {sender = DID.Key pk}} ->
runDB (User.getByPublicKey pk) >>= \case
Nothing ->
Web.Error.throw $ NotFound @User
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Servant.Server.Generic

import Fission.Prelude

import Web.DID.Types
import Web.DID.Types as DID

import qualified Fission.Web.API.User.Create.Types as User.Create

Expand Down Expand Up @@ -45,7 +45,7 @@ withDID ::
, Challenge.Creator m
)
=> ServerT User.Create.WithDID m
withDID User.Registration {username, email} DID {..} = do
withDID User.Registration {username, email} (DID.Key publicKey) = do
now <- currentTime
userId <- Web.Err.ensureM $ User.create username publicKey email now
challenge <- Web.Err.ensureM $ Challenge.create userId
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{-# LANGUAGE AllowAmbiguousTypes #-}
module Fission.Web.Server.Handler.User.Verify (handler) where

import Servant
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import Fission.Prelude
import Fission.Internal.Fixture.Key.Ed25519 as Fixture.Ed25519

import Fission.URL.Types
import Web.DID.Types
import Web.DID.Types as DID

import Fission.Web.API.Host.Types
import Fission.Web.API.Remote
Expand Down Expand Up @@ -108,10 +108,7 @@ run logFunc dbPool processCtx httpManager tlsManager action = do
herokuID = Hku.ID "HEROKU_ID"
herokuPassword = Hku.Password "HEROKU_PASSWORD"

fissionDID = DID
{ publicKey = Fixture.Ed25519.pk
, method = Key
}
fissionDID = DID.Key $ Fixture.Ed25519.pk

environment = LocalDev

Expand Down Expand Up @@ -185,10 +182,7 @@ mkConfig dbPool processCtx httpManager tlsManager logFunc linkRelayStoreVar mach
herokuID = Hku.ID "HEROKU_ID"
herokuPassword = Hku.Password "HEROKU_PASSWORD"

fissionDID = DID
{ publicKey = Fixture.Ed25519.pk
, method = Key
}
fissionDID = DID.Key $ Fixture.Ed25519.pk

ipfsPath = "/usr/local/bin/ipfs"
ipfsURLs = Partial.fromJust $ nonEmpty [IPFS.URL $ BaseUrl Http "localhost" 5001 ""]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import Fission.Prelude

import Fission.Internal.App
import Fission.Time
import Web.DID.Types
import Web.DID.Types as DID

import Fission.Web.API.Host.Types as Server
import qualified Fission.Web.API.Types as Fission
Expand Down Expand Up @@ -195,7 +195,7 @@ start middleware runner = do
now <- currentTime
cfg@Fission.Server.Config {..} <- ask

let DID _ serverPK = fissionDID
let DID.Key serverPK = fissionDID

logDebug $ displayShow cfg

Expand Down
15 changes: 3 additions & 12 deletions fission-web-server/library/Fission/Web/Server/Mock/Config.hs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import qualified Network.IPFS.Types as IPFS
import Servant
import Servant.Server.Experimental.Auth

import Web.DID.Types
import Web.DID.Types as DID

import Fission.Prelude

Expand Down Expand Up @@ -39,11 +39,7 @@ defaultConfig :: Config
defaultConfig = Config
{ now = agesAgo
, linkedPeers = pure $ IPFS.Peer "ipv4/fakepeeraddress"
, didVerifier = mkAuthHandler \_ ->
return $ DID
{ publicKey = pk
, method = Key
}
, didVerifier = mkAuthHandler \_ -> pure $ DID.Key pk
, userVerifier = mkAuthHandler \_ -> pure $ Fixture.entity Fixture.user
, authVerifier = mkAuthHandler \_ -> authZ
, herokuVerifier = BasicAuthCheck \_ -> pure . Authorized $ Heroku.Auth "FAKE HEROKU"
Expand All @@ -68,13 +64,8 @@ defaultConfig = Config

authZ :: Monad m => m Authorization
authZ = return Authorization
{ sender = Right did
{ sender = Right $ DID.Key $ Fixture.Ed25519.pk
, about = Fixture.entity Fixture.user
, potency = Just AppendOnly
, resource = Subset $ FissionFileSystem "/test/"
}
where
did = DID
{ publicKey = Fixture.Ed25519.pk
, method = Key
}

0 comments on commit c94705f

Please sign in to comment.