oauth not working with jhipster - jhipster

after generating a jhipster application (folowing the tutorial), the application runs well but I cannot login with my 'user' or 'admin' account. I see the following in the log:
[DEBUG] com.chomnoue.jstarter2.security.UserDetailsService - Authenticating jhip
sterapp
meaning that the application is trying to authenticate "jhipsterapp" instead of "user".
Following is the content of my .yo-rc.json file
{
"generator-jhipster": {
"baseName": "jstarter",
"packageName": "com.chomnoue.jstarter",
"packageFolder": "com/chomnoue/jstarter",
"authenticationType": "token",
"hibernateCache": "hazelcast",
"clusteredHttpSession": "hazelcast",
"websocket": "atmosphere",
"databaseType": "sql",
"devDatabaseType": "h2Memory",
"prodDatabaseType": "mysql",
"useCompass": true,
"frontendBuilder": "grunt",
"javaVersion": "8"
}
}
any help please?

Related

Incorrect version of jest trying to run jest

I have jest tests in my angular project.
I have a package.json file specifying the version of jest I would like to use to run the test. The file includes:
"#types/jest": "^24.0.18",
"jest": "^24.9.0",
"jest-preset-angular": "^7.1.1",
The jest config also includes:
"setupFilesAfterEnv": [
"<rootDir>/setup-jest.ts"
],
This is where the issue occurs. When trying to run jest, I get the following message:
● Validation Warning:
Unknown option "setupFilesAfterEnv" with value ["<rootDir>/setup-jest.ts"] was found.
This is probably a typing mistake. Fixing it will remove this message.
Configuration Documentation:
https://jestjs.io/docs/configuration.html
I had a look at jest -h and found a flag which gives me the setup of the jest environment.
jest --showConfig
This however shows that I am running jest on version
"version": "23.6.0"
So my question lies here. How come after I do an npm i, the jest version trying to run the tests is different / old.
I tried installing jest-cli with the -g flag and the save-dev flag.
Also trying to run tests in VS Code, if thats any help.
Please help.
Thank you in advance.
Full log of npx jest --showConfig
● Validation Warning:
Unknown option "setupFilesAfterEnv" with value ["<rootDir>/setup-jest.ts"] was found.
This is probably a typing mistake. Fixing it will remove this message.
Configuration Documentation:
https://jestjs.io/docs/configuration.html
{
"configs": [
{
"automock": false,
"browser": false,
"cache": true,
"cacheDirectory": "/var/folders/bs/wrvrgl6132df8l5ndxv40m3m0000gn/T/jest_dx",
"clearMocks": false,
"coveragePathIgnorePatterns": [
"/node_modules/",
"setup-jest.ts"
],
"detectLeaks": false,
"detectOpenHandles": false,
"errorOnDeprecated": false,
"filter": null,
"forceCoverageMatch": [],
"globals": {
"ts-jest": {
"tsConfig": "<rootDir>/tsconfig.spec.json",
"stringifyContentPathRegex": "\\.html$",
"astTransformers": [
"jest-preset-angular/InlineHtmlStripStylesTransformer"
]
}
},
"haste": {
"providesModuleNodeModules": []
},
"moduleDirectories": [
"node_modules"
],
"moduleFileExtensions": [
"ts",
"html",
"js",
"json"
],
"moduleNameMapper": [
[
"#app/(.*)",
"/Users/name/Projects/project/src/app/$1"
],
...
],
"modulePathIgnorePatterns": [],
"name": "6caa4...",
"prettierPath": "/Users/name/Projects/project/node_modules/prettier/index.js",
"resetMocks": false,
"resetModules": false,
"resolver": null,
"restoreMocks": false,
"rootDir": "/Users/name/Projects/project",
"roots": [
"/Users/name/Projects/project"
],
"runner": "jest-runner",
"setupFiles": [],
"setupTestFrameworkScriptFile": null,
"skipFilter": false,
"snapshotSerializers": [],
"testEnvironment": "/Users/name/Projects/project/node_modules/jest-environment-jsdom-thirteen/build/index.js",
"testEnvironmentOptions": {},
"testLocationInResults": false,
"testMatch": [
"**/__tests__/**/*.js?(x)",
"**/?(*.)+(spec|test).js?(x)"
],
"testRegex": "",
"testRunner": "/Users/name/node_modules/jest-jasmine2/build/index.js",
"testURL": "http://localhost",
"timers": "real",
"transform": [
[
"^.+\\.(ts|js|html)$",
"/Users/name/Projects/project/node_modules/ts-jest/dist/index.js"
]
],
"watchPathIgnorePatterns": []
}
],
"globalConfig": {
"bail": false,
"changedFilesWithAncestor": false,
"collectCoverage": true,
"collectCoverageFrom": null,
"coverageDirectory": "/Users/name/Projects/project/coverage",
"coverageReporters": [
"json",
"text",
"lcov",
"clover"
],
"coverageThreshold": null,
"detectLeaks": false,
"detectOpenHandles": false,
"errorOnDeprecated": false,
"expand": false,
"filter": null,
"globalSetup": null,
"globalTeardown": null,
"listTests": false,
"maxWorkers": 7,
"noStackTrace": false,
"nonFlagArgs": [],
"notify": false,
"notifyMode": "always",
"passWithNoTests": false,
"projects": null,
"rootDir": "/Users/name/Projects/project",
"runTestsByPath": false,
"skipFilter": false,
"testFailureExitCode": 1,
"testPathPattern": "",
"testResultsProcessor": null,
"updateSnapshot": "new",
"useStderr": false,
"verbose": null,
"watch": false,
"watchman": true
},
"version": "23.6.0"
}
Showing npm config get log here too:
; cli configs
metrics-registry = "http://.../.../npm-group/"
scope = ""
user-agent = "npm/6.9.0 node/v10.15.3 darwin x64"
; project config /Users/user/Projects/project/.npmrc
registry = "http://.../.../npm-group/"
; node bin location = /Users/user/.nvm/versions/node/v10.15.3/bin/node
; cwd = /Users/user/Projects/project
; HOME = /Users/user
; "npm config ls -l" to show all defaults.
I had the same issue, after a long search I've tried this:
type jest
Which gave me the location:
/usr/local/bin/jest
Renaming this file (or deleting it), solved the problem (note that now running jest will give command not found).

