• Stars
    star
    116
  • Rank 303,894 (Top 6 %)
  • Language
    Rust
  • License
    Apache License 2.0
  • Created over 4 years ago
  • Updated 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Web API access control for Rust

Aliri

Esperanto for "access"

CI

Aliri is a family of crates intended to help build access control, particularly of web APIs, where a token is the primary means of providing access.

Features

The aliri crate provides primary support for the JavaScript/JSON Object Signing and Encryption (JOSE) standard. For more information about the RFCs relating to this standard, see the crate's documentation.

The aliri_oauth2 crate provides some support for incorporating checks to ensure a bearer of a token has sufficient scopes to permit access. It also provides some functionality for using a local or remote JSON Web Key Set (JWKS) as an authority to authenticate tokens. Some of this functionality maybe broken off as part of planned OpenID Connect (OIDC) functionality.

The aliri_actix crate provides some useful bindings to create scope guards for the actix-web web server.

Similarly, the aliri_warp crate provides bindings to the warp web server, and includes filters useful for authenticating access to endpoints.

Other crates under the aliri header provide supporting functionality to these primary crates.

JSON Web Signature (JWS) operations

Supported algorithms

Feature hmac:

  • HS256, HS384, HS512

Feature rsa:

  • RS256, RS384, RS512
  • PS256, PS384, PS512

Feature ec:

  • ES256, ES384

Note: none is explicitly not supported by this library due to the security holes that algorithm raises when improperly accepted.

Support for private keys, to allow for signing operations and to generate new keys, is provided by the private-keys feature.

Due to limitations in the ability to import and export generated keys in the required JWK form, openssl is used to extract or handle the required parameters. In addition, ring does not support RSA private keys that are missing the p, q, dmp1, dmq1, or iqmp values. These parameters are highly recommended as they speed up signature calculation, but according to the JWA specification are technically optional.

Supported checks

  • iss exact string match
  • aud exact string match (list)
  • sub regex match
  • jti predicate function
  • nbf against current time
  • exp against current time
  • iat max age check
  • alg exact match (list)

Future plans

  • Support JWE
  • Support OpenID Connect as a relying party
  • Support obtaining tokens and token management

Alternatives

This set of crates grew out of my prior use of jsonwebtoken, and was expanded to fit larger goals of implementing the full JOSE suite. Further inspiration was taken from jsonwebtokens, in particular the Verifier type.

Unsafe code

Aliri does make use of very limited unsafe code. This unsafe code is limited to a single function defined in macros that is used to generate strongly-typed wrappers for String and Vec<u8> values. Unsafe is necessary here for the reference types, in order to reinterpret the &str as &MyTypeRef or &[u8] as &Base64Ref. This reinterpretation is safe because the wrappers around str use #[repr(transparent)], which means that the wrappers share the exact same representation as the underlying slice.

For the above reason, some included crates use #![deny(unsafe_code)] rather than #![forbid(unsafe_code)]. The only #![allow(unsafe_code)] in the code base can be found in the typed_string! and b64_builder! macros.

I have made this choice because of my preference for strongly-typed APIs over stringly-typed APIs. I believe that consumers of this library will benefit from this choice, as it will help them to prevent silly bugs.

Note that, because cargo-geiger has difficulty parsing out unsafe usage from within macros, that tool won't report these crates as "radioactive", but probably should. Do your due diligence.

More Repositories

1

protoc-gen-prost

Rust
150
star
2

modyne

An opinionated Rust library for interacting with AWS DynamoDB single-table designs.
Rust
53
star
3

stats_alloc

Rust
44
star
4

bouncycastle

Bouncy Castle
C#
41
star
5

aliri_braid

Improve and strengthen your strings by making them strongly-typed with less boilerplate
Rust
30
star
6

purpleonion

The Purple Onion Router: a managed implementation of the Tor Onion Router
C#
15
star
7

Hopac.Plus

A collection of utilities that encapsulate common concurrency patterns and constructs for use with the Hopac concurrency library.
F#
13
star
8

msfs_vpilot_vmr

vPilot-compatible VMRs for matching plane models in MSFS
6
star
9

health

Rust
6
star
10

docker-fsharp-alpine

5
star
11

c5

The C5 Generic Collection Library for C# and the CLI
C#
5
star
12

TickSpec

A lightweight Behaviour Driven Development (BDD) framework. Describe behaviour in plain text using the Gherkin business language, i.e. given, when, then. Easily execute the behaviour against matching F# tick methods (let ``tick method`` () = true) or attributed C# or F# methods.
F#
5
star
13

freya-netcore-presentation

F#
4
star
14

HttpFs.Auth0

Provides constructs which make it easier to use Auth0 when interacting with protected APIs.
F#
4
star
15

githax

Tools and documents related to the Tor project's conversion from svn to git
Shell
3
star
16

xpdm.Bitcoin

C#
2
star
17

monads-are-not-burritos

Explaining monads to the uninitiated (a lightning talk)
F#
2
star
18

xpdm.Catan

C#
2
star
19

cqrs

Rust
2
star
20

xpdm

General Repository for things xallaraparadigm
C#
2
star
21

hopac-concurrency-with-synchronous-messaging

One of the four tenets in the Reactive Manifesto is asynchronous messaging, but what if we considered the alternative? Synchronous messaging may not be the sin we've all been warned against. Inspired by Concurrent ML and the concurrent synchronous processes model, we will discuss the concurrency primitives exposed by the Hopac library and how they can be composed to build highly-concurrent applications which benefit from lightweight threads, an optimized work scheduler, and the ability to react to multiple communication channels. All while avoiding some of the pitfalls of asynchronous messaging.
F#
2
star
22

docker-mono-alpine

1
star
23

FSharp-Lightning-Talk

F#
1
star
24

new_type_derive

Rust
1
star
25

HopacPresentation

A long-ish presentation on Hopac
F#
1
star
26

cj4-fadec

Rust
1
star