Skip to content

Commit

Permalink
Fixes for okta + govcloud
Browse files Browse the repository at this point in the history
  • Loading branch information
duckfez committed Apr 7, 2020
1 parent 602ad1f commit 48077d7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
5 changes: 5 additions & 0 deletions aws_account.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ func ParseAWSAccounts(samlAssertion string) ([]*AWSAccount, error) {
awsURL = "https://signin.amazonaws.cn/saml"
}

if strings.Contains(string(decSamlAssertion), "signin.amazonaws-us-gov.com") {
fmt.Println("trying to login AWS GovCloud")
awsURL = "https://signin.amazonaws-us-gov.com/saml"
}

res, err := http.PostForm(awsURL, url.Values{"SAMLResponse": {samlAssertion}})
if err != nil {
return nil, errors.Wrap(err, "error retrieving AWS login form")
Expand Down
12 changes: 11 additions & 1 deletion pkg/provider/okta/okta.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,17 @@ func docIsFormResume(doc *goquery.Document) bool {
}

func docIsFormRedirectToAWS(doc *goquery.Document) bool {
return doc.Find("form[action=\"https://signin.aws.amazon.com/saml\"]").Size() == 1
urls := []string{"form[action=\"https://signin.aws.amazon.com/saml\"]",
"form[action=\"https://signin.amazonaws-us-gov.com/saml\"]",
"form[action=\"https://signin.amazonaws.cn/saml\"]",
};

for _, value := range urls {
if (doc.Find(value).Size() > 0) {
return true
}
}
return false
}

func extractSAMLResponse(doc *goquery.Document) (v string, ok bool) {
Expand Down

0 comments on commit 48077d7

Please sign in to comment.