-
Notifications
You must be signed in to change notification settings - Fork 138
Add support for Paseto Authentication #806
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
Closed
utsav0209
wants to merge
12
commits into
micronaut-projects:master
from
utsav0209:feature/JPaseto-504
Closed
Changes from 4 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
e9f2616
add: base paseto configuration
utsav0209 12253c2
BLD: Added JPaseto dependency
utsav0209 e1fda4f
CLN: Removed redundant isEnabled() in PasetoConfiguration interface
utsav0209 2f01114
BLD: Removed unnecessary dependencies
utsav0209 6902722
CLN: Cleaned build.gradle for security-paseto submodule
utsav0209 7fa3bfb
ENH: Added Paseto token generator
utsav0209 7d4e293
ENH: Added Paseto token validator
utsav0209 a641390
ENH: Added Shared secret property for LOCAL version
utsav0209 64a6ba5
ENH: Migrated paseto token configuration properties to enum types
utsav0209 0b16982
ENH: Added builder methods for default Paseto claims
utsav0209 d496a37
ENH: Added paseto generic paseto claim validator
utsav0209 26edf5f
ENH: Added Not before Paseto claims validator
utsav0209 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| ext { | ||
| jpasetoVersion = '0.7.0' | ||
| bouncyCastleVersion = '1.69' | ||
utsav0209 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| dependencies { | ||
| api "io.micronaut:micronaut-http" | ||
| api "io.micronaut:micronaut-http-server" | ||
| api project(":security") | ||
| api "dev.paseto:jpaseto-api:$jpasetoVersion" | ||
|
|
||
| implementation "io.projectreactor:reactor-core" | ||
|
|
||
| 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") | ||
|
|
||
| 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' | ||
| } | ||
29 changes: 29 additions & 0 deletions
29
...y-paseto/src/main/java/io/micronaut/security/token/paseto/config/PasetoConfiguration.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| /* | ||
| * 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 { | ||
|
|
||
| } |
59 changes: 59 additions & 0 deletions
59
...rc/main/java/io/micronaut/security/token/paseto/config/PasetoConfigurationProperties.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| /* | ||
| * 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; | ||
|
|
||
| /** | ||
| * | ||
| * @return a boolean flag indicating whether PASETO beans should be enabled or not | ||
| */ | ||
| @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; | ||
| } | ||
| } |
22 changes: 22 additions & 0 deletions
22
security-paseto/src/main/java/io/micronaut/security/token/paseto/config/package-info.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; |
30 changes: 30 additions & 0 deletions
30
security-paseto/src/main/java/io/micronaut/security/token/paseto/package-info.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.