Skip to content

This project is a sample user management and authentication system that adopts Rust and serverless architecture.

License

Notifications You must be signed in to change notification settings

sdn0303/sls-uma-rs

Repository files navigation

Sample Serverless User Management Auth Service Rust

This project is a sample user management and authentication system that adopts Rust and serverless architecture.

Architecture

See template.yaml

Setup (AppleSilicon)

Install the Rust toolchain

If your First time to install the Rust toolchain, you can use the following command.

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

After installing the Rust toolchain, check the version.

This project uses the following version.

rustup -V
rustup 1.27.1 (2024-04-24)
info: This is the version for the rustup toolchain manager, not the rustc compiler.
info: The currently active `rustc` version is `rustc 1.80.1 (3f5fd8dd4 2024-08-06)`
cargo version
cargo 1.80.1 (376290515 2024-07-16)

Install the cargo-make

cargo install --force cargo-make

Install the cargo-lambda

brew tap cargo-lambda/cargo-lambda
brew install cargo-lambda

Install the compiler and the target for the cross-compilation

brew install filosottile/musl-cross/musl-cross
rustup target add aarch64-unknown-linux-musl

If your build fails with the openssl related error, try to set the environment variables like this

export OPENSSL_DIR=$(brew --prefix openssl@3)
export OPENSSL_LIB_DIR=$(brew --prefix openssl@3)/lib
export OPENSSL_INCLUDE_DIR=$(brew --prefix openssl@3)/include
export PKG_CONFIG_PATH=$(brew --prefix openssl@3)/lib/pkgconfig

Install the SAM CLI

Set AWS credentials in you local.

brew install aws-sam-cli

Commands

This project uses the cargo-make for the build and the deployment.

More information, see the Makefile.toml and https://sagiegurari.github.io/cargo-make/.

Build the Lambda and templates

cargo make build-all
sam build --profile { your profile }

Deploy SAM

sam deploy --profile { your profile }

AWS Secrets Manager Configuration

Set the following items as secrets manually from the Cognito User Pool Client settings in the AWS Console:

  • COGNITO_USER_POOL_ID
  • COGNITO_CLIENT_ID
  • COGNITO_CLIENT_SECRET
  • COGNITO_JWKS_URL

In addition, please create the secret with the name {Env}/UserManagementAuthApi/CognitoEnv.

API Endpoints

POST   /signup
POST   /login
POST   /tokens/refresh
GET    /tokens/validate
GET    /organizations/{organizationId}/users
POST   /organizations/{organizationId}/users
GET    /organizations/{organizationId}/users/{userId}
PUT    /organizations/{organizationId}/users/{userId}
DELETE /organizations/{organizationId}/users/{userId}

About

This project is a sample user management and authentication system that adopts Rust and serverless architecture.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages