Skip to content

Commit

Permalink
[SHIBUI-1226]
Browse files Browse the repository at this point in the history
initial auditor aware for pac4j
extra configuration for debugging in database
rename field for mariadb compatibility
  • Loading branch information
jj committed Feb 13, 2019
1 parent 74e8e78 commit 880100b
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import lombok.Getter;
import lombok.Setter;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.validation.constraints.NotNull;

Expand All @@ -21,5 +22,6 @@ public RegexScheme() {
}

@NotNull
@Column(name = "match_regex")
private String match;
}
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,14 @@ public JPAEntityDescriptorServiceImpl(OpenSamlObjects openSamlObjects, EntitySer
public EntityDescriptor createDescriptorFromRepresentation(final EntityDescriptorRepresentation representation) {
EntityDescriptor ed = openSamlObjects.buildDefaultInstanceOfType(EntityDescriptor.class);
ed.setEntityID(representation.getEntityId());
/*
User user = userService.getCurrentUser();
if (user != null) {
ed.setCreatedBy(user.getUsername());
} else {
LOGGER.warn("Current user was null! Who is logged in?");
}
*/

// setup SPSSODescriptor
if (representation.getServiceProviderSsoDescriptor() != null) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package net.unicon.shibui.pac4j;

import org.springframework.data.domain.AuditorAware;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;

import java.util.Optional;

public class Pac4jAuditorAware implements AuditorAware<String> {
@Override
public Optional<String> getCurrentAuditor() {
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
if (authentication == null) {
return Optional.empty();
}
return Optional.of(authentication.getName());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.annotation.Order;
import org.springframework.data.domain.AuditorAware;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.config.http.SessionCreationPolicy;
Expand Down Expand Up @@ -93,4 +94,9 @@ public void configure(org.springframework.security.config.annotation.web.builder
web.httpFirewall(firewall);
}
}

@Bean
public AuditorAware<String> defaultAuditorAware() {
return new Pac4jAuditorAware();
}
}
10 changes: 10 additions & 0 deletions pac4j-module/src/test/docker/conf/application.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
spring:
profiles:
include:
datasource:
platform: mariadb
driver-class-name: org.mariadb.jdbc.Driver
url: jdbc:mariadb://db:3306/shibui
username: shibui
password: shibui
jpa:
properties:
hibernate:
dialect: org.hibernate.dialect.MariaDBDialect
server:
port: 8443
ssl:
Expand Down
15 changes: 14 additions & 1 deletion pac4j-module/src/test/docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
version: "3.7"

services:
db:
image: mariadb
container_name: db
environment:
MYSQL_USER: shibui
MYSQL_PASSWORD: shibui
MYSQL_DATABASE: shibui
MYSQL_RANDOM_ROOT_PASSWORD: "yes"
networks:
- front
ports:
- 3306:3306
shibui:
image: unicon/shibui-pac4j
entrypoint: ["/usr/bin/java", "-Dspring.profiles.active=dev", "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005", "-jar", "app.jar"]
Expand All @@ -13,7 +25,8 @@ services:
- ./conf/application.yml:/application.yml
networks:
- front

depends_on:
- db
mailhog:
image: mailhog/mailhog:latest
ports:
Expand Down

0 comments on commit 880100b

Please sign in to comment.