-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22 from Nike-Inc/feature/csrf-crumb-generation
CSRF crumb generation
- Loading branch information
Showing
10 changed files
with
166 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
-- Fire up the REPL with some niceties | ||
:m Control.Lens Data.Aeson Data.Aeson.Lens Network.Wreq | ||
:l test/ReplSugar.hs | ||
:set -XOverloadedStrings |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
{-# LANGUAGE OverloadedStrings #-} | ||
module ReplSugar where | ||
|
||
import Control.Lens | ||
import Bartlett.Types | ||
import Bartlett.Util | ||
import Bartlett.Configuration | ||
import Bartlett.Network | ||
import Data.Maybe | ||
import Data.ByteString.Lazy.Char8 | ||
import qualified Network.Wreq as W | ||
import qualified Network.Wreq.Session as S | ||
|
||
-- | Docker Jenkins user. | ||
usr :: User | ||
usr = User "test" "password" | ||
|
||
usrOpts :: W.Options | ||
usrOpts = | ||
W.defaults & W.auth ?~ getBasicAuth usr | ||
|
||
|
||
jenkins :: IO JenkinsInstance | ||
jenkins = do | ||
c <- getConfiguration "default" | ||
j <- getJenkinsInstance c | ||
return $ fromJust j | ||
|
||
getCSRF :: IO W.Options | ||
getCSRF = do | ||
j <- jenkins | ||
S.withAPISession $ \session -> do | ||
foo <- consCSRFHeader $ requestCSRFToken session usrOpts j | ||
return $ W.defaults & foo |