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

generate random password for initial okta login with heroku #13798

Merged

Conversation

atomfrede
Copy link
Member

This PR generates a random password for the initial okta login when using heroku. The password is printed to the console afterwards (or can be checked in configuration as before).

closes #13768


Please make sure the below checklist is followed for Pull Requests.

When you are still working on the PR, consider converting it to Draft (bellow reviewers) and adding skip-ci label, you can still see CI build result at your branch.

generators/heroku/index.js Outdated Show resolved Hide resolved
generators/heroku/index.js Outdated Show resolved Hide resolved
generators/heroku/index.js Outdated Show resolved Hide resolved
@atomfrede atomfrede force-pushed the 13768-random-initial-password-for-okta branch from 4ff71be to 7567458 Compare February 2, 2021 06:35
@atomfrede
Copy link
Member Author

Added a confirm prompt to make sure the user is aware of the generated password. The hint about login is now displayed after the script has been executed.

@mraible
Copy link
Contributor

mraible commented Feb 2, 2021

@atomfrede I tried to test this with your branch, but it fails to deploy to Heroku with the "build on Heroku" option. I think this is because jhipster-dependencies' SNAPSHOT is unavailable, I'm not sure.

remote: -----> Executing Maven
remote:        $ ./mvnw -Pprod,heroku -DskipTests clean dependency:list install

remote:        [INFO] Scanning for projects...

remote:        [INFO] Downloading from ossrh-snapshots: https://oss.sonatype.org/content/repositories/snapshots/tech/jhipster/jhipster-dependencies/7.0.0-SNAPSHOT/maven-metadata.xml

remote:        [INFO] Downloading from ossrh-snapshots: https://oss.sonatype.org/content/repositories/snapshots/tech/jhipster/jhipster-dependencies/7.0.0-SNAPSHOT/jhipster-dependencies-7.0.0-SNAPSHOT.pom

