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

feat: add security module #119

Merged
merged 2 commits into from
Dec 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ Include the component in your project by including the corresponding dependency.
| Rest | tkit-quarkus-rest | | Helper classes for JAX-RS and Jackson. | [Link](extensions/rest-dto) |
| Rest DTO | tkit-quarkus-rest-dto | | Helper classes for REST - model mapping, exception handling, DTOs. | [Link](extensions/rest) |
| Test data import | tkit-quarkus-test-db-import | | Test extension for data import from excel into database during unit tests. | [Link](extensions/test-db-import) |
| Security | tkit-quarkus-security | | Enhanced security configuration | [Link](extensions/security) |

### Migration from older version

Expand Down
5 changes: 5 additions & 0 deletions bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@
<artifactId>tkit-quarkus-test-db-import</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.tkit.quarkus.lib</groupId>
<artifactId>tkit-quarkus-security</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</dependencyManagement>

Expand Down
1 change: 1 addition & 0 deletions extensions/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
<module>rest-dto</module>
<module>rest-context</module>
<module>test-db-import</module>
<module>security</module>
</modules>

</project>
10 changes: 10 additions & 0 deletions extensions/security/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# tkit-quarkus-security

Enhanced security configuration

## Configuration

```properties
# disable or enable authorization
tkit.security.auth.enabled=true
```
22 changes: 22 additions & 0 deletions extensions/security/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 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.tkit.quarkus.lib</groupId>
<artifactId>tkit-quarkus-extensions-parent</artifactId>
<version>999-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

<artifactId>tkit-quarkus-security</artifactId>
<packaging>jar</packaging>

<dependencies>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-security-runtime-spi</artifactId>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package org.tkit.quarkus.security;

import jakarta.annotation.Priority;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.enterprise.inject.Alternative;
import jakarta.inject.Inject;
import jakarta.interceptor.Interceptor;

import io.quarkus.security.spi.runtime.AuthorizationController;

@Alternative
@Priority(Interceptor.Priority.LIBRARY_AFTER)
@ApplicationScoped
public class DisabledAuthController extends AuthorizationController {

@Inject
SecurityConfig config;

@Override
public boolean isAuthorizationEnabled() {
return config.enabled();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package org.tkit.quarkus.security;

import io.smallrye.config.ConfigMapping;
import io.smallrye.config.WithDefault;
import io.smallrye.config.WithName;

@ConfigMapping(prefix = "tkit.security")
public interface SecurityConfig {

@WithName("auth.enabled")
@WithDefault("true")
boolean enabled();
}
Empty file.
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@

<properties>
<!-- Quarkus -->
<quarkus.version>3.6.3</quarkus.version>
<quarkus.hibernate-orm.version>6.4.0.Final</quarkus.hibernate-orm.version>
<quarkus.version>3.6.4</quarkus.version>
<quarkus.hibernate-orm.version>6.4.1.Final</quarkus.hibernate-orm.version>
<quarkiverse.mockserver.version>1.2.0</quarkiverse.mockserver.version>
<quarkus.jandex-plugin.version>3.1.6</quarkus.jandex-plugin.version>

Expand All @@ -66,7 +66,7 @@
<maven.compiler.target>17</maven.compiler.target>
<maven.compiler.release>17</maven.compiler.release>
<maven.compiler.parameters>true</maven.compiler.parameters>
<maven.compiler-plugin.version>3.11.0</maven.compiler-plugin.version>
<maven.compiler-plugin.version>3.12.1</maven.compiler-plugin.version>
<maven.surefire-plugin.version>3.2.3</maven.surefire-plugin.version>
<maven.formatter-maven-plugin.version>2.23.0</maven.formatter-maven-plugin.version>
<maven.impsort-maven-plugin.version>1.9.0</maven.impsort-maven-plugin.version>
Expand Down