All Projects → l0s → Fernet Java8

l0s / Fernet Java8

Licence: apache-2.0
Java 8 implementation of the Fernet Specification

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Fernet Java8

Awesome Iam
👤 Identity and Access Management Knowledge for Cloud Platforms
Stars: ✭ 186 (+675%)
Mutual labels:  authentication, cryptography, authorization
Themis
Easy to use cryptographic framework for data protection: secure messaging with forward secrecy and secure data storage. Has unified APIs across 14 platforms.
Stars: ✭ 1,232 (+5033.33%)
Mutual labels:  authentication, cryptography, encryption
Halite
High-level cryptography interface powered by libsodium
Stars: ✭ 933 (+3787.5%)
Mutual labels:  authentication, cryptography, encryption
Securefs
Filesystem in userspace (FUSE) with transparent authenticated encryption
Stars: ✭ 518 (+2058.33%)
Mutual labels:  authentication, cryptography, encryption
Social Core
Python Social Auth - Core
Stars: ✭ 618 (+2475%)
Mutual labels:  authentication, authorization
Dancer Plugin Auth Extensible
Authentication framework for Dancer-based web applications
Stars: ✭ 22 (-8.33%)
Mutual labels:  authentication, authorization
Virgil Crypto Php
Virgil PHP Crypto Library is a high-level cryptographic library that allows you to perform all necessary operations for secure storing and transferring data and everything required to become HIPAA and GDPR compliant.
Stars: ✭ 22 (-8.33%)
Mutual labels:  cryptography, encryption
Php Auth
Authentication for PHP. Simple, lightweight and secure.
Stars: ✭ 713 (+2870.83%)
Mutual labels:  authentication, authorization
Doorkeeper
Doorkeeper is an OAuth 2 provider for Ruby on Rails / Grape.
Stars: ✭ 4,917 (+20387.5%)
Mutual labels:  authentication, authorization
Aspnet5identityserverangularimplicitflow
OpenID Connect Code / Implicit Flow with Angular and ASP.NET Core 5 IdentityServer4
Stars: ✭ 670 (+2691.67%)
Mutual labels:  authentication, authorization
Aws Serverless Auth Reference App
Serverless reference app and backend API, showcasing authentication and authorization patterns using Amazon Cognito, Amazon API Gateway, AWS Lambda, and AWS IAM.
Stars: ✭ 724 (+2916.67%)
Mutual labels:  authentication, authorization
Darkwire.io
End-to-end encrypted instant web chat
Stars: ✭ 594 (+2375%)
Mutual labels:  cryptography, encryption
Yosai
A Security Framework for Python applications featuring Authorization (rbac permissions and roles), Authentication (2fa totp), Session Management and an extensive Audit Trail
Stars: ✭ 582 (+2325%)
Mutual labels:  authentication, authorization
Fwknop
Single Packet Authorization > Port Knocking
Stars: ✭ 664 (+2666.67%)
Mutual labels:  authentication, authorization
Wetech Admin
wetech-admin是基于Spring Boot 2.0+Mybatis+Vue的轻量级后台管理系统,适用于中小型项目的管理后台,支持按钮级别的权限控制,系统具有最基本的用户管理、角色管理、权限管理等通用性功能,企业或个人可直接在此基础上进行开发,扩展,添加各自的需求和业务功能!
Stars: ✭ 570 (+2275%)
Mutual labels:  authentication, authorization
Maskbook
The portal to the new, open internet. ([I:b])
Stars: ✭ 691 (+2779.17%)
Mutual labels:  cryptography, encryption
Sdk Js
Tanker client-side encryption SDK for JavaScript
Stars: ✭ 786 (+3175%)
Mutual labels:  cryptography, encryption
Auth0.js
Auth0 headless browser sdk
Stars: ✭ 755 (+3045.83%)
Mutual labels:  authentication, authorization
Keeper
Stars: ✭ 23 (-4.17%)
Mutual labels:  authentication, authorization
Jso
Easy to use OAuth 2.0 javascript library for use in your javascript application.
Stars: ✭ 830 (+3358.33%)
Mutual labels:  authentication, authorization

