Skip to content
This repository has been archived by the owner on Jun 6, 2023. It is now read-only.

Changes based on integrating with ADFS, Azure, and PingOne #7

Open
wants to merge 35 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
6d5e7e4
AuthnRequest: don't create 'signature' tag in request if disabled
samv Nov 19, 2015
5b91e34
Suppress redundant XMLNS tags
samv Nov 19, 2015
6e5fbf2
Omit various optional fields if not set
samv Nov 19, 2015
8eb3a7d
Use persistent, not transient Name IDs
samv Nov 19, 2015
263a125
Don't send hi-resolution issue instants
samv Nov 19, 2015
1257662
SAML Response: parse out the SessionIndex
samv Dec 2, 2015
c249968
Permit setting of 'ForceAuthn' in AuthnRequest
samv Dec 2, 2015
5f34f36
Fix a broken test
samv Dec 6, 2015
07a7a6a
Add a 'ParseDecodedString' Response constructor
samv Dec 6, 2015
25b974a
Allow XML Signatures in one more location on responses
samv Dec 6, 2015
22fc0a7
Don't indent AuthnRequests
samv Dec 7, 2015
032c321
Fix an indent
samv Dec 7, 2015
a9e951e
AuthnRequest protocol compliance fix
samv Dec 7, 2015
4437955
Reverse an earlier protocol change
samv Dec 7, 2015
4482c55
Compliance fix in XML Signature boilerplate, use SHA-256
samv Dec 8, 2015
a561308
AuthnRequest: set Destination for signed requests
samv Dec 9, 2015
8ab58f4
Allow AuthnRequests without name ID policy, auth context
samv Dec 10, 2015
663d4f4
Add (limited) support for encrypted response assertions
samv Dec 12, 2015
c097a17
Comment out the debug output
samv Dec 12, 2015
b671544
Fix imports
samv Dec 16, 2015
7947faf
go fmt
samv Dec 16, 2015
0ae90e1
Implement LogoutRequest
samv Dec 16, 2015
661c9fa
Put back the imports
samv Jan 13, 2016
6ccbdcc
Add some XML bindings for Metadata
Mar 28, 2016
a218cc0
Make the codebase parsable
samv Feb 1, 2016
b86f185
PA-22319: Created unit tests and add additional validation for signat…
Jan 16, 2020
9b443e1
ADMIN-2247 - add test key to gitleaks allowed list
mlovrovich Oct 25, 2021
bddad8f
Merge pull request #6 from parsable/ADMIN-2247-gitleaks-allowed-list
mlovrovich Oct 25, 2021
fd8310a
INFRA-2677: GHA pipeline
pbrobles Nov 13, 2023
93bb449
INFRA-2677: Add dependabot
pbrobles Nov 13, 2023
06bf1c9
INFRA-2677: fix common actions
pbrobles Nov 14, 2023
be602a8
INFRA-2677: fix common actions
pbrobles Nov 15, 2023
c137aa2
Merge pull request #7 from parsable/infra-2677-buid-gha-pipeline
pbrobles Nov 15, 2023
5001401
INFRA-2677: fix build publish workflow
pbrobles Nov 15, 2023
715e1ba
Merge pull request #8 from parsable/infra-2677-build-gha-pipeline
pbrobles Nov 15, 2023
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
7 changes: 7 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version: 2
updates:
- package-ecosystem: gitsubmodule
directory: "/"
schedule:
interval: daily
open-pull-requests-limit: 10
60 changes: 60 additions & 0 deletions .github/workflows/build-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Run on master branch builds. Tags a release with v{semver}
name: CI-Go-Publish
permissions:
contents: write
id-token: write

on:
push:
branches:
- master
- main

jobs:
go-build-publish:
name: go build publish
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
fetch-depth: 0
- name: Install xmlsec1
run: sudo apt-get install -y libxmlsec1 && sudo apt-get install xmlsec1
- name: Go Build
run: |
echo "machine github.com login machine-parsable password ${{ secrets.GH_PAT_MACHINE_PARSABLE }}" > ~/.netrc
git fetch --tags
go build -v -o bin/events
- name: Go Test
run: go test -v -race ./...
- name: Git Version
id: version
uses: codacy/[email protected]
with:
release-branch: master
prefix: v
- name: Tag
id: tag
run: |
truncated_version=$(echo ${{ steps.version.outputs.version }} | awk -F- '{print $1}')
echo previous tag ${{ steps.version.outputs.previous-version }}
git config --global user.email "[email protected]"
git config --global user.name "machine-parsable"
git tag -a -m "${truncated_version}" ${truncated_version}
git push --tags
echo "new_tag=${truncated_version}" >> $GITHUB_OUTPUT
- name: Checkout common-actions repo
uses: actions/checkout@v4
with:
repository: parsable/common-actions
path: ./common-actions
token: ${{ secrets.GH_PAT_MACHINE_PARSABLE }}
ref: v1.0.1
- name: Release
uses: ./common-actions/release-with-changelog
with:
token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ steps.tag.outputs.new_tag }}
28 changes: 28 additions & 0 deletions .github/workflows/ci-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Run on branch builds
name: CI-Go-Tests
permissions:
contents: read
id-token: write

