Skip to content

Latest commit

 

History

History
84 lines (68 loc) · 3.18 KB

File metadata and controls

84 lines (68 loc) · 3.18 KB

A Rust based OAuth API

Rust CodeQL Advanced Dependabot Updates

An exercise into how to create a HTTP service using Rust, similar to oauth-api-go and oauth-api.

Requirements

Structure

├── src                     # Application source code
│   ├── token               # Shared token logic 
│   │   └── ...etc
│   ├── token_exchange      # Token exchange endpoint
│   │   └── ...etc
│   ├── token_introspection # Token introspection endpoint
│   │   └── ...etc
│   └── main.rs             # Application entry point
├── scripts
│   └── http                # Jetbrains HTTP Client requests, with assertions.
└── README.md

Building

The standard Cargo (Rust build tool) approach

cargo build

Linting

The standard rust linter, which is enforced by the GitHub Actions workflow

cargo clippy

Testing

The standard Cargo (Rust build tool) approach

cargo test

Running

The standard Cargo (Rust build tool) approach

cargo run

Checking its running

Hit the token exchange endpoint with a password grant (yeah, it's deprecated; but it's a quick lazy way to start).

curl -v -X POST -H 'Content-Type: application/x-www-form-urlencoded' -u 'aardvark:badger' -d 'grant_type=password&scope=basic&username=aardvark&password=P%4055w0rd' http://127.0.0.1:8080/token

Hit the token introspection endpoint with the token just issued.

curl -v -X POST -H 'Content-Type: application/x-www-form-urlencoded' -u 'aardvark:badger' -d 'token=483d83dd-92a2-4d73-817f-8fd0e7203cb3' http://127.0.0.1:8080/introspect

Reading materials