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 SAML flow support ADFS endpoint "/adfs/services/trust/13/usernamemixed" #504

Merged
merged 28 commits into from
May 25, 2020

Conversation

Didainius
Copy link
Collaborator

@Didainius Didainius commented May 8, 2020

This PR adds support for SAML login using Microsoft Active Directory Services as Identity Provider (IdP).

It introduces two new provider section variables use_saml_adfs and saml_rpt_id to alter login flow.

Testing

PR adds a few new variables to configuration struct:

SamlUser        string `json:"samlUser,omitempty"`
SamlPassword    string `json:"samlPassword,omitempty"`
SamlCustomRptId string `json:"samlCustomRptId,omitempty"`

It allows to triggers explicitly a test TestAccVcdSamlAuth designed to try SAML authentication and can be useful if local users are used for main testing.

More details about flow and how it works is in go-vcloud-director SDK PR (vmware/go-vcloud-director#304) as this is where it all is handled. The main point of SDK PR is to make it as easy as possible to use new features.

This PR demonstrates it by showing how little SDK user needs to do.

@ghost ghost added size/XXL and removed size/XL labels May 13, 2020
@Didainius Didainius marked this pull request as ready for review May 13, 2020 14:08
Copy link
Contributor

@vbauzys vbauzys left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I couldn't test as don't have ADF server

CHANGELOG.md Outdated
@@ -6,6 +6,8 @@ IMPROVEMENTS:
* Removed code that handled specific cases for API 29.0 and 30.0. This library now supports VCD versions from 9.5 to 10.1 included [GH-499]
* Added command line flags to test suite, corresponding to environment variables listed in TESTING.md [GH-505]
* `resource/vcd_vapp_vm` allows creating VM from multi VM vApp template [GH-501]
* Add support for SAML auth with Active Directory Federation Services (ADFS) as IdP using
"/adfs/services/trust/13/usernamemixed" endpoint. [GH-502]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[GH-502] -> [GH-504]

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed.

@ghost ghost added size/XL and removed size/XXL labels May 18, 2020
Copy link
Contributor

@dataclouder dataclouder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First pass. More after a new round of tests

"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
)

// TestAccVcdSamlAuth explicitly tests a simple operation using SAML auth when explicit SAML
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// TestAccVcdSamlAuth explicitly tests a simple operation using SAML auth when explicit SAML
// TestAccVcdSamlAuth tests a simple operation using SAML auth when explicit SAML

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed.

vcd/auth_saml_test.go Show resolved Hide resolved
UseSamlAdfs bool `json:"useSamlAdfs"`
CustomAdfsRptId string `json:"customAdfsRptId,omitempty"`

// The below `SamlUser`, `SamlPassword` and `SamlCustomRptId` variables are optional and are
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// The below `SamlUser`, `SamlPassword` and `SamlCustomRptId` variables are optional and are
// The variables `SamlUser`, `SamlPassword` and `SamlCustomRptId` are optional and are

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed.

@@ -6,6 +6,14 @@
"user": "root",
"password": "somePassword",
"token": "Access token to be used instead of username/password",

"//": "Below 3 fields allow to set SAML credentials for tests that specifically use it.",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"//": "Below 3 fields allow to set SAML credentials for tests that specifically use it.",
"//": "The 3 fields below allow to set SAML credentials for tests that specifically use it.",

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed.


"//": "Below 3 fields allow to set SAML credentials for tests that specifically use it.",
"//": "May be useful when local user credentials are used by default.",
"//": "The below credentials will authenticate to Org specified in vcd.org parameter.",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"//": "The below credentials will authenticate to Org specified in vcd.org parameter.",
"//": "These credentials will authenticate to the Org specified in vcd.org parameter.",

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed

Copy link
Collaborator

@lvirbalas lvirbalas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Neat PR. Have one user-facing field naming/typing to resolve.

vcd/config_test.go Show resolved Hide resolved
org = "System"
url = "${var.vcd_url}"
max_retry_timeout = "${var.vcd_max_retry_timeout}"
allow_unverified_ssl = "${var.vcd_allow_unverified_ssl}"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for clearing this up!

@@ -186,7 +209,17 @@ The following arguments are used to configure the VMware vCloud Director Provide
instead of username and password. When this is set, username and password will
be ignored, but should be left in configuration either empty or with any custom values.
A token can be specified with the `VCD_TOKEN` environment variable.


* `use_saml_adfs` - (Optional) Set `true` to use SAML login flow with Active Directory Federation
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In discussions about this field. Options so far:
saml_adfs_enabled
saml_adfs_auth_enabled
auth_type = "saml_adfs" | "native" (default) | "token" | "ldap"

CC: @dataclouder @vbauzysvmware

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my vote auth_type if possible

@ghost ghost removed the size/XL label May 20, 2020
@ghost ghost added the size/XXL label May 20, 2020
Copy link
Collaborator

@lvirbalas lvirbalas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Last comments below, LGTM otherwise!

  1. Please add a line about official support for LDAP auth type to CHANGELOG.md
  2. Would like to see tests passing for @vbauzysvmware on his ADFS before merging
  3. Travis is failing

Copy link
Contributor

@dataclouder dataclouder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@vbauzys
Copy link
Contributor

vbauzys commented May 22, 2020

2. Would like to see tests passing for @vbauzysvmware on his ADFS before merging

Replicated ADFS and tested on my env.

@Didainius Didainius merged commit 8292bdb into vmware:master May 25, 2020
@Didainius Didainius deleted the saml3 branch May 25, 2020 10:46
vbauzys referenced this pull request in vbauzys/terraform-provider-vcd_archive3 Jul 1, 2020
vbauzys referenced this pull request in vbauzys/terraform-provider-vcd_archive3 Jul 1, 2020
vbauzys referenced this pull request in vbauzys/terraform-provider-vcd_archive3 Jul 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants