JHipster: Enable anonymous users to read entity, but not update it - security

I have generated a JHipster application using these values:
{
"generator-jhipster":
{
"jhipsterVersion": "4.13.0",
"baseName": "app",
"packageName": "my.app",
"packageFolder": "my/app",
"serverPort": "8080",
"authenticationType": "session",
"hibernateCache": "ehcache",
"clusteredHttpSession": "no",
"websocket": "no",
"databaseType": "sql",
"devDatabaseType": "h2Disk",
"prodDatabaseType": "mysql",
"searchEngine": "elasticsearch",
"buildTool": "gradle",
"enableSocialSignIn": false,
"rememberMeKey": "",
"clientFramework": "angularX",
"useSass": true,
"applicationType": "monolith",
"testFrameworks": [],
"jhiPrefix": "jhi",
"enableTranslation": false
}
}
I would like to allow anonymous users to view an entity, but not update or delete that entity.
I have tried editing the generated SecurityConfiguration.java file to add permitAll(HttpMethod.GET,"/**") for authorizeRequests() in the configure(HttpSecurity http) method.
.and()
.authorizeRequests()
.antMatchers(HttpMethod.GET, "/api/products").permitAll()
I am still getting this message when I try to access the entity.
Resolved exception caused by Handler execution: org.springframework.security.authentication.InsufficientAuthenticationException: Full authentication is required to access this resource
I know is similar to this question: JHipster: Enable anonymous users to read entity, but not update?
I have tried to use the same solution here but it's not working. Is there something I should change in the front end ?
Can you help me on this?
Thank you

Related

Rust generates calls to __truncdfsf2, which it claims not to support?

