Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Open sidebar
DNS Witch
Nomilo
Commits
853b7609
Commit
853b7609
authored
Mar 27, 2021
by
Gaël Berthaud-Müller
Browse files
secret as string and not bytes
parent
759bf0cb
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
3 additions
and
12 deletions
+3
-12
src/config.rs
src/config.rs
+1
-10
src/models/users.rs
src/models/users.rs
+2
-2
No files found.
src/config.rs
View file @
853b7609
...
...
@@ -20,20 +20,11 @@ pub struct DnsConfig {
#[derive(Debug,
Deserialize)]
pub
struct
WebAppConfig
{
#[serde(deserialize_with
=
"from_base64"
)]
pub
secret
:
Vec
<
u8
>
,
pub
secret
:
String
,
#[serde(deserialize_with
=
"from_duration"
)]
pub
token_duration
:
Duration
,
}
fn
from_base64
<
'de
,
D
>
(
deserializer
:
D
)
->
Result
<
Vec
<
u8
>
,
D
::
Error
>
where
D
:
Deserializer
<
'de
>
{
use
serde
::
de
::
Error
;
String
::
deserialize
(
deserializer
)
.and_then
(|
string
|
base64
::
decode
(
&
string
)
.map_err
(|
err
|
Error
::
custom
(
err
.to_string
())))
}
fn
from_duration
<
'de
,
D
>
(
deserializer
:
D
)
->
Result
<
Duration
,
D
::
Error
>
where
D
:
Deserializer
<
'de
>
{
...
...
src/models/users.rs
View file @
853b7609
...
...
@@ -200,7 +200,7 @@ impl AuthClaims {
}
}
pub
fn
encode
(
self
,
secret
:
&
[
u8
]
)
->
JwtResult
<
String
>
{
encode
(
&
Header
::
default
(),
&
self
,
&
EncodingKey
::
from_secret
(
&
secret
))
pub
fn
encode
(
self
,
secret
:
&
str
)
->
JwtResult
<
String
>
{
encode
(
&
Header
::
default
(),
&
self
,
&
EncodingKey
::
from_secret
(
secret
.as_bytes
()
))
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment