mirror of
https://gitlab.com/fabinfra/fabaccess/bffh.git
synced 2025-01-03 17:13:48 +01:00
switch to uuid parsing for tokens
This commit is contained in:
parent
795c9870e8
commit
a470d4eeb0
@ -14,6 +14,7 @@ use std::convert::TryFrom;
|
|||||||
use std::fmt::{Debug, Display, Formatter};
|
use std::fmt::{Debug, Display, Formatter};
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
use uuid::Uuid;
|
||||||
|
|
||||||
use crate::authentication::fabfire::FabFireCardKey;
|
use crate::authentication::fabfire::FabFireCardKey;
|
||||||
use crate::CONFIG;
|
use crate::CONFIG;
|
||||||
@ -361,8 +362,11 @@ impl Authentication for FabFire {
|
|||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
match apdu_response.body {
|
match apdu_response.body {
|
||||||
Some(data) => {
|
Some(data) => {
|
||||||
let authid = hex::encode(data)
|
let data = data.get(..16).ok_or(FabFireError::ParseError)?;
|
||||||
.trim_matches(char::from(0))
|
let authid = uuid::Uuid::from_slice(data)
|
||||||
|
.unwrap()
|
||||||
|
.to_hyphenated()
|
||||||
|
.encode_lower(&mut Uuid::encode_buffer())
|
||||||
.to_string();
|
.to_string();
|
||||||
let prov = ThisProvider::<AuthId>::with(&authid);
|
let prov = ThisProvider::<AuthId>::with(&authid);
|
||||||
let key = session
|
let key = session
|
||||||
|
@ -32,7 +32,10 @@ impl SessionCallback for Callback {
|
|||||||
) -> Result<(), SessionError> {
|
) -> Result<(), SessionError> {
|
||||||
if let Some(authid) = context.get_ref::<AuthId>() {
|
if let Some(authid) = context.get_ref::<AuthId>() {
|
||||||
request.satisfy_with::<FabFireCardKey, _>(|| {
|
request.satisfy_with::<FabFireCardKey, _>(|| {
|
||||||
let user = self.users.get_user_by_token(authid).ok_or(CallbackError::NoValue)?;
|
let user = self
|
||||||
|
.users
|
||||||
|
.get_user_by_token(authid)
|
||||||
|
.ok_or(CallbackError::NoValue)?;
|
||||||
let kv = user
|
let kv = user
|
||||||
.userdata
|
.userdata
|
||||||
.kv
|
.kv
|
||||||
|
@ -235,8 +235,12 @@ impl card_d_e_s_fire_e_v2::Server for User {
|
|||||||
let card_key = pry!(params.get_auth_key());
|
let card_key = pry!(params.get_auth_key());
|
||||||
let token = pry!(params.get_token());
|
let token = pry!(params.get_token());
|
||||||
|
|
||||||
let token: Cow<'_, str> = if let Ok(url) = std::str::from_utf8(token) {
|
let token: Cow<'_, str> = if let Ok(uuid) = Uuid::from_slice(token) {
|
||||||
Cow::Borrowed(url)
|
Cow::Owned(
|
||||||
|
uuid.to_hyphenated()
|
||||||
|
.encode_lower(&mut Uuid::encode_buffer())
|
||||||
|
.to_string(),
|
||||||
|
)
|
||||||
} else {
|
} else {
|
||||||
Cow::Owned(hex::encode(token))
|
Cow::Owned(hex::encode(token))
|
||||||
};
|
};
|
||||||
@ -310,8 +314,12 @@ impl card_d_e_s_fire_e_v2::Server for User {
|
|||||||
let params = pry!(params.get());
|
let params = pry!(params.get());
|
||||||
let token = pry!(params.get_token());
|
let token = pry!(params.get_token());
|
||||||
|
|
||||||
let token: Cow<'_, str> = if let Ok(url) = std::str::from_utf8(token) {
|
let token: Cow<'_, str> = if let Ok(uuid) = Uuid::from_slice(token) {
|
||||||
Cow::Borrowed(url)
|
Cow::Owned(
|
||||||
|
uuid.to_hyphenated()
|
||||||
|
.encode_lower(&mut Uuid::encode_buffer())
|
||||||
|
.to_string(),
|
||||||
|
)
|
||||||
} else {
|
} else {
|
||||||
Cow::Owned(hex::encode(token))
|
Cow::Owned(hex::encode(token))
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user