Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add state argument to delete #66

Merged
merged 2 commits into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/scotty/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
import Data.List as L
import Data.Map (Map)
import qualified Data.Map as M
import Data.Maybe (Maybe (..), fromMaybe)

Check warning on line 23 in examples/scotty/Main.hs

View workflow job for this annotation

GitHub Actions / build (lts-17)

The import of ‘Maybe’ from module ‘Data.Maybe’ is redundant

Check warning on line 23 in examples/scotty/Main.hs

View workflow job for this annotation

GitHub Actions / build (lts-18)

The import of ‘Maybe’ from module ‘Data.Maybe’ is redundant

Check warning on line 23 in examples/scotty/Main.hs

View workflow job for this annotation

GitHub Actions / build (lts-19)

The import of ‘Maybe’ from module ‘Data.Maybe’ is redundant

Check warning on line 23 in examples/scotty/Main.hs

View workflow job for this annotation

GitHub Actions / build (lts-20)

The import of ‘Maybe’ from module ‘Data.Maybe’ is redundant
import Data.Monoid ((<>))

Check warning on line 24 in examples/scotty/Main.hs

View workflow job for this annotation

GitHub Actions / build (lts-17)

The import of ‘Data.Monoid’ is redundant

Check warning on line 24 in examples/scotty/Main.hs

View workflow job for this annotation

GitHub Actions / build (lts-18)

The import of ‘Data.Monoid’ is redundant

Check warning on line 24 in examples/scotty/Main.hs

View workflow job for this annotation

GitHub Actions / build (lts-19)

The import of ‘Data.Monoid’ is redundant

Check warning on line 24 in examples/scotty/Main.hs

View workflow job for this annotation

GitHub Actions / build (lts-20)

The import of ‘Data.Monoid’ is redundant
import Data.Text as T
import Data.Text.Encoding (decodeUtf8)
import Data.Text.Lazy as TL
Expand Down Expand Up @@ -167,7 +167,7 @@
{ sessionStoreGenerate = genBytes cprg
, sessionStoreSave = saveState ssm sid
, sessionStoreGet = getStateBy ssm sid
, sessionStoreDelete = deleteState ssm sid
, sessionStoreDelete = const $ deleteState ssm sid
}

blaze = html . renderHtml
Expand Down
2 changes: 1 addition & 1 deletion src/Web/OIDC/Client/CodeFlow.hs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import qualified Data.ByteString.Char8 as B
import Data.List (nub)
import Data.Maybe (isNothing)
import Data.Monoid ((<>))

Check warning on line 27 in src/Web/OIDC/Client/CodeFlow.hs

View workflow job for this annotation

GitHub Actions / build (lts-17)

The import of ‘Data.Monoid’ is redundant

Check warning on line 27 in src/Web/OIDC/Client/CodeFlow.hs

View workflow job for this annotation

GitHub Actions / build (lts-17)

The import of ‘Data.Monoid’ is redundant

Check warning on line 27 in src/Web/OIDC/Client/CodeFlow.hs

View workflow job for this annotation

GitHub Actions / build (lts-17)

The import of ‘Data.Monoid’ is redundant

Check warning on line 27 in src/Web/OIDC/Client/CodeFlow.hs

View workflow job for this annotation

GitHub Actions / build (lts-18)

The import of ‘Data.Monoid’ is redundant

Check warning on line 27 in src/Web/OIDC/Client/CodeFlow.hs

View workflow job for this annotation

GitHub Actions / build (lts-18)

The import of ‘Data.Monoid’ is redundant

Check warning on line 27 in src/Web/OIDC/Client/CodeFlow.hs

View workflow job for this annotation

GitHub Actions / build (lts-18)

The import of ‘Data.Monoid’ is redundant

Check warning on line 27 in src/Web/OIDC/Client/CodeFlow.hs

View workflow job for this annotation

GitHub Actions / build (lts-19)

The import of ‘Data.Monoid’ is redundant

Check warning on line 27 in src/Web/OIDC/Client/CodeFlow.hs

View workflow job for this annotation

GitHub Actions / build (lts-19)

The import of ‘Data.Monoid’ is redundant

Check warning on line 27 in src/Web/OIDC/Client/CodeFlow.hs

View workflow job for this annotation

GitHub Actions / build (lts-19)

The import of ‘Data.Monoid’ is redundant

Check warning on line 27 in src/Web/OIDC/Client/CodeFlow.hs

View workflow job for this annotation

GitHub Actions / build (lts-20)

The import of ‘Data.Monoid’ is redundant

Check warning on line 27 in src/Web/OIDC/Client/CodeFlow.hs

View workflow job for this annotation

GitHub Actions / build (lts-20)

The import of ‘Data.Monoid’ is redundant

Check warning on line 27 in src/Web/OIDC/Client/CodeFlow.hs

View workflow job for this annotation

GitHub Actions / build (lts-20)

The import of ‘Data.Monoid’ is redundant
import Data.Text (Text, pack, unpack)
import Data.Text.Encoding (decodeUtf8With)
import Data.Text.Encoding.Error (lenientDecode)
Expand Down Expand Up @@ -79,7 +79,7 @@
savedNonce <- sessionStoreGet store stateFromIdP
when (isNothing savedNonce) $ throwM UnknownState
result <- liftIO $ requestTokens oidc savedNonce code mgr
sessionStoreDelete store
sessionStoreDelete store stateFromIdP
return result

-- | Make URL for Authorization Request.
Expand Down
2 changes: 1 addition & 1 deletion src/Web/OIDC/Client/IdTokenFlow.hs
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
import Data.Aeson (FromJSON)
import qualified Data.ByteString.Char8 as B
import Data.List (nub)
import Data.Maybe (isNothing, fromMaybe)

Check warning on line 20 in src/Web/OIDC/Client/IdTokenFlow.hs

View workflow job for this annotation

GitHub Actions / build (lts-17)

The import of ‘Data.Maybe’ is redundant

Check warning on line 20 in src/Web/OIDC/Client/IdTokenFlow.hs

View workflow job for this annotation

GitHub Actions / build (lts-17)

The import of ‘Data.Maybe’ is redundant

Check warning on line 20 in src/Web/OIDC/Client/IdTokenFlow.hs

View workflow job for this annotation

GitHub Actions / build (lts-18)

The import of ‘Data.Maybe’ is redundant

Check warning on line 20 in src/Web/OIDC/Client/IdTokenFlow.hs

View workflow job for this annotation

GitHub Actions / build (lts-18)

The import of ‘Data.Maybe’ is redundant

Check warning on line 20 in src/Web/OIDC/Client/IdTokenFlow.hs

View workflow job for this annotation

GitHub Actions / build (lts-19)

The import of ‘Data.Maybe’ is redundant

Check warning on line 20 in src/Web/OIDC/Client/IdTokenFlow.hs

View workflow job for this annotation

GitHub Actions / build (lts-19)

The import of ‘Data.Maybe’ is redundant

Check warning on line 20 in src/Web/OIDC/Client/IdTokenFlow.hs

View workflow job for this annotation

GitHub Actions / build (lts-20)

The import of ‘Data.Maybe’ is redundant

Check warning on line 20 in src/Web/OIDC/Client/IdTokenFlow.hs

View workflow job for this annotation

GitHub Actions / build (lts-20)

The import of ‘Data.Maybe’ is redundant
import Data.Monoid ((<>))

Check warning on line 21 in src/Web/OIDC/Client/IdTokenFlow.hs

View workflow job for this annotation

GitHub Actions / build (lts-17)

The import of ‘Data.Monoid’ is redundant

Check warning on line 21 in src/Web/OIDC/Client/IdTokenFlow.hs

View workflow job for this annotation

GitHub Actions / build (lts-17)

The import of ‘Data.Monoid’ is redundant

Check warning on line 21 in src/Web/OIDC/Client/IdTokenFlow.hs

View workflow job for this annotation

GitHub Actions / build (lts-18)

The import of ‘Data.Monoid’ is redundant

Check warning on line 21 in src/Web/OIDC/Client/IdTokenFlow.hs

View workflow job for this annotation

GitHub Actions / build (lts-18)

The import of ‘Data.Monoid’ is redundant

Check warning on line 21 in src/Web/OIDC/Client/IdTokenFlow.hs

View workflow job for this annotation

GitHub Actions / build (lts-19)

The import of ‘Data.Monoid’ is redundant

Check warning on line 21 in src/Web/OIDC/Client/IdTokenFlow.hs

View workflow job for this annotation

GitHub Actions / build (lts-19)

The import of ‘Data.Monoid’ is redundant

Check warning on line 21 in src/Web/OIDC/Client/IdTokenFlow.hs

View workflow job for this annotation

GitHub Actions / build (lts-20)

The import of ‘Data.Monoid’ is redundant

Check warning on line 21 in src/Web/OIDC/Client/IdTokenFlow.hs

View workflow job for this annotation

GitHub Actions / build (lts-20)

The import of ‘Data.Monoid’ is redundant
import Data.Text (unpack)
import Data.Text.Encoding (decodeUtf8With)

Check warning on line 23 in src/Web/OIDC/Client/IdTokenFlow.hs

View workflow job for this annotation

