Add support for Organization token

This is a WIP for adding organization token login support.
It has basic token login and verification support, but that's about it.

This branch is a refresh of the previous version, and will contain code
from a PR based upon my previous branch.
This commit is contained in:
BlackDex
2023-06-02 21:36:15 +02:00
parent bd883de70e
commit 4219249e11
15 changed files with 272 additions and 18 deletions

View File

@@ -1,6 +1,6 @@
use chrono::{NaiveDateTime, Utc};
use crate::CONFIG;
use crate::{crypto, CONFIG};
db_object! {
#[derive(Identifiable, Queryable, Insertable, AsChangeset)]
@@ -47,9 +47,7 @@ impl Device {
}
pub fn refresh_twofactor_remember(&mut self) -> String {
use crate::crypto;
use data_encoding::BASE64;
let twofactor_remember = crypto::encode_random_bytes::<180>(BASE64);
self.twofactor_remember = Some(twofactor_remember.clone());
@@ -68,9 +66,7 @@ impl Device {
) -> (String, i64) {
// If there is no refresh token, we create one
if self.refresh_token.is_empty() {
use crate::crypto;
use data_encoding::BASE64URL;
self.refresh_token = crypto::encode_random_bytes::<64>(BASE64URL);
}