I'm writing some Rust code for an Atmega328. I understand that it does not have built in support for floats, so I will need to provide some sort of soft implementation of floating point routines that I want to use, like those found in compiler-builtins. However, even after including compiler-builtins, I get the following:
quaternion.rs:54: undefined reference to `__truncdfsf2'
Looking at the page for compiler-builtins, I see that there are no plans to support __truncdfsf2, since apparently it "involves floating-point types ("f128", "f80" and complex numbers) that are not supported by Rust."
Can anyone help me understand why Rust/LLVM seems to be generating calls that Rust apparently doesn't support? And is there a way to go about solving this?
Here's my target.json for reference.
{
"arch": "avr",
"atomic-cas": false,
"cpu": "atmega328",
"data-layout": "e-P1-p:16:8-i8:8-i16:8-i32:8-i64:8-f32:8-f64:8-n8-a:8",
"eh-frame-header": false,
"exe-suffix": ".elf",
"executables": true,
"late-link-args": {
"gcc": [
"-lgcc"
]
},
"linker": "avr-gcc",
"linker-is-gnu": true,
"llvm-target": "avr-unknown-unknown",
"max-atomic-width": 8,
"no-default-libraries": false,
"no-compiler-rt": true,
"target-c-int-width": "16",
"target-pointer-width": "16",
"pre-link-args": {
"gcc": [
"-mmcu=atmega328",
"-Wl,--as-needed"
]
},
"vendor": "unknown",
"os": "none",
"target-endian": "little"
}

Any possible ways to add answer for this question "may we anonymously report usage statistics to improve the tool over time?" in .yo-rc.json

Is there any possible ways to add answer for this question "may we anonymously report usage statistics to improve the tool over time?", which is asked as the 1st question when I hit "yo jhipster --force" on cmd, in .yo-rc.json. My .yo-rc.json file contains different required details but no answer for the above mentioned question.
As the jhipster gets reinstalled everytime deployment is done on kubernets and the image gets recreated, and then jhipster command ran from script, it gets stuck at the first question prompt whose answer I am expecting to be taken from .yo-rc.json file, which is otherwise a manual task to go into cmd and manually answer the prompt for every deployment.
I am attaching my .yo-rc.json file. Please help me with my requirement.
{
"generator-jhipster": {
"baseName": "localApp",
"packageName": "com.cg.localApp",
"packageFolder": "com/cg/localApp",
"serverPort": "*****",
"authenticationType": "session",
"hibernateCache": "ehcache",
"clusteredHttpSession": "no",
"websocket": false,
"databaseType": "sql",
"devDatabaseType": "h2Disk",
"prodDatabaseType": "mysql",
"searchEngine": false,
"buildTool": "maven",
"enableSocialSignIn": false,
"useSass": true,
"applicationType": "monolith",
"testFrameworks": ["gatling", "cucumber", "protractor"],
"jhiPrefix": "cg",
"enableTranslation": false,
"jhipsterVersion": "6.10.3",
"cacheProvider": "ehcache",
"messageBroker": false,
"serviceDiscoveryType": false,
"rememberMeKey": "****",
"embeddableLaunchScript": false,
"clientPackageManager": "npm",
"clientFramework": "angularX",
"clientTheme": "none",
"creationTimestamp": 1608305785798,
"entitySuffix": "",
"dtoSuffix": "DTO",
"otherModules": [],
"blueprints": []
}
}
There's an undocumented command line option --no-insight which does this, so you could use in .yo-rc.json as "noInsight": true.
But deployment process should not require jhipster command, so I suspect something is wrong in your approach.

Jhipster The entity cannot be generated as the application does not have a database configured in gateway

I am using jhipster version v6.5.0
When I am creating microservice gateway it asks for a database with the following error.
ERROR! Error: The entity cannot be generated as the application does not have a database configured!
Actually First I created a gateway with database and entities will work after my microservices are not running. That means it works as monolithic and I could see all JPA servicers in the gateway. Swagger API showing fine. But menu from Entities not using microservices.
.yo-rc.json
{
"generator-jhipster": {
"promptValues": {
"packageName": "com.xxx.gate",
"nativeLanguage": "en"
},
"jhipsterVersion": "6.5.0",
"applicationType": "gateway",
"baseName": "myGate2",
"packageName": "com.xxx.gate",
"packageFolder": "com/xxx/gate",
"serverPort": "8080",
"authenticationType": "jwt",
"cacheProvider": "hazelcast",
"enableHibernateCache": false,
"websocket": "spring-websocket",
"databaseType": "no",
"devDatabaseType": "no",
"prodDatabaseType": "no",
"searchEngine": false,
"messageBroker": false,
"serviceDiscoveryType": "eureka",
"buildTool": "maven",
"enableSwaggerCodegen": false,
"jwtSecretKey": "XXXXXXXX",
"embeddableLaunchScript": false,
"useSass": true,
"clientPackageManager": "npm",
"clientFramework": "angularX",
"clientTheme": "lumen",
"clientThemeVariant": "dark",
"jhiPrefix": "jhi",
"entitySuffix": "",
"dtoSuffix": "DTO",
"otherModules": [],
"enableTranslation": true,
"nativeLanguage": "en",
"languages": [
"en"
],
"blueprints": []
}
Please help
JHipster gateway does not persist entities, it's the responsibility of the microservices. This is why you are not able to generate entities in your gateway, the gateway will only import your microservices entities to generate frontend for them.
Rather than converting your monolith into a gateway, you should import your existing entities into a new service.
I tried several possibilities. After changing my angular service class below it starts working as expected(calling microservice rather going directly to gateway).
Generated
public resourceUrl = SERVER_API_URL + 'api/countries';
Changed to
public resourceUrl = SERVER_API_URL + 'services/myservice/api/countries';
I am not sure that is the correct way that Jhipster expected. I have noticed that in gateway SORS filter too.
If you have any git project build with Angular Entities it would be great to understand better.
Thank you for your attention and help.

jhipster changing users image URL

I am trying to use picture stored on HD as a profile picture of jhipster user, I'm having troubles with the url. I have tried :
file:///C:/Users/ab/Documents/myApp/uploads/profile_picture.png - Not worked.
Also tryed to place profile_picture in the same folder as the navbar.components.html and changing the url to just: profile_picture.png, but the image did not appear on the navbar. However when i am using any img url from any Google image, the profile picture is there.
As I am new with Jhipster I would like to know what am i doing wrong?
Is it possible to use pictures on HD as a jhipster user's profile picture?
Thanks in advance!
All about my project:
"jhipsterVersion": "4.14.1",
"serverPort": "8080",
"authenticationType": "jwt",
"cacheProvider": "ehcache",
"enableHibernateCache": true,
"websocket": false,
"databaseType": "sql",
"devDatabaseType": "h2Disk",
"prodDatabaseType": "mysql",
"searchEngine": false,
"messageBroker": false,
"serviceDiscoveryType": false,
"buildTool": "maven",
"enableSocialSignIn": true,
"enableSwaggerCodegen": false,
"jwtSecretKey": "",
"clientFramework": "angularX",
"useSass": false,
"clientPackageManager": "yarn",
"applicationType": "monolith",
"jhiPrefix": "jhi",
"enableTranslation": false
Finally solved my problem!
It was really obvious. In your JHipster app directory, there is a file named target/www/content which is accessible from the server. So, in your database, in JHI-USERS table, in img_url field write: content/NAME_OF_PICTURE.png and it will work.

jhipster import-jdl not generating entities from jdl file

I have created a jdl file using jdl-studio.
I tied to create entities from jdl file using jdl-import.
following is the snippet of my cmd terminal:
D:\spring-boot\examples\espressob>yo jhipster:import-jdl ./jhipster-jdl.jh
The jdl is being imported.
D:\spring-boot\examples\espressob>
the problem
It just prints that the jdl file is being imported, thats it.
I have checked if it generated code for entities from the jdl file, unfortunately it did not.
Env details
.yo-rc.json file content :
{
"generator-jhipster": {
"jhipsterVersion": "3.4.2",
"baseName": "espressob",
"packageName": "com.iwantunlimited.espressob",
"packageFolder": "com/iwantunlimited/espressob",
"serverPort": "8080",
"authenticationType": "jwt",
"hibernateCache": "hazelcast",
"clusteredHttpSession": "hazelcast",
"websocket": "spring-websocket",
"databaseType": "sql",
"devDatabaseType": "postgresql",
"prodDatabaseType": "postgresql",
"searchEngine": "elasticsearch",
"buildTool": "maven",
"enableSocialSignIn": true,
"jwtSecretKey": "790501d7e04040394e33964a4ee715408ec0408f",
"useSass": true,
"applicationType": "monolith",
"testFrameworks": [
"gatling",
"cucumber",
"protractor"
],
"jhiPrefix": "jhi",
"enableTranslation": true,
"nativeLanguage": "en",
"languages": [
"en",
"fr",
"hi"
]
}
}
jhipster-jdl.jh file content:
entity InsuranceCategory {
name String required,
description String,
isActive Boolean,
createdDate ZonedDateTime,
modifiedDate ZonedDateTime,
}
relationship ManyToOne {
InsuranceCategory{createdBy} to User
}
relationship ManyToOne {
InsuranceCategory{modifiedBy} to User
}
entity InsuranceProvider {
name String required,
isActive Boolean,
createdDate ZonedDateTime,
modifiedDate ZonedDateTime,
}
relationship ManyToOne {
InsuranceProvider{createdBy} to User
}
relationship ManyToOne {
InsuranceProvider{modifiedBy} to User
}
relationship ManyToMany {
InsuranceCategory{provider} to InsuranceProvider{category}
}
entity Policy {
name String required,
isActive Boolean,
createdDate ZonedDateTime,
modifiedDate ZonedDateTime,
}
relationship ManyToOne {
Policy{createdBy} to User
}
relationship ManyToOne {
Policy{modifiedBy} to User
}
relationship OneToMany {
InsuranceCategory{policy} to Policy
}
relationship OneToMany {
InsuranceProvider{policy} to Policy
}
dto all with mapstruct
Tried :
removing relationships with User entity -> not working
re arranging sequence of entries in jdl file (first all entities, then relationships) -> not working
I try your jdl-file with jhipster 3.6.1 version and it works with the following warning:
$ yo jhipster:import-jdl ./jhipster-jdl.jh
The jdl is being parsed.
**Warning: An Entity name 'User' was used: 'User' is an entity created by default by JHipster. All relationships toward it will be kept but any attributes and relationships from it will be disregarded.**
Writing entity JSON files.
Generating entities...
Also would recommend removing the commas at the end of the last field in the entities definitions:
entity InsuranceProvider {
name String required,
isActive Boolean,
createdDate ZonedDateTime,
modifiedDate ZonedDateTime
}
Instead of:
entity InsuranceProvider {
name String required,
isActive Boolean,
createdDate ZonedDateTime,
modifiedDate ZonedDateTime ,
}

Resources