on:
push:
branches-ignore:
- master
- main

jobs:
go-build-test:
name: go build test
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install xmlsec1
run: sudo apt-get install -y libxmlsec1 && sudo apt-get install xmlsec1
- name: Go Build
run: |
echo "machine github.com login machine-parsable password ${{ secrets.GH_PAT_MACHINE_PARSABLE }}" > ~/.netrc
go build -v -o bin/events
- name: Go Test
run: go test -v -race ./...
26 changes: 26 additions & 0 deletions .github/workflows/stale-actions.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: "Mark or close stale issues and PRs"
on:
schedule:
- cron: "0 10 * * 1-5"

jobs:
stale:
name: "Check for stale PRs"
runs-on: ubuntu-latest
steps:
- uses: actions/stale@v8
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
# Staling issues and PR's
days-before-stale: 15
stale-pr-label: stale
stale-pr-message: |
This PR has been automatically marked as stale because it has been open 15 days
with no activity. Remove stale label and comment on this PR or it will be closed
in 3 days. Setting this PR to draft will also prevent it from being closed.
exempt-all-milestones: true
exempt-draft-pr: true
# Time is up after 18 days
days-before-pr-close: 18
delete-branch: true
close-pr-message: "This PR was closed because it has been stalled for 18 days with no activity."
52 changes: 52 additions & 0 deletions .gitleaks.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
[allowlist]
regexes = ['''-----BEGIN RSA PRIVATE KEY-----
MIIJKAIBAAKCAgEA6KPw06lqMicl0dCvoReKcOKgZGiy9IG2yqIih/u8L3cxzjTq
BQXxeTUI9NjOCScnjkOvoR2FeEI7VBuNczH9V6B/1OhMv6FEZLgiSQhoVvQMg/gO
Fj+GEuAIP7je6ND957o+4SYqXn2NQc5oNp/PYhw3KR78Ck7VVmWHY+g4G8IfWR/U
IkUUafhmR17u51vlQmTNJhPvao8SuDMPihAw+iyIEjgM0S1i8lJm9isL3Pvg4cA7
SKE4VR2KDXeEpPY+v+Adw5j2vN4v9XWSshWjAg1J+/ouiocCFmxn4OrkDDPBul8x
eFeceWoJoPAytuFV7N8m9ZTiFHMzVauGR5AKXOI8B1ol53Gm/PFJwzxu6VZvO8IW
jIIVjcK2ALf/0BCJxMZMYzYVsMTRZXpYP/G/X1LHR+fBXmYmfpjZ8AAl54IJmRBP
pVF+RYfJe/W5HvnZ0GyQIUH4vjoZjZapnPqLigz2KpNPyAvav904OuRI/TIqvdfC
AL0AFbZcMMKeiOf9NgGuYqmaMwU1F2KlhP6l4sZaVodrT+ZY3nIBms7sOfLRo9vp
10vQwPcFYBlAJeMSRTv7PHpp2udpUj88L3K+o/gTIn1x69FgSBHE27c14cVKXwui
AteMnzzn/IOFiioINVqtx+HRohNdcuunHmHodUWZVl6vyRLSdRVS6BquKi8CAwEA
AQKCAgBFa0YdotwRgyUB6ue9hizFapq525Qq6doFtUPgl/mboFG4WonKXe+kX3MA
vQEeMhTXmtL5nLmLHRhfDKm0yiHy1+3NNlRQimrCMz/n0x5vc/uYFZj+go4ba8aK
XTwG9PYPA8Bnpt/VullAXbszMZTMjebX2msTGFsIoNs5sL2tasu36IuAfmSNCpZa
jbV0TDOpEDM3PZOflHndhT8Jz7MNs+QWq6sHcCeqb3RR2J59npuIQbhu/8yzeVEM
m7F1GBW5Y8L97tMRoKtm72KKy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PtBKquc04kS/H9XpjiTldxZeFLQEC0=
-----END RSA PRIVATE KEY-----''']
59 changes: 38 additions & 21 deletions authnrequest.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"net/url"
"time"

"github.com/RobotsAndPencils/go-saml/util"
"github.com/parsable/go-saml/util"
)

