added base64 encoding option to basic auth
Some checks failed
Rust / build (push) Failing after 8m11s
Some checks failed
Rust / build (push) Failing after 8m11s
This commit is contained in:
parent
982452cb5b
commit
808c6a526c
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "gt"
|
||||
version = "0.2.0"
|
||||
version = "0.3.0"
|
||||
authors = ["Wyatt J. Miller <wjmiller2016@gmail.com>"]
|
||||
edition = "2018"
|
||||
description = "A Gitea CLI client"
|
||||
@ -11,6 +11,7 @@ license-file = "LICENSE"
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
base64 = "0.22.1"
|
||||
clap = "2.33.1"
|
||||
colored = "2.0.0"
|
||||
config = "0.11.0"
|
||||
|
@ -423,3 +423,9 @@ impl Repository {
|
||||
|
||||
pub fn create_commit(&self, request: &Request, config: Configuration) {}
|
||||
}
|
||||
|
||||
impl Default for Repository {
|
||||
fn default() -> Self {
|
||||
Repository::new()
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
use std::{collections::HashMap, process};
|
||||
|
||||
use base64::{engine::general_purpose::URL_SAFE, Engine as _};
|
||||
use clap::ArgMatches;
|
||||
use reqwest::blocking::Client;
|
||||
|
||||
@ -67,6 +68,23 @@ impl<'a> Request<'a> {
|
||||
request_type: util::get_request_type(&arg).unwrap(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn auth_type(&self) {
|
||||
match self.authentication.auth_type {
|
||||
AuthenticationType::BasicAuth => {
|
||||
URL_SAFE.encode(self.authentication.credentials.1.unwrap())
|
||||
}
|
||||
AuthenticationType::ApiToken => self.authentication.credentials.1,
|
||||
AuthenticationType::None => {
|
||||
// this shouldn't happen, ever
|
||||
panic!();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn url_builder(&self) {
|
||||
Ok()
|
||||
}
|
||||
}
|
||||
|
||||
impl Authentication {
|
||||
@ -140,3 +158,7 @@ impl Authentication {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for Authentication {
|
||||
fn default() -> Self {}
|
||||
}
|
||||
|
10
src/user.rs
10
src/user.rs
@ -224,4 +224,14 @@ impl User {
|
||||
Err(e) => panic!("{}", e),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn authed_user(&self, request: &Request) {
|
||||
let client = &request.client;
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for User {
|
||||
fn default() -> Self {
|
||||
User::new()
|
||||
}
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ pub enum ErrorKind {
|
||||
ForbiddenRequest,
|
||||
NotFound,
|
||||
UnprocessiableRequest,
|
||||
JsonError,
|
||||
}
|
||||
|
||||
// TODO: Can't get this function to properly work
|
||||
@ -60,6 +61,12 @@ pub fn bad_response_message(message: &String, error_kind: ErrorKind) -> String {
|
||||
ErrorKind::UnprocessiableRequest => {
|
||||
final_message = format!("Client error - the request can't be processed. Please try again!\nError message: {}", message);
|
||||
}
|
||||
ErrorKind::JsonError => {
|
||||
final_message = format!(
|
||||
"Client error - can't parse command!\nError message: {}",
|
||||
message
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
String::from(final_message)
|
||||
|
Loading…
Reference in New Issue
Block a user