Spaces:
Sleeping
Sleeping
Update src/main/java/com/example/config/SecurityConfig.java
Browse files
src/main/java/com/example/config/SecurityConfig.java
CHANGED
|
@@ -34,42 +34,30 @@ public class SecurityConfig {
|
|
| 34 |
.logout(logout -> logout.logoutSuccessUrl("/"))
|
| 35 |
.oidcLogout(oidc -> oidc.backChannel(Customizer.withDefaults()))
|
| 36 |
.headers(headers -> headers
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
.policy(org.springframework.security.web.header.writers.ReferrerPolicyHeaderWriter.ReferrerPolicy.STRICT_ORIGIN_WHEN_CROSS_ORIGIN)
|
| 65 |
-
)
|
| 66 |
-
|
| 67 |
-
// 6. Permissions Policy (FIXED: Using the new permissionsPolicyHeader method)
|
| 68 |
-
.permissionsPolicyHeader(permissions -> permissions
|
| 69 |
-
.policy("geolocation=(), microphone=(), camera=(), payment=(), usb=()")
|
| 70 |
-
)
|
| 71 |
-
);
|
| 72 |
-
|
| 73 |
-
return http.build();
|
| 74 |
-
}
|
| 75 |
-
}
|
|
|
|
| 34 |
.logout(logout -> logout.logoutSuccessUrl("/"))
|
| 35 |
.oidcLogout(oidc -> oidc.backChannel(Customizer.withDefaults()))
|
| 36 |
.headers(headers -> headers
|
| 37 |
+
.defaultsDisabled() // Disable defaults so they don't conflict with HF proxy
|
| 38 |
+
.contentTypeOptions(Customizer.withDefaults())
|
| 39 |
+
.frameOptions(frame -> frame.sameOrigin())
|
| 40 |
+
.httpStrictTransportSecurity(hsts -> hsts
|
| 41 |
+
.includeSubDomains(true)
|
| 42 |
+
.maxAgeInSeconds(31536000)
|
| 43 |
+
)
|
| 44 |
+
.contentSecurityPolicy(csp -> csp
|
| 45 |
+
.policyDirectives("default-src 'self'; " +
|
| 46 |
+
"script-src 'self' 'unsafe-inline' 'unsafe-eval'; " +
|
| 47 |
+
"style-src 'self' 'unsafe-inline'; " +
|
| 48 |
+
"img-src 'self' data:; " +
|
| 49 |
+
"connect-src 'self' https://learnifymedhub-kc.hf.space; " +
|
| 50 |
+
"frame-ancestors 'self' https://huggingface.co; " + // Allow HF to frame your app
|
| 51 |
+
"form-action 'self';")
|
| 52 |
+
)
|
| 53 |
+
.referrerPolicy(referrer -> referrer
|
| 54 |
+
.policy(org.springframework.security.web.header.writers.ReferrerPolicyHeaderWriter.ReferrerPolicy.STRICT_ORIGIN_WHEN_CROSS_ORIGIN)
|
| 55 |
+
)
|
| 56 |
+
.permissionsPolicyHeader(permissions -> permissions
|
| 57 |
+
.policy("geolocation=(), microphone=(), camera=(), payment=(), usb=()")
|
| 58 |
+
)
|
| 59 |
+
);
|
| 60 |
+
|
| 61 |
+
return http.build();
|
| 62 |
+
}
|
| 63 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|