Crates.io | akas |
lib.rs | akas |
version | 1.2.0 |
source | src |
created_at | 2024-08-23 21:10:05.049673 |
updated_at | 2024-10-13 17:00:42.506298 |
description | AKAS: API Key Authorization Server |
homepage | |
repository | https://gitlab.com/op_so/projects/akas |
max_upload_size | |
id | 1349629 |
size | 306,388 |
A server written in Rust to authorize HTTP requests that include an authorization bearer in their header.
Authorization: Bearer <token>
The file of the list of the tokens to be used for authorization should contain one token per line in plain or SHA-256 format:
mykey-3532dceb-f38a-491b-814d-9607bc9a947a
mykey-c2d79a40-388e-4709-9e4b-903035b0e71e
...
8b89600015b273c28f966f368456e45e01df239a36bf939ff72a16881f775679
fb22be500af1ef0479745bbbce847854da33f5e910361ad278e0282995b95f4d
...
AKAS: API Key Authorization Server
Usage: akas [OPTIONS] --file <FILE>
Options:
-f, --file <FILE> File path of the tokens list
-p, --port <PORT> Port of the server [default: 5001]
--format <FORMAT> Format of the token in the file <plain|sha256> [default: plain]
--length <LENGTH> Length of the token [optional] [default: 0]
--prefix <PREFIX> Prefix of the token [optional] [default: ]
-h, --help Print help
-V, --version Print version
5001
and a file containing plain tokens:./akas --file plain-tokens.txt
server {
listen 80;
server_name _;
location / {
auth_request /auth;
auth_request_set $auth_status $upstream_status;
root /usr/share/nginx/html;
index index.html index.htm;
}
location = /auth {
internal;
proxy_pass http://localhost:5001/auth;
proxy_pass_request_body off;
proxy_set_header content-length "";
proxy_set_header x-forwarded-for $proxy_add_x_forwarded_for;
proxy_set_header x-original-host $host;
proxy_set_header x-original-uri $request_uri;
proxy_set_header x-original-remote-addr $remote_addr;
}
}
More details of Nginx configuration can be found in the configuring subrequest authentication* documentation
curl -H "Authorization: Bearer <token>" http://<host>/
/auth
: default endpoint./auth-ok
: always return 200 OK
without checking the token (for testing purposes)./auth-unauthorized
: always return 401 Unauthorized
without checking the token (for testing purposes or disable access)./auth
: default endpoint./auth-ok
: always return 200 OK
without checking the token./auth-unauthorized
: always return 401 Unauthorized
without checking the token.Binary file installation on Linux via the GitLab package registry of the project:
With a Rust environment, running this command will globally install the akas binary:
cargo install akas
Clone the source repository: git clone https://gitlab.com/op_so/projects/akas.git
To format and lint:
cargo fmt # cargo fmt -- --check
cargo clippy
cargo test
cargo tarpaulin --ignore-tests
cargo audit
To run: cargo run -- --file tests/files/plain_token.txt
To build:
cargo build # Debug binary target/debug/akas
cargo build --release # Release binary target/release/akas
This program is free software: you can redistribute it and/or modify it under the terms of the MIT License (MIT). See the LICENSE for details.