-
Notifications
You must be signed in to change notification settings - Fork 90
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
Authenticate using Snowflake authentication mechanism #4315
Conversation
Signed-off-by: Iliyan Velichkov <[email protected]>
Signed-off-by: Iliyan Velichkov <[email protected]>
Signed-off-by: Iliyan Velichkov <[email protected]>
Signed-off-by: Iliyan Velichkov <[email protected]>
Signed-off-by: Iliyan Velichkov <[email protected]>
Signed-off-by: Iliyan Velichkov <[email protected]>
Signed-off-by: Iliyan Velichkov <[email protected]>
Signed-off-by: Iliyan Velichkov <[email protected]>
Signed-off-by: Iliyan Velichkov <[email protected]>
Signed-off-by: Iliyan Velichkov <[email protected]>
Signed-off-by: Iliyan Velichkov <[email protected]>
Signed-off-by: Iliyan Velichkov <[email protected]>
Signed-off-by: Iliyan Velichkov <[email protected]>
Signed-off-by: Iliyan Velichkov <[email protected]>
Signed-off-by: Iliyan Velichkov <[email protected]>
...c/main/java/org/eclipse/dirigible/components/security/snowflake/SnowflakeSecurityConfig.java
Fixed
Show fixed
Hide fixed
Signed-off-by: Iliyan Velichkov <[email protected]>
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.
+1 Seems good to me
…ation # Conflicts: # components/data/data-source-snowpark/src/main/java/org/eclipse/dirigible/components/data/source/snowpark/SnowflakeDatabaseConfigurator.java
1b6bdd4
to
eea4a18
Compare
…rkaround for invalidating the cookie Signed-off-by: Iliyan Velichkov <[email protected]>
login-logout.mov |
Signed-off-by: Iliyan Velichkov <[email protected]>
@@ -44,7 +42,7 @@ | |||
SecurityFilterChain filterChain(HttpSecurity http, TenantContextInitFilter tenantContextInitFilter) throws Exception { | |||
http.cors(Customizer.withDefaults()) | |||
.httpBasic(Customizer.withDefaults()) | |||
.csrf(csrf -> csrf.disable()) | |||
.csrf(csrf -> csrf.disable())// if enabled, some functionalities will not work - like creating a project |
Check failure
Code scanning / CodeQL
Disabled Spring CSRF protection High
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI about 1 month ago
To fix the problem, we need to enable CSRF protection and handle any specific functionalities that might break due to this change. One approach is to selectively disable CSRF protection for specific endpoints that require it, while keeping it enabled for the rest of the application.
- Enable CSRF Protection: Remove the
csrf.disable()
line to enable CSRF protection globally. - Selective CSRF Disabling: If certain endpoints need CSRF protection to be disabled, configure the
HttpSecurity
object to selectively disable CSRF for those endpoints.
-
Copy modified line R45
@@ -44,3 +44,3 @@ | ||
.httpBasic(Customizer.withDefaults()) | ||
.csrf(csrf -> csrf.disable())// if enabled, some functionalities will not work - like creating a project | ||
.csrf(Customizer.withDefaults()) // Enable CSRF protection | ||
.addFilterBefore(tenantContextInitFilter, UsernamePasswordAuthenticationFilter.class) |
SecurityFilterChain filterChain(HttpSecurity http, TenantContextInitFilter tenantContextInitFilter) throws Exception { | ||
LOGGER.info("Configure snowflake security configurations"); | ||
http.cors(Customizer.withDefaults()) | ||
.csrf(csrf -> csrf.disable()) // if enabled, some functionalities will not work - like creating a project |
Check failure
Code scanning / CodeQL
Disabled Spring CSRF protection High
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI about 1 month ago
To fix the problem, we need to enable CSRF protection while ensuring that the application's functionalities are not broken. This can be achieved by configuring CSRF protection to ignore specific endpoints or using CSRF tokens appropriately.
- Enable CSRF Protection: Remove the
csrf.disable()
call. - Configure CSRF Protection: If certain endpoints need to be excluded from CSRF protection, configure them explicitly.
- Update Methods and Imports: Ensure that the necessary methods and imports are in place to support the new configuration.
-
Copy modified line R47
@@ -46,3 +46,3 @@ | ||
http.cors(Customizer.withDefaults()) | ||
.csrf(csrf -> csrf.disable()) // if enabled, some functionalities will not work - like creating a project | ||
.csrf(csrf -> csrf.ignoringAntMatchers("/specific-endpoint-to-ignore")) // Enable CSRF protection and ignore specific endpoints if necessary | ||
.logout(logout -> logout.deleteCookies("JSESSIONID") |
with zero the ingress returns 500 Signed-off-by: Iliyan Velichkov <[email protected]>
Example flow for the scenario in which path logout-using-path.mov |
Signed-off-by: Iliyan Velichkov <[email protected]>
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.
Awesome!
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.
+1 Seems good to me.
When the Dirigible is deployed on Snowflake as container service, users should be able to authenticated in the application with Snowflake authentication mechanism only. Currently, double authentication is used.
The PR adds a new spring profile for Snowflake called
snowflake
.The profile relies on the propagated logged in user for the authentication as described in this tutorial. Additional details here.
Example env variable:
SPRING_PROFILES_ACTIVE=snowflake
An additional optional env variable was introduced called
DIRIGIBLE_SNOWFLAKE_ADMIN_USERNAME
.Using this configuration, an user can be automatically initialized with all available Dirigible roles. Later on, you can use this user to assign roles to other users.
When a user loggin to the application for the first time, a new user registration is automatically created in the system DB if missing.
I didn't find a proper way to implement logout. I have created a Snowflake ticket for that.
I verified the Snowflake UDF scenario works with the current implementation.
Login flow:
Screen.Recording.2024-09-26.at.15.23.43.mov