Create new application

I want creates a new app in azure directory using azure rest api (not with the protal).
Is there any document that describes this process?
Thanks
Note
This document describes how can we create a new app using azure portal.
https://learn.microsoft.com/fr-fr/azure/active-directory/develop/active-directory-integrating-applications
I am looking if there any method to make the same but with Azure Rest API
Update
{
"odata.metadata": "https://graph.windows.net/{tenantID}/$metadata#directoryObjects/Microsoft.DirectoryServices.Application/#Element",
"odata.type": "Microsoft.DirectoryServices.Application",
"objectType": "Application",
"objectId": "ed32872e-9bf2-427c-8006-3cc69f88bfae",
"deletionTimestamp": null,
"acceptMappedClaims": null,
"addIns": [],
"appId": "6e8dbbc1-1a7e-44a8-9994-d59d454af941",
"appRoles": [],
"availableToOtherTenants": true,
"displayName": "AppAzure2",
"errorUrl": null,
"groupMembershipClaims": null,
"homepage": "http://www.monsite22/callback",
"identifierUris": [
"https://****.onmicrosoft.com/F2F37cd1d-c44d-4f72-a747-7d702d80a8df"
],
"informationalUrls": {
"termsOfService": null,
"support": null,
"privacy": null,
"marketing": null
},
"isDeviceOnlyAuthSupported": null,
"keyCredentials": [],
"knownClientApplications": [],
"logoutUrl": null,
"logo#odata.mediaContentType": "application/json;odata=minimalmetadata",
"logoUrl": null,
"oauth2AllowIdTokenImplicitFlow": false,
"oauth2AllowImplicitFlow": false,
"oauth2AllowUrlPathMatching": false,
"oauth2Permissions": [
{
"adminConsentDescription": "Allow the application to access AppAzure2 on behalf of the signed-in user.",
"adminConsentDisplayName": "Access AppAzure2",
"id": "872ba752-9974-4862-b5b7-bdc7a3d03df7",
"isEnabled": true,
"type": "User",
"userConsentDescription": "Allow the application to access AppAzure2 on your behalf.",
"userConsentDisplayName": "Access AppAzure2",
"value": "user_impersonation"
}
],
"oauth2RequirePostResponse": false,
"optionalClaims": null,
"orgRestrictions": [],
"parentalControlSettings": {
"countriesBlockedForMinors": [],
"legalAgeGroupRule": "Allow"
},
"passwordCredentials": [],
"publicClient": false,
"publisherDomain": null,
"recordConsentConditions": null,
"replyUrls": [
"http://www.monsite22/callback"
],
"requiredResourceAccess": [],
"samlMetadataUrl": null,
"signInAudience": "AzureADMultipleOrgs",
"tokenEncryptionKeyId": null
}
Request Body
POST /******-91a0-4978-b46e-***********/applications?api-version=1.6 HTTP/1.1
Host: graph.windows.net
Content-Type: application/json
Authorization: Bearer ********************************************************
Cache-Control: no-cache
Postman-Token: 3daf6fe8-87db-cc48-35f0-c90901354610
{
"displayName":"AppAzure2",
"publicClient":false,
"identifierUris":[
"https://******.onmicrosoft.com/F2F37cd1d-c44d-4f72-a747-7d702d80a8df"
],
"homepage":"http://www.monsite22/callback",
"replyUrls":[
"http://www.monsite22/callback"
],
"availableToOtherTenants":true
}
Token
{
"aud": "00000002-0000-0000-c000-000000000000",
"iss": "https://sts.windows.net/9440940f-91a0-4978-b46e-5ee05d7bd605/",
"iat": 1528890289,
"nbf": 1528890289,
"exp": 1528894189,
"aio": "Y2dgYBCPvL2QwVKroXbzbYbLLs9PAgA=",
"appid": "***-c780-4861-a331-18400c3e5a30",
"appidacr": "1",
"idp": "https://sts.windows.net/9440940f-91a0-4978-b46e-5ee05d7bd605/",
"oid": "***-183f-4817-961d-****",
"roles": [
"Device.ReadWrite.All",
"Directory.Read.All",
"Member.Read.Hidden",
"Directory.ReadWrite.All",
"Domain.ReadWrite.All",
"Application.ReadWrite.OwnedBy",
"Application.ReadWrite.All"
],
"sub": "****-183f-4817-961d-****",
"tenant_region_scope": "EU",
"tid": "*****-91a0-4978-b46e-******",
"uti": "mNzY050I0kOHMlog1Xg7AA",
"ver": "1.0"
}
Yes, there is. You can find the documentation here; Applications - Create.
By the way, I found this by using the awesome REST API Browser.
Welcome to the REST API Browser – your one-stop shop for REST APIs from Microsoft. Start searching for any REST APIs by typing in the box below.

