Monolithic app and load balancing by F5 - jhipster

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.

Related

Unexpected search results from Azure Cognitive Search

I recently developed an index on Azure. I have the following index structure:
{"name": "my_index",
"fields":
[
{"name": "id", "type": "Edm.String", "filterable": true, "key": true, "searchable": true, "sortable": true, "facetable": false},
{"name": "metadata_storage_path", "type": "Edm.String", "searchable": false, "filterable": false, "retrievable": true, "sortable": false, "facetable": false},
{"name": "Name", "type": "Edm.String", "searchable": true, "retrievable": true, "filterable": true, "sortable": false, "facetable": true, "analyzer": "en.microsoft"},
{"name": "Description", "type": "Edm.String", "searchable": true, "retrievable": true, "filterable": false, "sortable": false, "facetable": false, "analyzer": "en.microsoft"},
{"name": "Content", "type": "Edm.String", "searchable": true, "retrievable": true, "filterable": false, "sortable": false, "facetable": false, "analyzer": "en.microsoft"}
}
When I try to search an entire phrase, for example, "cloud platform", I get some top results without any mention of "cloud platform" which is a bit strange. When I then look at the search.score, even the top results have very low score like 0.07. However, I could see the phrases appearing in the documents and I expect to have enough documents containing the phrase.
Does anyone know why that might be the case? Is it because I used the wrong analyzer?
Any potential tests I can try would also be hugely appreciated.
are you querying using REST or SDK, in both cases an example request will help to understand your issue better.
If I were doing this using REST it will be like this
https://<yourserviceName>.search.windows.net/indexes/<yourIndexName>/docs?api-version=2020-06-30&search=*&%24filter=description%20eq%20'cloud platform'
Note to make sure the exact match happens I am using filter instead of search.

Azure search: how to create a search index of complex type for blobs

I have a blob storage that has a number of folders, each folder has a number of pdf documents. I now want to create an azure search index which indexes the data by folder level, but includes a complex type structure (Collection(edm.ComplexType) that allows me to include all the documents. So the index looks like this:
{"name": "index",
"fields":
[
{"name": "id", "type": "Edm.String", "filterable": true, "key": true, "searchable": true, "sortable": true, "facetable": false},
{"name": "folderName", "type": "Collection(Edm.String)", "searchable": true, "retrievable": true, "filterable": true, "sortable": false, "facetable": true, "analyzer": "en.microsoft"},
{"name": "documents", "type": "Collection(Edm.ComplexType)",
"fields": [
{"name": "documentName", "type": "Edm.String", "searchable": true, "retrievable": true, "filterable": true, "sortable": false, "facetable": true, "analyzer": "en.microsoft"},
{"name": "content", "type": "Edm.String", "searchable": true, "retrievable": true, "filterable": false, "sortable": false, "facetable": false, "analyzer": "en.microsoft", "synonymMaps": ["synonymsmap"]},
{"name": "documentType", "type": "Collection(Edm.String)", "searchable": true, "retrievable": true, "filterable": true, "sortable": false, "facetable": true, "analyzer": "en.microsoft"},
{"name": "language", "type": "Collection(Edm.String)", "searchable": true, "retrievable": true, "filterable": true, "sortable": false, "facetable": true, "analyzer": "en.microsoft"}
]
}
]
}
Does anyone know how I should approach this? I have been creating and populating indexes using rest api.
I am thinking maybe I need to create a folder-level index structure and populate the folder-level details from some sql-table before populating the sub-fields with the blobs through skillset and indexer etc?
EDITS:
Maybe my ideas above are completely off-track. What I want to do is to search a term and return folder names based on the aggregate relevancy of documents within folders. Not sure if this is achievable in search or have to be processed afterwards. Any pointers?
Does anyone know how I should approach this? I have been creating and populating indexes using rest api.
A: If you want this structure, then you're right. You'll need to create your index and push data by yourself (rest api is one of the options)
I am thinking maybe I need to create a folder-level index structure and populate the folder-level details from some sql-table before populating the sub-fields with the blobs through skillset and indexer etc?
A: This is not a good idea, when searching using a particular term, you'll need to query all the possible indexes and do the ordering by yourself.
I personally would create a simple structure, which no complex types:
{
"name": "index",
"fields":
[
{"name": "id", "type": "Edm.String", "filterable": true, "key": true, "searchable": true, "sortable": true, "facetable": false},
{"name": "folderName", "type": "Collection(Edm.String)", "searchable": true, "retrievable": true, "filterable": true, "sortable": false, "facetable": true, "analyzer": "en.microsoft"},
{"name": "documentName", "type": "Edm.String", "searchable": true, "retrievable": true, "filterable": true, "sortable": false, "facetable": true, "analyzer": "en.microsoft"},
{"name": "content", "type": "Edm.String", "searchable": true, "retrievable": true, "filterable": false, "sortable": false, "facetable": false, "analyzer": "en.microsoft", "synonymMaps": ["synonymsmap"]},
{"name": "documentType", "type": "Collection(Edm.String)", "searchable": true, "retrievable": true, "filterable": true, "sortable": false, "facetable": true, "analyzer": "en.microsoft"},
{"name": "language", "type": "Collection(Edm.String)", "searchable": true, "retrievable": true, "filterable": true, "sortable": false, "facetable": true, "analyzer": "en.microsoft"}
]
}
want to retrieve all documents by a particular folder?
search=*&$filter=folderName eq 'abc'
want to retrieve a particular documents in a particular folder?
search=*&$filter=folderName eq 'abc' and documentName eq 'x.docx'
want to all documents that contain a particular term?
search=mickey mouse&$orderBy=folderName
simple and effective

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

oauth not working with 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?

Resources