-
Notifications
You must be signed in to change notification settings - Fork 40
Jwttoken implementation #106
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
Changes from all commits
ff301e4
ecabd88
4030d56
71b15ba
1d2e222
9688378
5670ba5
2c61996
f679f75
d995ab9
ea9d72c
9fd406e
f484251
f2161c8
635263c
8fe74d9
1439253
ca3a465
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -16,4 +16,5 @@ tm-url=http://localhost:8089/ | |||||
| fhir-url=http://localhost:8093/ | ||||||
|
|
||||||
| # Redis Config | ||||||
| spring.redis.host=localhost | ||||||
| spring.redis.host=localhost | ||||||
| cors.allowed-origins=http://localhost:* | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. π‘ Verification agent π§© Analysis chainSecurity concern: Wildcard port in CORS configuration. Using Consider specifying explicit ports or using environment-specific configurations instead of wildcards. -cors.allowed-origins=http://localhost:*
+cors.allowed-origins=http://localhost:3000,http://localhost:4200Verify if this wildcard configuration is used in production environments: π Script executed: #!/bin/bash
# Check if wildcard CORS origins are used in production configs
echo "Checking for wildcard CORS configurations in production-like environments..."
rg -n "cors\.allowed-origins.*\*" --type propertiesLength of output: 251 π Script executed: #!/bin/bash
echo "Searching for wildcard CORS origins in all .properties files..."
# Use glob filter instead of --type to include .properties files
rg -n "cors\.allowed-origins.*\*" -g '*.properties'Length of output: 368 Restrict wildcard ports in CORS configuration Allowing Files to update:
Suggested change (example portsβadjust as needed): -cors.allowed-origins=http://localhost:*
+cors.allowed-origins=http://localhost:3000,http://localhost:4200π Committable suggestion
Suggested change
π€ Prompt for AI Agents |
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| package com.iemr.common.identity.config; | ||
|
|
||
| import java.util.Arrays; | ||
|
|
||
| import org.springframework.beans.factory.annotation.Value; | ||
| import org.springframework.context.annotation.Configuration; | ||
| import org.springframework.web.servlet.config.annotation.CorsRegistry; | ||
| import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; | ||
|
|
||
| @Configuration | ||
| public class CorsConfig implements WebMvcConfigurer { | ||
| @Value("${cors.allowed-origins}") | ||
| private String allowedOrigins; | ||
|
|
||
| @Override | ||
| public void addCorsMappings(CorsRegistry registry) { | ||
| registry.addMapping("/**").allowedOriginPatterns( | ||
| allowedOrigins != null && !allowedOrigins.trim().isEmpty() ? Arrays.stream(allowedOrigins.split(",")) | ||
| .map(String::trim).filter(s -> !s.isEmpty()).toArray(String[]::new) : new String[0]) | ||
| .allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS").allowedHeaders("*") | ||
| .exposedHeaders("Authorization", "Jwttoken").allowCredentials(true).maxAge(3600); | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
π‘ Verification agent
β Verification inconclusive
Wildcard port in
cors.allowed-originsis likely ignored by Springhttp://localhost:*is not interpreted as a valid wildcard by SpringβsCorsConfiguration#setAllowedOrigins, so no origin will actually match and CORS will still fail in local testing.Suggested fix β either enumerate the concrete ports you use, or switch the Java config to
setAllowedOriginPatternsand keep a wildcard there:or update
CorsConfigto rely onsetAllowedOriginPatternsinstead.Fix CORS allowed-origins: wildcard port is ignored
Springβs
CorsConfiguration#setAllowedOriginsonly matches exact origins. The patternhttp://localhost:*will not match any origin, so CORS requests will still be blocked.Please update
src/main/environment/1097_example.properties(lines 20β21) using one of these options:setAllowedOriginPatterns(...)instead ofsetAllowedOrigins(...).π Committable suggestion
π€ Prompt for AI Agents