Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add login page (Backend) #16

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ Bob Management GUI changelog
## [Unreleased]

#### Added

Copy link
Member

@ikopylov ikopylov Jan 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unnecessary empty line

- Initial project structure, backend only (#9)
- Initial project stricture, frontend (#10)
- Dockerfile and Docker-Compose to simplify deployment (#5)
- CI/CD configuration (#11)
- Logger Initialization (#14)
- Login Page, backend (#16)
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ license-file = "./LICENSE"
edition = "2021"

[workspace]
members = [ "cli", "frontend", "backend", "utils" ]
members = [ "cli", "frontend", "backend", "utils", "proc_macro" ]
default-members = [ "frontend", "backend"]
resolver = "2"

Expand Down
100 changes: 98 additions & 2 deletions api/openapi.yaml
Original file line number Diff line number Diff line change
@@ -1,21 +1,117 @@
openapi: 3.0.3
info:
title: bob-management
description: 'Bob Management GUI: Backend'
description: Bob Management GUI
contact:
name: Romanov Simeon ArchArcheoss@proton.me
license:
name: ''
version: 0.0.0
paths:
/root:
/api/v1/login:
post:
tags:
- services::auth
summary: Login to a BOB cluster
description: |
Login to a BOB cluster

# Errors
This function can return the following errors

1. [`StatusCode::BAD_REQUEST`]
The function failed to parse hostname of the request

2. [`StatusCode::NOT_FOUND`]
The client was unable to reach the host

3. [`StatusCode::UNAUTHORIZED`]
The client couldn't authorize on the host
operationId: login
parameters:
- name: hostname
in: path
description: Address to connect to
required: true
schema:
$ref: '#/components/schemas/Hostname'
- name: credentials
in: path
description: '[Optional] Credentials used for BOB authentication'
required: true
schema:
allOf:
- $ref: '#/components/schemas/Credentials'
nullable: true
requestBody:
description: ''
content:
application/json:
schema:
$ref: '#/components/schemas/BobConnectionData'
required: true
responses:
'200':
description: Successful authorization
'400':
description: Bad Hostname
'401':
description: Bad Credentials
'404':
description: Can't reach specified hostname
/api/v1/logout:
post:
tags:
- services::auth
operationId: logout
responses:
'200':
description: Logged out
/api/v1/root:
get:
tags:
- crate
operationId: root
responses:
'200':
description: Hello Bob!
components:
schemas:
BobConnectionData:
type: object
description: Data needed to connect to a BOB cluster
required:
- hostname
properties:
credentials:
allOf:
- $ref: '#/components/schemas/Credentials'
nullable: true
hostname:
$ref: '#/components/schemas/Hostname'
example:
credentials:
login: archeoss
password: '12345'
hostname: 0.0.0.0:7000
Credentials:
type: object
description: Optional auth credentials for a BOB cluster
required:
- login
- password
properties:
login:
type: string
description: Login used during auth
password:
type: string
description: Password used during auth
example:
login: archeoss
password: '12345'
Hostname:
$ref: '#/components/schemas/Uri'
tags:
- name: bob
description: BOB management API
23 changes: 17 additions & 6 deletions backend/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "bob-management"
description = "Bob Management GUI: Backend"
description = "Bob Management GUI"
publish = false
keywords = [ "BOB", "Management", "GUI" ]
version.workspace = true
Expand All @@ -13,10 +13,9 @@ repository.workspace = true
[dependencies]
# Backend (lib.rs)
## Axum related
axum = "0.6"
axum = { version = "0.6", features = ["headers"] }
axum-macros = "0.3"
axum-login = "0.6"
axum-sessions = "0.6"
tower-sessions = "0.5"
tower = "0.4"
tower-http = { version = "0.4", features = ["cors", "fs"] }

Expand All @@ -25,15 +24,20 @@ tracing = "0.1"
file-rotate = "0.7"
tracing-appender = "0.2"
tracing-subscriber = "0.3"
# tracing-forest = { version = "0.1", features = ["tokio"] }

## Error Handling
error-stack = "0.4"
thiserror = "1.0"

## General
tokio = { version = "1.32", features = ["rt", "macros", "rt-multi-thread" ] }
hyper = "0.14"
lazy_static = "1.4"
hyper = { version = "0.14", features = ["http2", "client"] }
hyper_serde = "0.13"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
uuid = { version = "1.4", features = ["v4", "serde", "fast-rng"] }
futures = "0.3"

## OpenAPI + Swagger
utoipa = { version = "4.0", features = ["yaml", "axum_extras", "chrono", "openapi_extensions"], optional = true }
Expand All @@ -44,7 +48,14 @@ utoipa-rapidoc = { version = "1.0", features = ["axum"], optional = true }
## CLI
cli = { path = "../cli" }

# Macro
proc-macro = { path = "../proc_macro" }

[dev-dependencies]
utoipa = { version = "4.0", features = ["yaml", "axum_extras", "chrono", "openapi_extensions"]}

[features]
default = [ "swagger" ]
swagger = [ "dep:utoipa", "dep:utoipa-swagger-ui" , "dep:utoipa-redoc", "dep:utoipa-rapidoc" ]
gen_api = [ "dep:utoipa" ]

Loading
Loading