Skip to content

Commit

Permalink
Merge pull request #3 from xdev-software/develop
Browse files Browse the repository at this point in the history
Release
  • Loading branch information
AB-xdev committed Apr 3, 2024
2 parents bc0cd3a + f694f15 commit b96c0a3
Show file tree
Hide file tree
Showing 43 changed files with 2,814 additions and 43 deletions.
4 changes: 2 additions & 2 deletions .run/Run Demo.run.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Run Demo" type="Application" factoryName="Application">
<option name="MAIN_CLASS_NAME" value="software.xdev.Application" />
<module name="standard-maven-template-demo" />
<module name="spring-security-advanced-authentication-ui-demo" />
<option name="WORKING_DIRECTORY" value="$MODULE_DIR$" />
<extension name="coverage">
<pattern>
Expand All @@ -13,4 +13,4 @@
<option name="Make" enabled="true" />
</method>
</configuration>
</component>
</component>
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# 1.0.0
<i>Initial release</i>
* All methods and functionality are designed to be overwritable (at least protected)
* The library consists of 2 main parts:
* ``extendable`` → Includes the bare minimum to make the Spring components extendable
* ``advanced`` → Contains components made on top of ``extendable`` with many customization options; Additionally:
* Updated Bootstrap to version 5.3+
* Improved SSO (OAuth2 / SAML2) UI
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ You should have the following things installed:
* Ensure that the JDK/Java-Version is correct


## Releasing [![Build](https://img.shields.io/github/actions/workflow/status/xdev-software/standard-maven-template/release.yml?branch=master)](https://github.com/xdev-software/standard-maven-template/actions/workflows/release.yml)
## Releasing [![Build](https://img.shields.io/github/actions/workflow/status/xdev-software/spring-security-advanced-authentication-ui/release.yml?branch=master)](https://github.com/xdev-software/spring-security-advanced-authentication-ui/actions/workflows/release.yml)

