Skip to content
This repository has been archived by the owner on Feb 5, 2020. It is now read-only.

Use Terraform to bcrypt the admin password #1771

Merged
merged 4 commits into from
Sep 28, 2017
Merged

Conversation

edevenport
Copy link
Contributor

Frontend and backend have been adjusted to use Terraform bcrypt interpolation for the adminPassword per issue #643. I have tested locally with make apply and through the UI with local terraform versions 0.9.11 and 0.10.2.

Password has been tested with the following special characters:

`-=\][';/.,~!@#$%^&*()_+|}{":?><

Backslashes and double quotes will need to be escaped when setting the password in terraform.tfvars manually (template descriptions updated accordingly), but all above special characters handled successfully through the UI.

I am unable to validate tests through Jenkins, but TF_VAR_tectonic_admin_password_hash is now TF_VAR_tectonic_admin_password and requires a plain text password.

@sym3tri sym3tri requested a review from squat August 25, 2017 12:18
@edevenport edevenport changed the title WIP: Use Terraform to bcrypt the admin password [WIP]: Use Terraform to bcrypt the admin password Aug 31, 2017
@edevenport
Copy link
Contributor Author

@squat Do you have some time to review the code and test results?

@squat
Copy link
Contributor

squat commented Aug 31, 2017

Thanks @edevenport, I'll TAL now.

@sym3tri
Copy link
Contributor

sym3tri commented Sep 1, 2017

Jenkins & GitHub are complaining about the same merge conflicts.

@sym3tri sym3tri changed the title [WIP]: Use Terraform to bcrypt the admin password Use Terraform to bcrypt the admin password Sep 1, 2017
@edevenport
Copy link
Contributor Author

ok to test

@edevenport
Copy link
Contributor Author

@sym3tri @squat I merged the latest updates from master and corrected the merge conflicts.

@cpanato
Copy link
Contributor

cpanato commented Sep 5, 2017

@edevenport there are two small issues in the lint for the frontend.

/home/ubuntu/workspace/tectonic-installer_PR-1771-MDYVNSYM5ANLWQBB6KSQTDFNNEI4ELV7WSD4XPYFG4CEHLHS2QWQ/installer/frontend/cluster-config.js
  196:37  error  'opts' is assigned a value but never used  no-unused-vars
  297:43  error  'opts' is assigned a value but never used  no-unused-vars

✖ 2 problems (2 errors, 0 warnings)

@edevenport
Copy link
Contributor Author

ok to test

@edevenport
Copy link
Contributor Author

Thank you @cpanato - the lint errors should be resolved now.

@squat
Copy link
Contributor

squat commented Sep 5, 2017

@edevenport looking better! now the frontend tests are failing with:

    Difference:
    
    - Expected
    + Received
    
    @@ -9,11 +9,11 @@
       "platform": "aws",
       "pullSecret": "<TECTONIC_PULL_SECRET>",
       "retry": false,
       "variables": Object {
         "tectonic_admin_email": "[email protected]",
    -    "tectonic_admin_password": "PASSWORD",
    +    "tectonic_admin_password": "pjazbahvw!Singon9cwh^ygsi9hoblxW",
         "tectonic_aws_extra_tags": Object {
           "test_tag": "testing",
         },
         "tectonic_aws_master_custom_subnets": Object {
           "us-west-1a": "10.0.0.0/19",

To fix this we need to update the *.progress files in installer/frontend/__tests__/examples/ and replace https://github.com/coreos/tectonic-installer/blob/master/installer/frontend/__tests__/examples/tectonic-aws-vpc.progress#L49 with the new example password you specified in the *.json files. Alternatively, the json files could all use PASSWORD as the test password.

@edevenport
Copy link
Contributor Author

ok to test

@@ -0,0 +1,277 @@
# Install Tectonic on Azure with Terraform
Copy link
Contributor

Choose a reason for hiding this comment

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

@edevenport why was this included in this PR? could we remove this doc?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@squat Sorry about that. It was updated in my original PR before it was removed from master and seems to have gotten restored during my pull. I rebased and removed the file.

@edevenport
Copy link
Contributor Author

Thank you @squat - looks like the tests are passing now.

@squat
Copy link
Contributor

squat commented Sep 6, 2017

@edevenport the tests look good. The one main outstanding issue is the azure doc. Did that sneak in accidentally?

@edevenport
Copy link
Contributor Author

ok to test

Copy link
Contributor

@squat squat left a comment

Choose a reason for hiding this comment

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

Looks great! Two small nits concerning wording.

config.tf Outdated
type = "string"

description = <<EOF
The bcrypt hash of admin user password to login to the Tectonic Console.
Use the bcrypt-hash tool (https://github.com/coreos/bcrypt-tool/releases/tag/v1.0.0) to generate it.
The admin user password to login to the Tectonic Console. Backslashes and double quotes should
Copy link
Contributor

Choose a reason for hiding this comment

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

s/should/must/ to convey that it is a requirement.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. I also moved the special character requirement to the Note line for better division between parameter description and requirements.

variable "admin_password_hash" {
description = "Hashed password used to by the cluster admin to login to the Tectonic Console. Generate with the bcrypt-hash tool (https://github.com/coreos/bcrypt-tool/releases/tag/v1.0.0)."
variable "admin_password" {
description = "Password used to by the cluster admin to login to the Tectonic Console. Backslashes and double quotes should be escaped."
Copy link
Contributor

Choose a reason for hiding this comment

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

s/should/must/ to convey that it is a requirement.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@@ -7,7 +7,7 @@ This document gives an overview of variables used in all platforms of the Tecton
| Name | Description | Type | Default |
|------|-------------|:----:|:-----:|
| tectonic_admin_email | The e-mail address used to: 1. login as the admin user to the Tectonic Console. 2. generate DNS zones for some providers.<br><br>Note: This field MUST be in all lower-case e-mail address format and set manually prior to creating the cluster. | string | - |
| tectonic_admin_password_hash | The bcrypt hash of admin user password to login to the Tectonic Console. Use the bcrypt-hash tool (https://github.com/coreos/bcrypt-tool/releases/tag/v1.0.0) to generate it.<br><br>Note: This field MUST be set manually prior to creating the cluster. | string | - |
| tectonic_admin_password | The admin user password to login to the Tectonic Console. Backslashes and double quotes should be escaped.<br><br>Note: This field MUST be set manually prior to creating the cluster. | string | - |
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for making that change. Looks like we need to make docs && make examples again now

Copy link
Contributor Author

Choose a reason for hiding this comment

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

And done.

@edevenport edevenport force-pushed the terraform_bcrypt_643 branch 2 times, most recently from c728dca to 367441d Compare September 6, 2017 19:07
squat
squat previously approved these changes Sep 6, 2017
@squat squat closed this Sep 6, 2017
@squat squat reopened this Sep 6, 2017
@squat
Copy link
Contributor

squat commented Sep 6, 2017

The tests are failing with the following error:

1 error(s) occurred:

* module.tectonic.template_dir.tectonic: 1 error(s) occurred:

* module.tectonic.template_dir.tectonic: 1:3: unknown function called: bcrypt in:

${bcrypt(var.admin_password, 12)}
Makefile:44: recipe for target 'apply' failed

This is because the smoke tests use Terraform 0.9.x, which does not have support for bcrypt. We'll need to bump that or wait for #1841.

@cpanato
Copy link
Contributor

cpanato commented Sep 7, 2017

@edevenport do you mind to rebase this PR? Thanks!

@edevenport
Copy link
Contributor Author

A merge conflict was introduced recently, so I rebased the branch and corrected the issue.

@edevenport
Copy link
Contributor Author

@squat We are ready for a review (and hopefully merger) again.

Copy link
Contributor

@s-urbaniak s-urbaniak left a comment

Choose a reason for hiding this comment

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

This LGTM modulo the hard-coded password values.

tectonic_admin_email = "[email protected]"
tectonic_admin_password_hash = "$2a$12$T8hTe.NlOPDP0SS3DxNeDuVhHSFbdGXZEhGps/W.BG4QC7.1/nDaG"
tectonic_admin_password = "password"
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's get rid of this here and inject it via an env var in CI, @cpanato do you mind to give directions here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@cpanato I have no visibility into Jenkins. Would you be able to assist me here?

type = "string"
default = "2a$12$k9wa31uE/4uD9aVtT/vNtOZwxXyEJ/9DwXXEYB/eUpb9fvEPsH/kO"
default = "password"
Copy link
Contributor

Choose a reason for hiding this comment

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

I strongly suggest to remove this default value here.

@@ -37,7 +37,7 @@
"tectonicLicense": "<TECTONIC_LICENSE>",
"pullSecret": "<TECTONIC_PULL_SECRET>",
"adminEmail": "[email protected]",
"adminPassword": "PASSWORD",
"adminPassword": "password",
Copy link
Contributor

Choose a reason for hiding this comment

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

those variables should be dependency-injected via CI, /cc @cpanato

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@cpanato Same issue here with no visibility into Jenkins.

Copy link
Contributor

@alexsomesan alexsomesan left a comment

Choose a reason for hiding this comment

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

Looks good, but I second @s-urbaniak 's suggestion of removing the hardcoded password value from the test configs. We will inject that from CI.

I'm asking myself if we should rather also keep the old variable there for a while (and fall back to using it) to provide a migration path. This is a rather sensitive change since it alters the confidentiality level of the tfvars file. I'd rather users have some time to adjust their workflows around it.

@s-urbaniak
Copy link
Contributor

ping @edevenport: do you mind to rebase+address the review comments?

@edevenport
Copy link
Contributor Author

edevenport commented Sep 26, 2017

@s-urbaniak The rebase is completed. I'll see if @cpanato can assist with the Jenkins piece.

@alexsomesan
Copy link
Contributor

retest this please

Jenkinsfile Outdated
$class: 'UsernamePasswordMultiBinding',
credentialsId: 'tectonic-console-login',
passwordVariable: 'TF_VAR_tectonic_admin_email',
usernameVariable: 'TF_VAR_tectonic_admin_password'
Copy link
Contributor

Choose a reason for hiding this comment

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

We dont need to set the admin_email/password because in the rspec tests we randon generate those.

Copy link
Contributor

Choose a reason for hiding this comment

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

can you please remove this change?

@cpanato cpanato force-pushed the terraform_bcrypt_643 branch from d476dea to 6dbacb3 Compare September 28, 2017 08:05
@cpanato
Copy link
Contributor

cpanato commented Sep 28, 2017

@edevenport @alexsomesan @s-urbaniak @squat all green now :)

Copy link
Contributor

@s-urbaniak s-urbaniak left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@alexsomesan alexsomesan merged commit 2101f86 into master Sep 28, 2017
s-urbaniak pushed a commit to s-urbaniak/tectonic-installer that referenced this pull request Oct 4, 2017
bcrypt support landed in coreos#1771 but the change was not promoted to GCP.
This fixes it.
s-urbaniak pushed a commit that referenced this pull request Oct 4, 2017
* modules/tectonic: add kube_dns_service_ip variable

This fixes a regression introduced in #2014.

* platforms/gcp: replace admin_password_hash with admin_password

bcrypt support landed in #1771 but the change was not promoted to GCP.
This fixes it.

* modules/tectonic: use literals for values of data keys

ConfigMaps in k8s are key-value pairs in a data section. The values need
to be literal YAML strings otherwise the nested YAML will be
interpreted causing a failure in deploying the ConfigMap.

This fixes another regression introduced in #2014
nreisbeck pushed a commit to nreisbeck/tectonic-installer that referenced this pull request Oct 19, 2017
@squat squat deleted the terraform_bcrypt_643 branch November 17, 2017 15:47
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants