Skip to content

Commit e9f2616

Browse files
committed
add: base paseto configuration
1 parent b4a9256 commit e9f2616

File tree

6 files changed

+176
-0
lines changed

6 files changed

+176
-0
lines changed

security-paseto/build.gradle

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
ext {
2+
nimbusJoseJwtVersion = '9.15.2'
3+
bouncyCastleVersion = '1.69'
4+
}
5+
6+
dependencies {
7+
api "io.micronaut:micronaut-http"
8+
api "io.micronaut:micronaut-http-server"
9+
api project(":security")
10+
11+
implementation "io.projectreactor:reactor-core"
12+
13+
testImplementation "org.bouncycastle:bcpkix-jdk15on:$bouncyCastleVersion"
14+
testImplementation "org.bouncycastle:bcprov-jdk15on:$bouncyCastleVersion"
15+
16+
testImplementation "io.micronaut:micronaut-management"
17+
testImplementation "io.micronaut:micronaut-http-client"
18+
testAnnotationProcessor "io.micronaut:micronaut-inject-java"
19+
testImplementation "io.micronaut:micronaut-http-server-netty"
20+
testImplementation project(":test-suite-utils")
21+
testImplementation project(":test-suite-utils-security")
22+
testImplementation "io.micronaut.multitenancy:micronaut-multitenancy"
23+
24+
testImplementation "io.micronaut.views:micronaut-views-velocity"
25+
testRuntimeOnly "org.apache.velocity:velocity-engine-core:2.3"
26+
}
27+
apply from: "${rootProject.projectDir}/gradle/testVerbose.gradle"
28+
29+
test {
30+
testLogging.showStandardStreams = true
31+
testLogging.exceptionFormat = 'full'
32+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* Copyright 2017-2020 original authors
3+
*
4+
* Licensed under the Apache License, Version 2.0 \(the "License"\);
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
*/
17+
package io.micronaut.security.token.paseto.config;
18+
19+
import io.micronaut.core.util.Toggleable;
20+
21+
/**
22+
* Represents configuration of the PASETO token.
23+
*
24+
* @author Utsav Varia
25+
* @since 3.0
26+
*/
27+
public interface PasetoConfiguration extends Toggleable {
28+
29+
/**
30+
*
31+
* @return a boolean flag indicating whether PASETO beans should be enabled or not
32+
*/
33+
@Override
34+
boolean isEnabled();
35+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*
2+
* Copyright 2017-2020 original authors
3+
*
4+
* Licensed under the Apache License, Version 2.0 \(the "License"\);
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
*/
17+
package io.micronaut.security.token.paseto.config;
18+
19+
import io.micronaut.context.annotation.ConfigurationProperties;
20+
import io.micronaut.context.annotation.Requires;
21+
import io.micronaut.core.util.StringUtils;
22+
import io.micronaut.security.token.config.TokenConfigurationProperties;
23+
24+
/**
25+
* {@link PasetoConfiguration} implementation.
26+
*
27+
* @author Utsav Varia
28+
* @since 3.0
29+
*/
30+
@Requires(property = TokenConfigurationProperties.PREFIX + ".enabled", notEquals = StringUtils.FALSE)
31+
@ConfigurationProperties(PasetoConfigurationProperties.PREFIX)
32+
public class PasetoConfigurationProperties implements PasetoConfiguration {
33+
34+
public static final String PREFIX = TokenConfigurationProperties.PREFIX + ".paseto";
35+
/**
36+
* The default enable value.
37+
*/
38+
@SuppressWarnings("WeakerAccess")
39+
public static final boolean DEFAULT_ENABLED = true;
40+
41+
private boolean enabled = DEFAULT_ENABLED;
42+
43+
@Override
44+
public boolean isEnabled() {
45+
return enabled;
46+
}
47+
48+
/**
49+
* Sets whether Paseto security is enabled. Default value ({@value #DEFAULT_ENABLED}).
50+
* @param enabled True if it is
51+
*/
52+
public void setEnabled(boolean enabled) {
53+
this.enabled = enabled;
54+
}
55+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
* Copyright 2017-2020 original authors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
/**
17+
* PASETO configuration.
18+
*
19+
* @author Utsav Varia
20+
* @since 3.0
21+
*/
22+
package io.micronaut.security.token.paseto.config;
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* Copyright 2017-2020 original authors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
/**
17+
* Contains classes specific to Platform-Agnostic Security Tokens (PASETO) Authentication within Micronaut.
18+
*
19+
* @author Utsav Varia
20+
* @since 3.0
21+
*/
22+
23+
@Configuration
24+
@Requires(property = PasetoConfigurationProperties.PREFIX + ".enabled", notEquals = StringUtils.FALSE)
25+
package io.micronaut.security.token.paseto;
26+
27+
import io.micronaut.context.annotation.Configuration;
28+
import io.micronaut.context.annotation.Requires;
29+
import io.micronaut.core.util.StringUtils;
30+
import io.micronaut.security.token.paseto.config.PasetoConfigurationProperties;

settings.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,5 @@ include "test-suite"
2323
include "test-suite-utils"
2424
include "test-suite-utils-security"
2525
include "test-suite-kotlin"
26+
include 'security-paseto'
27+

0 commit comments

Comments
 (0)