func ParseCompressedEncodedRequest(b64RequestXML string) (*AuthnRequest, error) {
Expand Down Expand Up @@ -82,10 +82,13 @@ func (r *AuthnRequest) Validate(publicCertPath string) error {

// GetSignedAuthnRequest returns a singed XML document that represents a AuthnRequest SAML document
func (s *ServiceProviderSettings) GetAuthnRequest() *AuthnRequest {
r := NewAuthnRequest()
r := NewAuthnRequestCustom(s.SPSignRequest)
r.AssertionConsumerServiceURL = s.AssertionConsumerServiceURL
r.Issuer.Url = s.IDPSSODescriptorURL
r.Signature.KeyInfo.X509Data.X509Certificate.Cert = s.PublicCert()
if s.SPSignRequest {
r.Signature[0].KeyInfo.X509Data.X509Certificate.Cert = s.PublicCert()
r.Destination = s.IDPSSOURL
}

return r
}
Expand All @@ -105,14 +108,17 @@ func GetAuthnRequestURL(baseURL string, b64XML string, state string) (string, er
}

func NewAuthnRequest() *AuthnRequest {
return NewAuthnRequestCustom(true)
}

func NewAuthnRequestCustom(sign bool) *AuthnRequest {
id := util.ID()
return &AuthnRequest{
authReq := &AuthnRequest{
XMLName: xml.Name{
Local: "samlp:AuthnRequest",
},
SAMLP: "urn:oasis:names:tc:SAML:2.0:protocol",
SAML: "urn:oasis:names:tc:SAML:2.0:assertion",
SAMLSIG: "http://www.w3.org/2000/09/xmldsig#",
ID: id,
ProtocolBinding: "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST",
Version: "2.0",
Expand All @@ -122,31 +128,33 @@ func NewAuthnRequest() *AuthnRequest {
Local: "saml:Issuer",
},
Url: "", // caller must populate ar.AppSettings.Issuer
SAML: "urn:oasis:names:tc:SAML:2.0:assertion",
},
IssueInstant: time.Now().UTC().Format(time.RFC3339Nano),
NameIDPolicy: NameIDPolicy{
IssueInstant: time.Now().UTC().Format(time.RFC3339),
NameIDPolicy: &NameIDPolicy{
XMLName: xml.Name{
Local: "samlp:NameIDPolicy",
},
AllowCreate: true,
Format: "urn:oasis:names:tc:SAML:2.0:nameid-format:transient",
Format: "urn:oasis:names:tc:SAML:2.0:nameid-format:persistent",
},
RequestedAuthnContext: RequestedAuthnContext{
RequestedAuthnContext: &RequestedAuthnContext{
XMLName: xml.Name{
Local: "samlp:RequestedAuthnContext",
},
SAMLP: "urn:oasis:names:tc:SAML:2.0:protocol",
Comparison: "exact",
AuthnContextClassRef: AuthnContextClassRef{
XMLName: xml.Name{
Local: "saml:AuthnContextClassRef",
},
SAML: "urn:oasis:names:tc:SAML:2.0:assertion",
Transport: "urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport",
},
},
Signature: Signature{
}

if sign {
authReq.SAMLSIG = "http://www.w3.org/2000/09/xmldsig#"
authReq.Signature = make([]Signature, 1, 1)
authReq.Signature[0] = Signature{
XMLName: xml.Name{
Local: "samlsig:Signature",
},
Expand All @@ -165,7 +173,7 @@ func NewAuthnRequest() *AuthnRequest {
XMLName: xml.Name{
Local: "samlsig:SignatureMethod",
},
Algorithm: "http://www.w3.org/2000/09/xmldsig#rsa-sha1",
Algorithm: "http://www.w3.org/2001/04/xmldsig-more#rsa-sha256",
},
SamlsigReference: SamlsigReference{
XMLName: xml.Name{
Expand All @@ -176,18 +184,26 @@ func NewAuthnRequest() *AuthnRequest {
XMLName: xml.Name{
Local: "samlsig:Transforms",
},
Transform: Transform{
XMLName: xml.Name{
Local: "samlsig:Transform",
Transforms: []Transform{
{
XMLName: xml.Name{
Local: "samlsig:Transform",
},
Algorithm: "http://www.w3.org/2000/09/xmldsig#enveloped-signature",
},
{
XMLName: xml.Name{
Local: "samlsig:Transform",
},
Algorithm: "http://www.w3.org/2001/10/xml-exc-c14n#",
},
Algorithm: "http://www.w3.org/2000/09/xmldsig#enveloped-signature",
},
},
DigestMethod: DigestMethod{
XMLName: xml.Name{
Local: "samlsig:DigestMethod",
},
Algorithm: "http://www.w3.org/2000/09/xmldsig#sha1",
Algorithm: "http://www.w3.org/2001/04/xmlenc#sha256",
},
DigestValue: DigestValue{
XMLName: xml.Name{
Expand Down Expand Up @@ -217,12 +233,13 @@ func NewAuthnRequest() *AuthnRequest {
},
},
},
},
}
}
return authReq
}

func (r *AuthnRequest) String() (string, error) {
b, err := xml.MarshalIndent(r, "", " ")
b, err := xml.Marshal(r)
if err != nil {
return "", err
}
Expand Down
Loading