Add authentication from upstream providers (#107)
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
Let BasicOIDC delegate authentication to upstream providers (Google, GitHub, GitLab, Keycloak...) Reviewed-on: #107
This commit is contained in:
@ -21,7 +21,7 @@ pub struct TotpKey {
|
||||
impl TotpKey {
|
||||
/// Generate a new TOTP key
|
||||
pub fn new_random() -> Self {
|
||||
let random_bytes = rand::thread_rng().gen::<[u8; 10]>();
|
||||
let random_bytes = rand::thread_rng().gen::<[u8; 20]>();
|
||||
Self {
|
||||
encoded: base32::encode(BASE32_ALPHABET, &random_bytes),
|
||||
}
|
||||
@ -40,10 +40,10 @@ impl TotpKey {
|
||||
pub fn url_for_user(&self, u: &User, conf: &AppConfig) -> String {
|
||||
format!(
|
||||
"otpauth://totp/{}:{}?secret={}&issuer={}&algorithm=SHA1&digits={}&period={}",
|
||||
urlencoding::encode(conf.domain_name()),
|
||||
urlencoding::encode(conf.domain_name_without_port()),
|
||||
urlencoding::encode(&u.username),
|
||||
self.encoded,
|
||||
urlencoding::encode(conf.domain_name()),
|
||||
urlencoding::encode(conf.domain_name_without_port()),
|
||||
NUM_DIGITS,
|
||||
PERIOD,
|
||||
)
|
||||
@ -53,7 +53,7 @@ impl TotpKey {
|
||||
pub fn account_name(&self, u: &User, conf: &AppConfig) -> String {
|
||||
format!(
|
||||
"{}:{}",
|
||||
urlencoding::encode(conf.domain_name()),
|
||||
urlencoding::encode(conf.domain_name_without_port()),
|
||||
urlencoding::encode(&u.username)
|
||||
)
|
||||
}
|
||||
|
Reference in New Issue
Block a user