Skip to content

Commit

Permalink
Merge pull request #30 from pavankjadda/development
Browse files Browse the repository at this point in the history
release version 7.0.0
  • Loading branch information
pavankjadda authored Feb 4, 2023
2 parents a5bef10 + c7ce691 commit fb88bbb
Show file tree
Hide file tree
Showing 41 changed files with 8,240 additions and 24,578 deletions.
13 changes: 6 additions & 7 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.0</version>
<version>2.7.8</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.pj</groupId>
<artifactId>keycloak</artifactId>
<version>6.0.0</version>
<version>7.0.0</version>
<name>KeyCloak-Angular-SpringSecurity</name>
<description>Demo project for KeyCloak and Spring Security</description>

Expand All @@ -35,7 +35,7 @@
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-spring-boot-starter</artifactId>
<version>18.0.0</version>
<version>20.0.3</version>
</dependency>

<dependency>
Expand All @@ -50,9 +50,8 @@
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
Expand Down
45 changes: 15 additions & 30 deletions src/main/java/com/pj/keycloak/security/SecurityConfig.java
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
package com.pj.keycloak.security;

import org.keycloak.adapters.springboot.KeycloakSpringBootConfigResolver;
import org.keycloak.adapters.springsecurity.KeycloakSecurityComponents;
import org.keycloak.adapters.springsecurity.authentication.KeycloakAuthenticationProvider;
import org.keycloak.adapters.springsecurity.KeycloakConfiguration;
import org.keycloak.adapters.springsecurity.config.KeycloakWebSecurityConfigurerAdapter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.FilterType;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.core.authority.mapping.SimpleAuthorityMapper;
import org.springframework.security.core.session.SessionRegistryImpl;
import org.springframework.security.web.authentication.session.RegisterSessionAuthenticationStrategy;
import org.springframework.security.web.authentication.session.SessionAuthenticationStrategy;
Expand All @@ -22,36 +17,22 @@

import java.util.Collections;

@Configuration
@EnableWebSecurity
@ComponentScan(basePackageClasses = {KeycloakSecurityComponents.class},
excludeFilters = @ComponentScan.Filter(type = FilterType.REGEX, pattern = "org.keycloak.adapters.springsecurity.management.HttpSessionManager"))
public class SecurityConfig extends KeycloakWebSecurityConfigurerAdapter
{
@KeycloakConfiguration
@ConditionalOnProperty(name = "keycloak.enabled", havingValue = "false", matchIfMissing = true)
public class SecurityConfig extends KeycloakWebSecurityConfigurerAdapter {
@Autowired
public void configureGlobal(AuthenticationManagerBuilder authenticationManagerBuilder)
{
KeycloakAuthenticationProvider keycloakAuthenticationProvider=keycloakAuthenticationProvider();
keycloakAuthenticationProvider.setGrantedAuthoritiesMapper(new SimpleAuthorityMapper());
authenticationManagerBuilder.authenticationProvider(keycloakAuthenticationProvider);
public void configureGlobal(AuthenticationManagerBuilder authenticationManagerBuilder) {
authenticationManagerBuilder.authenticationProvider(keycloakAuthenticationProvider());
}

@Bean
@Override
protected SessionAuthenticationStrategy sessionAuthenticationStrategy()
{
protected SessionAuthenticationStrategy sessionAuthenticationStrategy() {
return new RegisterSessionAuthenticationStrategy(new SessionRegistryImpl());
}

@Bean
public KeycloakSpringBootConfigResolver keycloakSpringBootConfigResolver()
{
return new KeycloakSpringBootConfigResolver();
}

@Override
protected void configure(HttpSecurity http) throws Exception
{
protected void configure(HttpSecurity http) throws Exception {
super.configure(http);

http.authorizeRequests()
Expand All @@ -64,10 +45,14 @@ protected void configure(HttpSecurity http) throws Exception
http.csrf().disable();
}

@Bean
public KeycloakSpringBootConfigResolver keycloakSpringBootConfigResolver() {
return new KeycloakSpringBootConfigResolver();
}

//Cors filter to accept incoming requests
@Bean
CorsConfigurationSource corsConfigurationSource()
{
CorsConfigurationSource corsConfigurationSource() {
CorsConfiguration configuration = new CorsConfiguration();
configuration.applyPermitDefaultValues();
configuration.setAllowedMethods(Collections.singletonList("*"));
Expand Down
3 changes: 3 additions & 0 deletions src/webapp/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/dist
.angular
src/assets/css/vendor
9 changes: 9 additions & 0 deletions src/webapp/.prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"printWidth": 140,
"singleQuote": true,
"trailingComma": "es5",
"semi": true,
"bracketSameLine": true,
"useTabs": true,
"endOfLine": "auto"
}
Loading

0 comments on commit fb88bbb

Please sign in to comment.