Fernet Java

Build Status Javadocs Known Vulnerabilities

This is an implementation of the Fernet Spec using Java 8. The goal is to use only native Java constructs to avoid pulling in any dependencies so the library would be more generally usable. It also takes advantage of the Java 8 time objects to add type-safety.

I am actively soliciting feedback on this library. If you have any thoughts, please submit an issue.

Features

  • fully-validated against the scenarios in the Fernet Spec
  • type-safety by using Java 8 time objects (no confusing milliseconds vs seconds after the epoch)
  • no dependencies!
  • pluggable mechanism so you can specify your own:
    • Clock
    • TTL / max clock skew
    • payload validator
    • payload transformation (i.e. to POJO)

Adding this to your project

This library is available in The Central Repository. If you use Maven, you can add it to your project object model using:

<dependency>
  <groupId>com.macasaet.fernet</groupId>
  <artifactId>fernet-java8</artifactId>
  <version>1.4.2</version>
</dependency>

For more details, see: The Central Repository

If you use a dependency manager system or build system other than Maven, see Dependency Information.

Alternatively, you can just download the latest jar and add it to your classpath. It does not have any dependencies.

Note that this library requires Java 8 or higher.

Examples

Create a new key:

final Key key = Key.generateKey();

or

final Key key = Key.generateKey(customRandom);

Deserialise an existing key:

final Key key = new Key("cw_0x689RpI-jtRR7oE8h_eQsKImvJapLeSbXpwF4e4=");

Create a token:

final Token token = Token.generate(key, "secret message");

or

final Token token = Token.generate(customRandom, key, "secret message");

Deserialise an existing token:

final Token token = Token.fromString("gAAAAAAdwJ6wAAECAwQFBgcICQoLDA0ODy021cpGVWKZ_eEwCGM4BLLF_5CV9dOPmrhuVUPgJobwOz7JcbmrR64jVmpU4IwqDA==");

Validate the token:

final Validator<String> validator = new StringValidator() {
};
final String payload = token.validateAndDecrypt(key, validator);

When validating, an exception is thrown if the token is not valid. In this example, the payload is just the decrypted cipher text portion of the token. If you choose to store structured data in the token (e.g. JSON), or a pointer to a domain object (e.g. a username), you can implement your own Validator<T> that returns the type of POJO your application expects.

Use a custom time-to-live:

final Validator<String> validator = new StringValidator() {
  public TemporalAmount getTimeToLive() {
    return Duration.ofHours(4);
  }
};

The default time-to-live is 60 seconds, but in this example, it's overridden to 4 hours.

Storing Sensitive Data on the Client

For an example of how to securely store sensitive data on the client (e.g. browser cookie), see the classes in src/test/java. The class AutofillExample shows a full end-to-end example.

JAX-RS / JSR 311

For details on how to use Fernet tokens to secure JAX-RS endpoints, see the fernet-jersey-auth submodule. If you're using the Jersey implementation of JAX-RS, you can use that module directly. TokenInjectionIT contains an example of injecting a Fernet token into an endpoint parameter. SecretInjectionIT contains an example of injecting a Fernet token payload into an endpoint parameter.

AWS Secrets Manager

For details on how to store Fernet keys using AWS Secrets Manager, see the submodule fernet-aws-secrets-manager-rotator. It includes a Lambda Function to enable key rotation.

Development

Mutation Testing and Test Coverage

This project uses PITest to evaluate test coverage and test effectiveness. The latest report is available here. To generate a report for a local build, run:

./mvnw clean install site

Releasing to The Central Repository

./mvnw --batch-mode -Prelease clean release:clean release:prepare release:perform

Prior Art

There is a library called fernet-java, which as of version 0.0.1-SNAPSHOT, uses Guava and commons-codec.

License

Copyright 2017 Carlos Macasaet

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.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].