remote:        [ERROR] [ERROR] Some problems were encountered while processing the POMs:
remote:        [ERROR] Non-resolvable import POM: Could not find artifact tech.jhipster:jhipster-dependencies:pom:7.0.0-SNAPSHOT in ossrh-snapshots (https://oss.sonatype.org/content/repositories/snapshots/) @ line 104, column 25
remote:        [ERROR] 'dependencies.dependency.version' for tech.jhipster:jhipster-framework:jar is missing. @ line 116, column 21

remote:        [ERROR] 'dependencies.dependency.version' for javax.annotation:javax.annotation-api:jar is missing. @ line 120, column 21
remote:        [ERROR] 'dependencies.dependency.version' for org.springframework.boot:spring-boot-starter-cache:jar is missing. @ line 124, column 21

I tried to run jhipster heroku again to build locally, but it fails too.

Configuring Heroku
No new Database addon created
✖ Error: Command failed: heroku buildpacks:add heroku/java --app shrouded-mountain-34941
 ›   Error: The buildpack heroku/java is already set on your app.

    at ChildProcess.exithandler (child_process.js:308:12)
    at ChildProcess.emit (events.js:315:20)
    at maybeClose (internal/child_process.js:1048:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:288:5) {
  killed: false,
  code: 1,
  signal: null,
  cmd: 'heroku buildpacks:add heroku/java --app shrouded-mountain-34941',
  stdout: '',
  stderr: ' ›   Error: The buildpack heroku/java is already set on your app.\n'

One thing I noticed is the Maven command that's used on Heroku:

./mvnw -Pprod,heroku -DskipTests clean dependency:list install

It seems like it could be a bit shorter, like:

./mvnw -Pprod,heroku -DskipTests package

@mraible
Copy link
Contributor

mraible commented Feb 2, 2021

Related: building locally seems to run all the tests too. It's probably a good practice, but not sure if it's necessary.

[INFO] ------------------------------------------------------------------------
[INFO] Total time:  03:35 min
[INFO] Finished at: 2021-02-02T08:36:14-07:00
[INFO] ------------------------------------------------------------------------

It'd be cool if you could create and deploy a JHipster app to Heroku in 2 minutes!

@mraible
Copy link
Contributor

mraible commented Feb 2, 2021

@atomfrede I got it to work. I forgot you needed to run npm link generator-jhipster in the project after generation.

Here's what it currently says:

? You are using OAuth 2.0. Do you want to use Okta as your identity provider it yourself? When you choose Okta, the auto
mated configuration of users and groups requires cURL and jq. Yes, provision the Okta add-on
? Login (valid email) for the JHipster Admin user: matt.raible@okta.com
? Take note of this password! You will need it on your first login: 28be10ea4c0501b162c0f6dfdb0cf64a49ee767b Yes

Can we change it to the following?

? You are using OAuth 2.0. Do you want to use Okta? When you choose Okta, the automated configuration of users and groups requires cURL and jq. Yes, provision the Okta add-on
? Enter a valid email for the JHipster Admin user: matt.raible@okta.com
? Take note of this password! You will need it to sign in: 28be10ea4c0501b162c0f6dfdb0cf64a49ee767b Yes

I could also see changing the initial question to Do you want to use Okta as your identity provider? The reason I removed it is I don't think developers are that familiar with the term 'identity provider', but I could be wrong.

It'd also be cool if the password could be a different color so it's more noticeable. You probably don't want it to be blue because then the user might think "Yes" is part of it. Maybe yellow?

Screen Shot 2021-02-02 at 8 42 55 AM

At the end, there's a NaN. Not sure what that should be.

Screen Shot 2021-02-02 at 8 48 34 AM

I'm using the blog-oauth2 JDL to test. It looks like Hazlecast might be preventing a successful startup.

Screen Shot 2021-02-02 at 8 51 30 AM

@atomfrede
Copy link
Member Author

@atomfrede I got it to work. I forgot you needed to run npm link generator-jhipster in the project after generation.

Here's what it currently says:

? You are using OAuth 2.0. Do you want to use Okta as your identity provider it yourself? When you choose Okta, the auto
mated configuration of users and groups requires cURL and jq. Yes, provision the Okta add-on
? Login (valid email) for the JHipster Admin user: matt.raible@okta.com
? Take note of this password! You will need it on your first login: 28be10ea4c0501b162c0f6dfdb0cf64a49ee767b Yes

Can we change it to the following?

? You are using OAuth 2.0. Do you want to use Okta? When you choose Okta, the automated configuration of users and groups requires cURL and jq. Yes, provision the Okta add-on
? Enter a valid email for the JHipster Admin user: matt.raible@okta.com
? Take note of this password! You will need it to sign in: 28be10ea4c0501b162c0f6dfdb0cf64a49ee767b Yes

I could also see changing the initial question to Do you want to use Okta as your identity provider? The reason I removed it is I don't think developers are that familiar with the term 'identity provider', but I could be wrong.

Sure.

It'd also be cool if the password could be a different color so it's more noticeable. You probably don't want it to be blue because then the user might think "Yes" is part of it. Maybe yellow?

Need to check if we can use different colors for the prompts

Screen Shot 2021-02-02 at 8 42 55 AM

At the end, there's a NaN. Not sure what that should be.

Screen Shot 2021-02-02 at 8 48 34 AM

I'm using the blog-oauth2 JDL to test. It looks like Hazlecast might be preventing a successful startup.

Screen Shot 2021-02-02 at 8 51 30 AM

The NaN is wrong. Will check. It should be EMAIL/PASSWORD.

@mraible
Copy link
Contributor

mraible commented Feb 2, 2021

I tried again without Hazelcast and it worked. I like the "reset your password on first use flow!"

Besides the other edits I suggested, it might be cool to spit out the credentials at the end. I'm not sure we need to tell them they'll need to change their password afterward.

Okta configured successfully!

Use $email/$password to sign in. 

@atomfrede
Copy link
Member Author

It now looks like this

image

Screenshot-20210202222434-887x151

generators/heroku/index.js Outdated Show resolved Hide resolved
Copy link
Contributor

@mraible mraible left a comment

Choose a reason for hiding this comment

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

@atomfrede I would change the end messages to capitalize JHipster. There's a jhipster in there.

@atomfrede atomfrede force-pushed the 13768-random-initial-password-for-okta branch from c2b75a6 to 44eb227 Compare February 2, 2021 21:37
@atomfrede atomfrede merged commit 35d30ba into jhipster:main Feb 3, 2021
@atomfrede
Copy link
Member Author

@pascalgrimaud
Copy link
Member

@atomfrede : approved

@pascalgrimaud pascalgrimaud added this to the v7.0.0-beta.2 milestone Feb 20, 2021
coderguy-tech pushed a commit to coderguy-tech/generator-jhipster that referenced this pull request Jun 1, 2021
…#13798)

* generate random password for initial okta login with heroku

closes jhipster#13768

* fix password prompt and display of login at the end

* remove identity provider from prompt
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.

Okta password rules have changed. JHipster + Heroku needs updating.
3 participants