GitHub Actions / build (lts-17)

The import of ‘Data.Text.Encoding’ is redundant

Check warning on line 23 in src/Web/OIDC/Client/IdTokenFlow.hs

View workflow job for this annotation

GitHub Actions / build (lts-17)

The import of ‘Data.Text.Encoding’ is redundant

Check warning on line 23 in src/Web/OIDC/Client/IdTokenFlow.hs

View workflow job for this annotation

GitHub Actions / build (lts-18)

The import of ‘Data.Text.Encoding’ is redundant

Check warning on line 23 in src/Web/OIDC/Client/IdTokenFlow.hs

View workflow job for this annotation

GitHub Actions / build (lts-18)

The import of ‘Data.Text.Encoding’ is redundant

Check warning on line 23 in src/Web/OIDC/Client/IdTokenFlow.hs

View workflow job for this annotation

GitHub Actions / build (lts-19)

The import of ‘Data.Text.Encoding’ is redundant

Check warning on line 23 in src/Web/OIDC/Client/IdTokenFlow.hs

View workflow job for this annotation

GitHub Actions / build (lts-19)

The import of ‘Data.Text.Encoding’ is redundant

Check warning on line 23 in src/Web/OIDC/Client/IdTokenFlow.hs

View workflow job for this annotation

GitHub Actions / build (lts-20)

The import of ‘Data.Text.Encoding’ is redundant

Check warning on line 23 in src/Web/OIDC/Client/IdTokenFlow.hs

View workflow job for this annotation

GitHub Actions / build (lts-20)

The import of ‘Data.Text.Encoding’ is redundant
import Data.Text.Encoding.Error (lenientDecode)

Check warning on line 24 in src/Web/OIDC/Client/IdTokenFlow.hs

View workflow job for this annotation

GitHub Actions / build (lts-17)

The import of ‘Data.Text.Encoding.Error’ is redundant

Check warning on line 24 in src/Web/OIDC/Client/IdTokenFlow.hs

View workflow job for this annotation

GitHub Actions / build (lts-17)

The import of ‘Data.Text.Encoding.Error’ is redundant

Check warning on line 24 in src/Web/OIDC/Client/IdTokenFlow.hs

View workflow job for this annotation

GitHub Actions / build (lts-18)

The import of ‘Data.Text.Encoding.Error’ is redundant

Check warning on line 24 in src/Web/OIDC/Client/IdTokenFlow.hs

View workflow job for this annotation

GitHub Actions / build (lts-18)

The import of ‘Data.Text.Encoding.Error’ is redundant

Check warning on line 24 in src/Web/OIDC/Client/IdTokenFlow.hs

View workflow job for this annotation

GitHub Actions / build (lts-19)

The import of ‘Data.Text.Encoding.Error’ is redundant

Check warning on line 24 in src/Web/OIDC/Client/IdTokenFlow.hs

View workflow job for this annotation

GitHub Actions / build (lts-19)

The import of ‘Data.Text.Encoding.Error’ is redundant

Check warning on line 24 in src/Web/OIDC/Client/IdTokenFlow.hs

View workflow job for this annotation

GitHub Actions / build (lts-20)

The import of ‘Data.Text.Encoding.Error’ is redundant

Check warning on line 24 in src/Web/OIDC/Client/IdTokenFlow.hs

View workflow job for this annotation

GitHub Actions / build (lts-20)

The import of ‘Data.Text.Encoding.Error’ is redundant
import qualified Jose.Jwt as Jwt
import Network.HTTP.Client (getUri, setQueryString)
import Network.URI (URI)
Expand Down Expand Up @@ -64,7 +64,7 @@
msavedNonce <- sessionStoreGet store stateFromIdP
savedNonce <- maybe (liftIO $ throwIO UnknownState) pure msavedNonce
jwt <- Jwt.Jwt <$> getIdToken
sessionStoreDelete store
sessionStoreDelete store stateFromIdP
idToken <- liftIO $ validateIdToken oidc jwt
nonce' <- maybe (liftIO $ throwIO MissingNonceInResponse) pure (nonce idToken)
when (nonce' /= savedNonce) $ liftIO $ throwIO MismatchedNonces
Expand Down
2 changes: 1 addition & 1 deletion src/Web/OIDC/Client/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,6 @@ data SessionStore m = SessionStore
, sessionStoreSave :: State -> Nonce -> m ()
, sessionStoreGet :: State -> m (Maybe Nonce)
-- ^ Returns 'Nothing' if 'State' is unknown
, sessionStoreDelete :: m ()
, sessionStoreDelete :: State -> m ()
-- ^ Should delete at least nonce
}
Loading