Microservice Backend project with Jhipster 4.3.0 does not create User tables

Microservice Backend project with Jhipster 4.3.0 does not create User tables (jhi_user, jhi_authotity, jhi_user_authority) only (jhi_persistent_audit-event, jhi_persistent_audit-event_data) are created
Here is the result of command: yo jhipster:info
Welcome to the JHipster Information Sub-Generator
##### **JHipster Version(s)**
```
`enter code here`D:\.....\git\dolly-ms-app-consul\dolly-backend
`-- generator-jhipster#4.3.0
### **JHipster configuration, a `.yo-rc.json` file generated in the root folder**
```yaml
{
"generator-jhipster": {
"promptValues": {
"packageName": "com.mycompany.myapp",
"nativeLanguage": "fr"
},
"jhipsterVersion": "4.3.0",
"baseName": "dollybackend",
"packageName": "com.mycompany.myapp",
"packageFolder": "com/mycompany/myapp",
"serverPort": "8081",
"authenticationType": "jwt",
"hibernateCache": "hazelcast",
"clusteredHttpSession": false,
"websocket": false,
"databaseType": "sql",
"devDatabaseType": "mysql",
"prodDatabaseType": "mysql",
"searchEngine": false,
"messageBroker": false,
"serviceDiscoveryType": "consul",
"buildTool": "maven",
"enableSocialSignIn": false,
"jwtSecretKey": "aa600103f58d769cb4077acccbf8bdfc276b0eb2",
"enableTranslation": true,
"applicationType": "microservice",
"clientPackageManager": "yarn",
"testFrameworks": [
"gatling",
"cucumber"
],
"jhiPrefix": "jhi",
"skipClient": true,
"skipUserManagement": true,
"nativeLanguage": "fr",
"languages": [
"fr",
"en"
]
}
}
```
##### **Entity configuration(s) `entityName.json` files generated in the `.jhipster` directory**
Client.json
```yaml
{
"fluentMethods": true,
"relationships": [],
"fields": [
{
"fieldName": "idClient",
"fieldType": "BigDecimal",
"fieldValidateRules": [
"required"
]
},
{
"fieldName": "numeroCniClient",
"fieldType": "BigDecimal",
"fieldValidateRules": [
"required"
]
},
{
"fieldName": "dateNaisClient",
"fieldType": "LocalDate",
"fieldValidateRules": [
"required"
]
},
],
"changelogDate": "20170511190126",
"javadoc": "Customer entity.\n#author The JHipster team.",
"entityTableName": "client",
"dto": "mapstruct",
"pagination": "pager",
"service": "serviceImpl"
}
CompteBancaire.json ```yaml {…}
Transaction.json ```yaml {….}
TypeCompteBancaire.json ```yaml {….}
TypeTransaction.json ```yaml {….}
```
##### **Browsers and Operating System**
java version "1.8.0_92"
Java(TM) SE Runtime Environment (build 1.8.0_92-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.92-b14, mixed mode)
git version 2.12.2.windows.2
node: v7.3.0
npm: 3.10.10
bower: 1.8.0
gulp:[09:46:49] CLI version 3.9.1
yarn: 0.23.4
Docker version 17.03.1-ce, build c6d412e
docker-compose version 1.11.1, build 7afaa436
With jhipster microservices, your users won't be stored in every microservices. They should be stored in one microservice and referenced loosely by identifier. Notice that your output has
"skipClient": true,
"skipUserManagement": true
This will be a backend microservice and if your microservice needs the user, its identifier can be found in the JWT that gets passed as an authorization header and (I think) gets set in your spring security principal.

