Skip to content
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

240 azure oauth2 #254

Open
wants to merge 35 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
2157721
#240 use azure AD
Jul 4, 2023
793e7d2
#240 working state but some bugs
Jul 4, 2023
4d7595f
#240 bugfixes
Jul 7, 2023
07045d4
#240 csrf fix
Jul 8, 2023
8e9dd1c
#240 clean up
Jul 8, 2023
5d9a51a
#240 profile
Jul 11, 2023
7e3abae
#240 disable csrf
Jul 11, 2023
ebc0f7e
#240 spring to 2.7.4
Jul 13, 2023
1d309a9
#240 fixing redirect to login
Jul 25, 2023
55114b0
#240 fixing Circular viewpath exception
Aug 31, 2023
cc2db17
#240 fix exclude
Aug 31, 2023
21db42e
#240 fix auth user at session scope
Sep 25, 2023
6719de9
#240 logging
Sep 28, 2023
5621d90
#240 error-handling & Save icon
Sep 28, 2023
bf34fbd
#240 error-handling
Sep 28, 2023
a1d77a2
Add or update the App Service deployment workflow configuration from …
youseeus Sep 28, 2023
db22554
#240 try to get a CI-Pipeline
Sep 28, 2023
56a2f22
#240 fix save report
Sep 28, 2023
e348b48
#240 fix save report
Sep 28, 2023
e1729e1
#240 try to get a CI-Pipeline
Sep 28, 2023
9ee6276
#240 try to get a CI-Pipeline
Sep 28, 2023
2c5986d
#240 remove Password-change
Nov 1, 2023
6088fe3
e2e-tests
Nov 1, 2023
3146afb
e2e-tests
Nov 3, 2023
559df91
e2e-tests
Nov 3, 2023
a97862f
e2e-tests
Nov 3, 2023
4900250
e2e-tests
Nov 4, 2023
2f9c908
e2e-tests
Nov 4, 2023
d548cbb
e2e-tests
Nov 6, 2023
379a6b6
e2e-tests playwright java
Nov 6, 2023
41a1111
#240 change to Spring-oauth2
Nov 9, 2023
e167203
#240 fix save part 1
Nov 10, 2023
4aa5f0a
#240 Workaround for the inability of struts to take 'form' attributes
Nov 14, 2023
c1b66cc
#240 e2eTest-Configuration
Nov 20, 2023
acc9c62
#240 cors
Nov 20, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .github/workflows/build-war-and-container.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,8 @@ jobs:
src: ghcr.io/hbtgmbh/salat:ci
dst: |
${{ steps.meta.outputs.tags }}

# - name: 'Run Azure webapp deploy action using publish profile credentials'
# uses: azure/webapps-deploy@v2
# with:
# app-name: salat-test
# publish-profile: ${{ secrets.azureWebAppPublishProfile }}
33 changes: 24 additions & 9 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.4</version>
<version>2.7.8</version>

<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>de.hbt.salat</groupId>
Expand All @@ -27,12 +28,26 @@
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>com.azure.spring</groupId>
<artifactId>spring-cloud-azure-starter-active-directory</artifactId>
<version>4.8.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<artifactId>spring-boot-starter-oauth2-client</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId>
<scope>test</scope>
</dependency>
<!-- <dependency>-->
<!-- <groupId>com.azure.spring</groupId>-->
<!-- <artifactId>spring-cloud-azure-starter-active-directory</artifactId>-->
<!-- </dependency>-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
Expand All @@ -48,11 +63,6 @@
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
Expand Down Expand Up @@ -82,6 +92,11 @@
<artifactId>spring-security-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
Expand Down Expand Up @@ -219,7 +234,7 @@
<dependency>
<groupId>org.webjars.npm</groupId>
<artifactId>bootstrap-icons</artifactId>
<version>1.10.3</version>
<version>1.11.1</version>
</dependency>

</dependencies>
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/org/tb/SalatApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,17 @@
import org.springframework.boot.actuate.autoconfigure.security.servlet.ManagementWebSecurityAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration;
import org.springframework.boot.autoconfigure.web.servlet.error.ErrorMvcAutoConfiguration;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.transaction.annotation.EnableTransactionManagement;

@EnableWebSecurity
@EnableJpaRepositories
@EnableJpaAuditing
@EnableTransactionManagement
@SpringBootApplication(exclude = { SecurityAutoConfiguration.class, ManagementWebSecurityAutoConfiguration.class})
@SpringBootApplication(exclude = { ErrorMvcAutoConfiguration.class, SecurityAutoConfiguration.class, ManagementWebSecurityAutoConfiguration.class})
public class SalatApplication {

public static void main(String[] args) {
Expand Down
39 changes: 39 additions & 0 deletions src/main/java/org/tb/auth/AadOAuth2LoginSecurityConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package org.tb.auth;

import com.azure.spring.cloud.autoconfigure.aad.AadWebSecurityConfigurerAdapter;
import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Profile;
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;

@RequiredArgsConstructor
@EnableWebSecurity
@EnableGlobalMethodSecurity(prePostEnabled = true)
@Profile({"test","prod","local"})
public class AadOAuth2LoginSecurityConfig extends AadWebSecurityConfigurerAdapter {

final private HbtAuthenticationFilter hbtAuthenticationFilter;

/**
* Add configuration logic as needed.
*/
@Override
protected void configure(HttpSecurity http) throws Exception {
super.configure(http);
http
//.addFilterAfter(hbtAuthenticationFilter, )
.authorizeHttpRequests(
(authorize) -> authorize
.antMatchers(HbtAuthenticationFilter.EXCLUDE_PATTERN.toArray(new String[0]))
.permitAll()
.antMatchers("/**")
//.hasRole("salat-user")
//.anyRequest()
.authenticated()
)
.csrf().disable()
Fixed Show fixed Hide fixed
// .csrf().csrfTokenRepository(CookieCsrfTokenRepository.withHttpOnlyFalse())
;
}
}
8 changes: 4 additions & 4 deletions src/main/java/org/tb/auth/AuthService.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@
import static org.tb.common.util.SecureHashUtils.legacyPasswordMatches;
import static org.tb.common.util.SecureHashUtils.passwordMatches;

import java.time.*;
import java.time.Clock;
import java.time.Duration;
import java.time.LocalDate;
import java.util.HashSet;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.StreamSupport;

import javax.annotation.PostConstruct;
import lombok.Data;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Value;
Expand All @@ -19,8 +21,6 @@
import org.tb.employee.domain.Employee;
import org.tb.employee.persistence.EmployeeRepository;

import javax.annotation.PostConstruct;

@Service
@RequiredArgsConstructor
public class AuthService {
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/tb/auth/AuthorizedUser.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package org.tb.auth;

import static java.lang.Boolean.TRUE;
import static org.springframework.web.context.WebApplicationContext.SCOPE_REQUEST;
import static org.springframework.web.context.WebApplicationContext.SCOPE_SESSION;
import static org.tb.common.GlobalConstants.EMPLOYEE_STATUS_ADM;
import static org.tb.common.GlobalConstants.EMPLOYEE_STATUS_BL;
import static org.tb.common.GlobalConstants.EMPLOYEE_STATUS_BO;
Expand All @@ -15,7 +15,7 @@
import org.tb.employee.domain.Employee;

@Component
@Scope(value = SCOPE_REQUEST, proxyMode = ScopedProxyMode.TARGET_CLASS)
@Scope(value = SCOPE_SESSION, proxyMode = ScopedProxyMode.TARGET_CLASS)
@Data
public class AuthorizedUser implements Serializable {

Expand Down
Loading
Loading