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

Shorten SAML Request ID and make it hexadecimal, then prepend "id" #23

Merged
merged 1 commit into from
Oct 27, 2022
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
1 change: 1 addition & 0 deletions package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ dependencies:
- base >= 4.8 && < 5
- text < 2
- bytestring >= 0.9 && < 0.12
- base16-bytestring >= 0.1 && < 1.1
- base64-bytestring >= 0.1 && < 2
- containers >= 0.6 && <0.7
- data-default-class < 1
Expand Down
5 changes: 4 additions & 1 deletion src/Network/Wai/SAML2/Request.hs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import Network.Wai.SAML2.XML
import Text.XML

import qualified Data.ByteString as B
import qualified Data.ByteString.Base16 as Base16
import qualified Data.ByteString.Base64 as Base64
import qualified Data.ByteString.Lazy as BL
import qualified Data.Map.Strict as Map
Expand Down Expand Up @@ -64,7 +65,9 @@ issueAuthnRequest
-> IO AuthnRequest
issueAuthnRequest authnRequestIssuer = do
authnRequestTimestamp <- getCurrentTime
authnRequestID <- T.decodeUtf8 . Base64.encode <$> getRandomBytes 64
-- Azure AD does not accept an id starting with a number
-- https://learn.microsoft.com/en-us/azure/active-directory/develop/single-sign-on-saml-protocol
authnRequestID <- ("id" <>) . T.decodeUtf8 . Base16.encode <$> getRandomBytes 16
pure AuthnRequest{
authnRequestAllowCreate = True
, authnRequestNameIDFormat =
Expand Down
2 changes: 2 additions & 0 deletions wai-saml2.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ library
ghc-options: -W
build-depends:
base >=4.8 && <5
, base16-bytestring >=0.1 && <1.1
, base64-bytestring >=0.1 && <2
, bytestring >=0.9 && <0.12
, c14n >=0.1.0.1 && <1
Expand Down Expand Up @@ -89,6 +90,7 @@ test-suite parser
ghc-options: -Wall -Wcompat
build-depends:
base
, base16-bytestring >=0.1 && <1.1
, base64-bytestring >=0.1 && <2
, bytestring
, c14n >=0.1.0.1 && <1
Expand Down