Before releasing:
* Consider doing a [test-deployment](https://github.com/xdev-software/standard-maven-template/actions/workflows/test-deploy.yml?query=branch%3Adevelop) before actually releasing.
* Consider doing a [test-deployment](https://github.com/xdev-software/spring-security-advanced-authentication-ui/actions/workflows/test-deploy.yml?query=branch%3Adevelop) before actually releasing.
* Check the [changelog](CHANGELOG.md)

If the ``develop`` is ready for release, create a pull request to the ``master``-Branch and merge the changes
Expand Down
39 changes: 33 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,39 @@
[![Latest version](https://img.shields.io/maven-central/v/software.xdev/standard-maven-template?logo=apache%20maven)](https://mvnrepository.com/artifact/software.xdev/standard-maven-template)
[![Build](https://img.shields.io/github/actions/workflow/status/xdev-software/standard-maven-template/checkBuild.yml?branch=develop)](https://github.com/xdev-software/standard-maven-template/actions/workflows/checkBuild.yml?query=branch%3Adevelop)
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=xdev-software_standard-maven-template&metric=alert_status)](https://sonarcloud.io/dashboard?id=xdev-software_standard-maven-template)
[![Latest version](https://img.shields.io/maven-central/v/software.xdev/spring-security-advanced-authentication-ui?logo=apache%20maven)](https://mvnrepository.com/artifact/software.xdev/spring-security-advanced-authentication-ui)
[![Build](https://img.shields.io/github/actions/workflow/status/xdev-software/spring-security-advanced-authentication-ui/checkBuild.yml?branch=develop)](https://github.com/xdev-software/spring-security-advanced-authentication-ui/actions/workflows/checkBuild.yml?query=branch%3Adevelop)
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=xdev-software_spring-security-advanced-authentication-ui&metric=alert_status)](https://sonarcloud.io/dashboard?id=xdev-software_spring-security-advanced-authentication-ui)

# standard-maven-template
# spring-security-advanced-authentication-ui

Modernizes the default Spring Web Authentication UI and makes it easier customizable.

<details><summary>Show demo</summary>

<p align="center">
<img src="./assets/demo.png" alt="Demo" />
</p>

</details>

## Usage

The library provides an adapter that can be used like this:
```java
public SecurityFilterChain configure(final HttpSecurity http) throws Exception
{
// Changing the text "Login with" to "Sign in with"
http.with(new AdvancedLoginPageAdapter<>(http), c -> c
.customizeLoginPage(p -> p.ssoLoginHeaderText("Sign in with")))
.oauth2Login(c ->
// ...
)
// ...
}
```

A more detailed scenario is available in the [demo](./spring-security-advanced-authentication-ui-demo/).

## Installation
[Installation guide for the latest release](https://github.com/xdev-software/standard-maven-template/releases/latest#Installation)
[Installation guide for the latest release](https://github.com/xdev-software/spring-security-advanced-authentication-ui/releases/latest#Installation)


## Support
Expand All @@ -16,4 +43,4 @@ If you need support as soon as possible and you can't wait for any pull request,
See the [contributing guide](./CONTRIBUTING.md) for detailed instructions on how to get started with our project.

## Dependencies and Licenses
View the [license of the current project](LICENSE) or the [summary including all dependencies](https://xdev-software.github.io/standard-maven-template/dependencies)
View the [license of the current project](LICENSE) or the [summary including all dependencies](https://xdev-software.github.io/spring-security-advanced-authentication-ui/dependencies)
2 changes: 1 addition & 1 deletion SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

## Reporting a Vulnerability

Please report a security vulnerability [on GitHub Security Advisories](https://github.com/xdev-software/standard-maven-template/security/advisories/new).
Please report a security vulnerability [on GitHub Security Advisories](https://github.com/xdev-software/spring-security-advanced-authentication-ui/security/advisories/new).
Binary file added assets/demo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions dev_infra/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
oidc-user-config.json
33 changes: 33 additions & 0 deletions dev_infra/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
## Development Infrastructure

The infrastructure contains the following:
* [Open ID Connect Mock Server](https://github.com/Soluto/oidc-server-mock) - for login in
* Available at http://localhost:4011

### Setup
* Requires Docker

#### OIDC
* Create ``oidc-user-config.json`` from [``oidc-user-config.json.template``](./oidc-user-config.json.template)
* File should not be tracked in Git
* Fill in your login details like mail, name, password


### Usage
Note: Commands are all executed inside a shell/CMD in the current folder. ([Tip for windows users](https://stackoverflow.com/a/40146208))

| Use case | What to do? |
| --- | --- |
| Starting the infrastructure | ``docker compose up`` |
| Stopping (and removing) the infrastructure | ``docker compose down`` |
| (Re)Building the infrastructure<br/>e.g. after changes to the Dockerfiles | ``docker compose build --pull`` |

See also ``docker compose --help``

### Additional notes
⚠ The containers don't automatically restart after a PC restart!

⚠ After a PC restart the infrastructure is still present but it's stopped.<br/>
In this case you have 2 options:
* start the existing infrastructure again (``docker compose up``) or
* do a clean start by first removing (``docker compose down``) and then starting the infrastructure
69 changes: 69 additions & 0 deletions dev_infra/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
version: "3"

services:
# Docs: https://docs.duendesoftware.com
oidc-server-mock:
container_name: oidc-server-mock
image: ghcr.io/soluto/oidc-server-mock:0.9.0
environment:
ASPNETCORE_ENVIRONMENT: Development
SERVER_OPTIONS_INLINE: |
{
"AccessTokenJwtType": "JWT",
"Discovery": {
"ShowKeySet": true
},
"Authentication": {
"CookieSameSiteMode": "Lax",
"CheckSessionCookieSameSiteMode": "Lax"
}
}
LOGIN_OPTIONS_INLINE: |
{
"AllowRememberLogin": false
}
LOGOUT_OPTIONS_INLINE: |
{
"AutomaticRedirectAfterSignOut": true
}
USERS_CONFIGURATION_PATH: /tmp/config/oidc-user-config.json
CLIENTS_CONFIGURATION_INLINE: |
[
{
"ClientId": "client-id",
"ClientSecrets": [
"client-secret"
],
"Description": "TestClient",
"AllowedGrantTypes": [
"authorization_code",
"refresh_token"
],
"RedirectUris": [
"*"
],
"AllowedScopes": [
"openid",
"profile",
"email",
"offline_access"
],
"AlwaysIncludeUserClaimsInIdToken": true,
"AllowOfflineAccess": true,
"RequirePkce": false
}
]
ASPNET_SERVICES_OPTIONS_INLINE: |
{
"ForwardedHeadersOptions": {
"ForwardedHeaders" : "All"
}
}
volumes:
- ./oidc-user-config.json:/tmp/config/oidc-user-config.json:ro
ports:
- '4011:8080'
deploy:
resources:
limits:
memory: 512m
19 changes: 19 additions & 0 deletions dev_infra/oidc-user-config.json.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[
{
"SubjectId":"1",
"Username":"[email protected]",
"Password":"pwd",
"Claims": [
{
"Type": "name",
"Value": "Your name",
"ValueType": "string"
},
{
"Type": "email",
"Value": "[email protected]",
"ValueType": "string"
}
]
}
]
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>

<groupId>software.xdev</groupId>
<artifactId>standard-maven-template-root</artifactId>
<artifactId>spring-security-advanced-authentication-ui-root</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>pom</packaging>

Expand All @@ -15,8 +15,8 @@
</organization>

<modules>
<module>standard-maven-template</module>
<module>standard-maven-template-demo</module>
<module>spring-security-advanced-authentication-ui</module>
<module>spring-security-advanced-authentication-ui-demo</module>
</modules>

<licenses>
Expand Down
5 changes: 5 additions & 0 deletions spring-security-advanced-authentication-ui-demo/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Demo

* Start the [development infrastructure](../dev_infra/)
* Run the application
* Open ``http://localhost:8080``
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>

<groupId>software.xdev</groupId>
<artifactId>standard-maven-template-demo</artifactId>
<artifactId>spring-security-advanced-authentication-ui-demo</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>jar</packaging>

Expand All @@ -24,14 +24,42 @@
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

<mainClass>software.xdev.Application</mainClass>

<org.springframework.boot.version>3.2.4</org.springframework.boot.version>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${org.springframework.boot.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>


<dependencies>
<dependency>
<groupId>software.xdev</groupId>
<artifactId>standard-maven-template</artifactId>
<artifactId>spring-security-advanced-authentication-ui</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-oauth2-client</artifactId>
</dependency>
</dependencies>

<build>
Expand All @@ -49,31 +77,21 @@
</compilerArgs>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.7.1</version>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${org.springframework.boot.version}</version>
<configuration>
<archive>
<manifest>
<mainClass>${mainClass}</mainClass>
</manifest>
<manifestEntries>
<Multi-Release>true</Multi-Release>
</manifestEntries>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<appendAssemblyId>false</appendAssemblyId>
<mainClass>${mainClass}</mainClass>
</configuration>
<executions>
<execution>
<id>make-assembly</id> <!-- this is used for inheritance merges -->
<phase>package</phase> <!-- bind to the packaging phase -->
<id>repackage</id>
<goals>
<goal>single</goal>
<goal>repackage</goal>
</goals>
<phase>package</phase>
</execution>
</executions>
</plugin>
Expand All @@ -92,7 +110,7 @@
<dependency>
<groupId>com.puppycrawl.tools</groupId>
<artifactId>checkstyle</artifactId>
<version>10.14.2</version>
<version>10.15.0</version>
</dependency>
</dependencies>
<configuration>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package software.xdev;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;


@SuppressWarnings("checkstyle:HideUtilityClassConstructor")
@SpringBootApplication
public class Application
{
public static void main(final String[] args)
{
SpringApplication.run(Application.class, args);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package software.xdev.controllers;

import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.oauth2.core.oidc.user.DefaultOidcUser;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@RestController
@RequestMapping("/")
public class RootController
{
@GetMapping
public Result respond()
{
if(SecurityContextHolder.getContext()
.getAuthentication()
.getPrincipal() instanceof final DefaultOidcUser oidcUser)
{
return new Result(oidcUser.getFullName(), oidcUser.getEmail(), "/logout");
}
return null;
}

public record Result(
String name,
String email,
String logoutUrl
)
{

}
}
Loading

0 comments on commit b96c0a3

Please sign in to comment.