Jhipster application hangs on Pivotal Cloud Foundry after printing banner

I've created a JHipster application using the following
yo jhipster
yo jhipster:cloudfoundry
However, when I push to PCF, the app starts, hangs after printing the banner and gets killed after a minute.
The only customization I've tried is changing the URLs in some properties to point to a JHipster registry deployed on cloudfoundry as described in the jhipster documentation.
This is my .yo-rc.json file:
{
"generator-jhipster": {
"promptValues": {
"packageName": "com.mycompany.myapp"
},
"jhipsterVersion": "4.3.0",
"baseName": "test",
"packageName": "com.mycompany.myapp",
"packageFolder": "com/mycompany/myapp",
"serverPort": "8081",
"authenticationType": "jwt",
"hibernateCache": "hazelcast",
"clusteredHttpSession": false,
"websocket": false,
"databaseType": "sql",
"devDatabaseType": "h2Disk",
"prodDatabaseType": "mysql",
"searchEngine": false,
"messageBroker": false,
"serviceDiscoveryType": "eureka",
"buildTool": "gradle",
"enableSocialSignIn": false,
"jwtSecretKey": "bec0ab8352f04338c8c1db2fd572022c1bf877fe",
"enableTranslation": false,
"applicationType": "microservice",
"testFrameworks": [],
"jhiPrefix": "jhi",
"skipClient": true,
"skipUserManagement": true,
"clientPackageManager": "yarn"
}
}
The app needed to be correctly configured to use the registry as described in JHipster Documentation: Doing Microservices.
In the bootstrap-prod.yml file, the spring.cloud.config.uri must point to http:///config/
In the application-prod.yml file, the eureka.client.serviceUrl.defaultZone must point to http:///eureka/
By default, the JHipster registry is authenticated with an admin:admin user, so the files above also need to be configured as described in the Spring Cloud docs.
spring:
cloud:
config:
uri: https://myconfig.mycompany.com
username: user
password: secret

Monolithic app and load balancing by F5

Can we use an F5 load balancer to scale monolithic jhipster application?
On https://jhipster.github.io/security/ it is mentioned that we can
scale application on several different servers using JWT.
Are there any tips to do this, or we can just load balance it by directing the user on different instance of the app?
Regards.
Here is the .yo-rc.json :
{
"generator-jhipster": {
"jhipsterVersion": "3.12.1",
"baseName": "app",
"packageName": "com.example.app",
"packageFolder": "com/example/app",
"serverPort": "8080",
"authenticationType": "jwt",
"hibernateCache": "ehcache",
"clusteredHttpSession": false,
"websocket": false,
"databaseType": "sql",
"devDatabaseType": "h2Disk",
"prodDatabaseType": "postgresql",
"searchEngine": false,
"messageBroker": false,
"buildTool": "maven",
"enableSocialSignIn": false,
"jwtSecretKey": "**",
"useSass": false,
"applicationType": "monolith",
"testFrameworks": [
"gatling"
],
"jhiPrefix": "jhi",
"otherModules": [
{
"name": "generator-jhipster-entity-audit",
"version": "2.2.2"
}
],
"enableTranslation": true,
"nativeLanguage": "fr",
"languages": [
"fr"
]
}
}
short answer: yes, you can simply scale your application to several instances running in parallel, and the user won't notice any difference
precise answer: the key difference between JWT and classical stateful approach, like HTTP Session with cookies, is that there is no need to store the user session server side, as the interesting information is already contained inside a JWT. When your user is logging in, the JHipster application returns a JSON Webtoken, containing all permissions and principal data of the user, signed with the secret key. Using this secret key, every instance of your application can verify the JWT is correct.

Resources