Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 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
37 changes: 37 additions & 0 deletions security-paseto/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
ext {
jpasetoVersion = '0.7.0'
bouncyCastleVersion = '1.69'
}

dependencies {
api "io.micronaut:micronaut-http"
api "io.micronaut:micronaut-http-server"
api project(":security")
compileOnly "dev.paseto:jpaseto-api:$jpasetoVersion"

implementation "io.projectreactor:reactor-core"

testImplementation "org.bouncycastle:bcpkix-jdk15on:$bouncyCastleVersion"
testImplementation "org.bouncycastle:bcprov-jdk15on:$bouncyCastleVersion"

testImplementation "io.micronaut:micronaut-management"
testImplementation "io.micronaut:micronaut-http-client"
testAnnotationProcessor "io.micronaut:micronaut-inject-java"
testImplementation "io.micronaut:micronaut-http-server-netty"
testImplementation project(":test-suite-utils")
testImplementation project(":test-suite-utils-security")
testImplementation "io.micronaut.multitenancy:micronaut-multitenancy"

testImplementation "io.micronaut.views:micronaut-views-velocity"
testRuntimeOnly "org.apache.velocity:velocity-engine-core:2.3"

testRuntimeOnly "dev.paseto:jpaseto-impl:$jpasetoVersion"
testRuntimeOnly "dev.paseto:jpaseto-jackson:$jpasetoVersion"
testRuntimeOnly "dev.paseto:jpaseto-bouncy-castle:$jpasetoVersion"
}
apply from: "${rootProject.projectDir}/gradle/testVerbose.gradle"

test {
testLogging.showStandardStreams = true
testLogging.exceptionFormat = 'full'
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Copyright 2017-2020 original authors
*
* Licensed under the Apache License, Version 2.0 \(the "License"\);
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package io.micronaut.security.token.paseto.config;

import io.micronaut.core.util.Toggleable;

/**
* Represents configuration of the PASETO token.
*
* @author Utsav Varia
* @since 3.0
*/
public interface PasetoConfiguration extends Toggleable {

/**
*
* @return a boolean flag indicating whether PASETO beans should be enabled or not
*/
@Override
boolean isEnabled();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* Copyright 2017-2020 original authors
*
* Licensed under the Apache License, Version 2.0 \(the "License"\);
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package io.micronaut.security.token.paseto.config;

import io.micronaut.context.annotation.ConfigurationProperties;
import io.micronaut.context.annotation.Requires;
import io.micronaut.core.util.StringUtils;
import io.micronaut.security.token.config.TokenConfigurationProperties;

/**
* {@link PasetoConfiguration} implementation.
*
* @author Utsav Varia
* @since 3.0
*/
@Requires(property = TokenConfigurationProperties.PREFIX + ".enabled", notEquals = StringUtils.FALSE)
@ConfigurationProperties(PasetoConfigurationProperties.PREFIX)
public class PasetoConfigurationProperties implements PasetoConfiguration {

public static final String PREFIX = TokenConfigurationProperties.PREFIX + ".paseto";
/**
* The default enable value.
*/
@SuppressWarnings("WeakerAccess")
public static final boolean DEFAULT_ENABLED = true;

private boolean enabled = DEFAULT_ENABLED;

@Override
public boolean isEnabled() {
return enabled;
}

/**
* Sets whether Paseto security is enabled. Default value ({@value #DEFAULT_ENABLED}).
* @param enabled True if it is
*/
public void setEnabled(boolean enabled) {
this.enabled = enabled;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* Copyright 2017-2020 original authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* PASETO configuration.
*
* @author Utsav Varia
* @since 3.0
*/
package io.micronaut.security.token.paseto.config;
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Copyright 2017-2020 original authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Contains classes specific to Platform-Agnostic Security Tokens (PASETO) Authentication within Micronaut.
*
* @author Utsav Varia
* @since 3.0
*/

@Configuration
@Requires(property = PasetoConfigurationProperties.PREFIX + ".enabled", notEquals = StringUtils.FALSE)
package io.micronaut.security.token.paseto;

import io.micronaut.context.annotation.Configuration;
import io.micronaut.context.annotation.Requires;
import io.micronaut.core.util.StringUtils;
import io.micronaut.security.token.paseto.config.PasetoConfigurationProperties;
2 changes: 2 additions & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,5 @@ include "test-suite"
include "test-suite-utils"
include "test-suite-utils-security"
include "test-suite-kotlin"
include 'security-paseto'