update keys route

This commit is contained in:
marin postma 2021-06-24 15:37:18 +02:00
parent fab50256bc
commit 817fcfdd88
No known key found for this signature in database
GPG Key ID: 6088B7721C3E39F9

View File

@ -1,13 +1,11 @@
use actix_web::get;
use actix_web::web;
use actix_web::HttpResponse;
use actix_web::{web, HttpResponse};
use serde::Serialize;
use crate::helpers::Authentication;
use crate::Data;
use crate::extractors::authentication::{GuardedData, policies::*};
pub fn services(cfg: &mut web::ServiceConfig) {
cfg.service(list);
cfg.route("/keys", web::get().to(list));
}
#[derive(Serialize)]
@ -16,8 +14,7 @@ struct KeysResponse {
public: Option<String>,
}
#[get("/keys", wrap = "Authentication::Admin")]
async fn list(data: web::Data<Data>) -> HttpResponse {
async fn list(data: GuardedData<Admin, Data>) -> HttpResponse {
let api_keys = data.api_keys.clone();
HttpResponse::Ok().json(&KeysResponse {
private: api_keys.private,