Skip to content

Paseto.NET, a Paseto (Platform-Agnostic Security Tokens) implementation for .NET

License

Notifications You must be signed in to change notification settings

niilante/paseto-dotnet

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Paseto.NET, a Paseto (Platform-Agnostic Security Tokens) implementation for .NET

Build status NuGet MyGet contributions welcome

Usage

Building a Paseto

var token = new PasetoBuilder<Version2>()
		.WithKey(secret)
		.AddClaim("example", "Hello Paseto!")
		.Expiration(DateTime.UtcNow.AddHours(24))
		.AsPublic() // Purpose
		.Build();
var encoder = new PasetoEncoder(cfg => cfg.Use<Version2>(sk)); // default is public purpose
var token = encoder.Encode(new PasetoPayload
{
	{ "example", "Hello Paseto!" },
	{ "exp", UnixEpoch.ToUnixTime(DateTime.UtcNow.AddHours(24)) }
});

Encoded Token:

v2.public.eyJleGFtcGxlIjoiSGVsbG8gUGFzZXRvISIsImV4cCI6IjE1MjEyNDU0NTAifQ2jznA4Tl8r2PM8xu0FIJhyWkm4SiwvCxavTSFt7bo7JtnsFdWgXBOgbYybi5-NAkmpm94uwJCRjCApOXBSIgs

Decoding a Paseto

var payload = new PasetoBuilder<Version2>()
		.WithKey(publicKey)
		.AsPublic() // Purpose
		.AndVerifySignature()
		.Decode(token);
var decoder = new PasetoDecoder(cfg => cfg.Use<Version2>(publicKey)); // default is public purpose
var payload = decoder.Decode(token);

Decrypted Payload:

{
  "example": "Hello Paseto!",
  "exp": "1521245450"
}

Roadmap

  • Add support for local authentication for v1 and v2.
    • Implement XChaCha20-Poly1305 algorithm or use an external library
  • Improve protocol versioning
  • Add more documentation on the usage
  • Extend the fluent builder API
  • Add more tests

Cryptography

  • Uses Ed25519 algorithm from CodesInChaos Chaos.NaCl cryptography library.

At its current state, libsodium-core and NSec does't support XChaCha20-Poly1305.

About

Paseto.NET, a Paseto (Platform-Agnostic Security Tokens) implementation for .NET

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 98.5%
  • Smalltalk 1.5%