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

Default admin/user accounts don't work on Monolithic app w/ H2 disk-based persistence #24608

Closed
1 task done
cfreyer opened this issue Dec 19, 2023 · 6 comments · Fixed by #25312
Closed
1 task done

Comments

@cfreyer
Copy link

cfreyer commented Dec 19, 2023

Overview of the issue

After generating a new Monolithic app with H2 disk-based persistence, the standard Administrator and User accounts do not allow login. No console warnings are given. This functionality worked before my upgrade to jhipster 8.1.0, so I suspect this is a regression.

Motivation for or Use Case

Previous new projects have allowed admin and user accounts to login with no issues

Reproduce the error

Run jhipster at the command line. Answer questions as follows:
? What is the base name of your application? sample
? Which type of application would you like to create? Monolithic application (recommended for simple projects)
? Do you want to generate a feign client? No
? Besides Junit, which testing frameworks would you like to use?
? Do you want to make it reactive with Spring WebFlux? No
? What is your default Java package name? com.mycompany.myapp
? Which type of authentication would you like to use? JWT authentication (stateless, with a token)
? Which type of database would you like to use? SQL (H2, PostgreSQL, MySQL, MariaDB, Oracle, MSSQL)
? Which production database would you like to use? PostgreSQL
? Which development database would you like to use? H2 with disk-based persistence
? Which cache do you want to use? (Spring cache abstraction) No cache - Warning, when using an SQL database, this will disable the Hibernate 2nd level cache!
? Would you like to use Maven or Gradle for building the backend? Maven
? Which other technologies would you like to use? API first development using OpenAPI-generator
INFO! Disabling hibernate cache for cache provider no
? Which Framework would you like to use for the client? Vue <-- also fails w/ Angular (didn't test React)
? Besides Jest/Vitest, which testing frameworks would you like to use?
? Do you want to generate the admin UI? Yes
? Would you like to use a Bootswatch theme (https://bootswatch.com/)? Default JHipster
? Would you like to enable internationalization support? Yes
? Please choose the native language of the application English
? Please choose additional languages to install Spanish
info Generating 2,048 bit RSA key pair and self-signed certificate (SHA256withRSA) with a validity of 99,999 days
........

And then ./mvnw and attempt to login at http://localhost:8080/

Related issues

None

Suggest a Fix

I'll

JHipster Version(s)
JHipster configuration
[email protected] /home/chris/code/sample
└── [email protected]
JHipster configuration, a .yo-rc.json file generated in the root folder
.yo-rc.json file
{
  "generator-jhipster": {
    "applicationType": "monolith",
    "authenticationType": "jwt",
    "baseName": "sample",
    "buildTool": "maven",
    "cacheProvider": "no",
    "clientFramework": "vue",
    "clientTestFrameworks": [],
    "clientTheme": "none",
    "creationTimestamp": 1702955049083,
    "databaseType": "sql",
    "devDatabaseType": "h2Disk",
    "devServerPort": 9060,
    "enableGradleEnterprise": null,
    "enableHibernateCache": false,
    "enableSwaggerCodegen": true,
    "enableTranslation": true,
    "entities": [],
    "feignClient": false,
    "gradleEnterpriseHost": null,
    "jhipsterVersion": "8.1.0",
    "languages": [
      "en",
      "es"
    ],
    "messageBroker": false,
    "microfrontend": null,
    "microfrontends": [],
    "nativeLanguage": "en",
    "packageName": "com.mycompany.myapp",
    "prodDatabaseType": "postgresql",
    "reactive": false,
    "searchEngine": false,
    "serverPort": null,
    "serverSideOptions": [
      "enableSwaggerCodegen:true"
    ],
    "serviceDiscoveryType": false,
    "testFrameworks": [],
    "websocket": false,
    "withAdminUi": true
  }
}
Environment and Tools

openjdk version "17.0.9" 2023-10-17
OpenJDK Runtime Environment GraalVM CE 17.0.9+9.1 (build 17.0.9+9-jvmci-23.0-b22)
OpenJDK 64-Bit Server VM GraalVM CE 17.0.9+9.1 (build 17.0.9+9-jvmci-23.0-b22, mixed mode, sharing)

git version 2.39.2

node: v18.18.2
npm: 10.2.5

Docker version 24.0.7, build afdd53b

JDL for the Entity configuration(s) entityName.json files generated in the .jhipster directory
JDL entity definitions

Entity configuration(s) entityName.json files generated in the .jhipster directory

None created yet

Browsers and Operating System

lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux 12 (bookworm)
Release: 12
Codename: bookworm

uname -a ──(Mon,Dec18)─┘
Linux pluto 6.1.0-13-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.55-1 (2023-09-29) x86_64 GNU/Linux

Browser:
Google Chrome
Version 119.0.6045.159 (Official Build) (64-bit)

  • Checking this box is mandatory (this is just to show you read everything)
@mraible
Copy link
Contributor

mraible commented Dec 19, 2023

Using h2 disk-based persistence worked fine for me when I tried it with 8.1.0 and Angular last week as part of my jhipster8-demo tutorial and screencast.

Copy link
Contributor

github-actions bot commented Dec 19, 2023

JHipster has completed the sample check
.yo-rc.json: valid
Entities JDL: blank
Application: successfully generated
Frontend check: success
Backend check: success
E2E check: success

This check uses jhipster info output from the issue description to generate the sample.
Bug report that does not contain this information will be marked as invalid.

@mshima
Copy link
Member

mshima commented Dec 21, 2023

I could not reproduce:

jhipster from-issue 24608
cd jhipster-samples/24608
./mvnw

user/user 👍
admin/admin 👍

@cfreyer
Copy link
Author

cfreyer commented Dec 22, 2023

Discovered that this is a token-relate issue. Repro case:

  1. generate an app, start it, login as admin (and check the "remember me" box)
  2. shutdown the app, delete it on disk
  3. generate another app, start it, repeat the same login process
    Login fails due to leftover jhi-authenticationToken in browser local storage.
    Delete the token & try again...should be successful.

This happened to me because I ran the generator multiple times (testing different front-ends).
Might happen to others if they generate or use multiple jhipster apps on the same host/port.

This isn't strictly a defect, but has to do with token management.

@cevheri
Copy link
Contributor

cevheri commented Feb 17, 2024

Discovered that this is a token-relate issue. Repro case:

  1. generate an app, start it, login as admin (and check the "remember me" box)
  2. shutdown the app, delete it on disk
  3. generate another app, start it, repeat the same login process
    Login fails due to leftover jhi-authenticationToken in browser local storage.
    Delete the token & try again...should be successful.

This happened to me because I ran the generator multiple times (testing different front-ends). Might happen to others if they generate or use multiple jhipster apps on the same host/port.

This isn't strictly a defect, but has to do with token management.

thanks @cfreyer. it works in private window

@mshima
Copy link
Member

mshima commented Feb 23, 2024

This is a bug. Probably happens with expired jwt token too.

@deepu105 deepu105 added this to the 8.2.0 milestone Mar 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants