Add session::token() function for retrieving authentication token claims data
This commit is contained in:
parent
0d4d2359d4
commit
2bc44af8cd
4 changed files with 9 additions and 0 deletions
|
@ -134,6 +134,7 @@ pub fn synchronous(ctx: &Context<'_>, name: &str, args: Vec<Value>) -> Result<Va
|
|||
"session::origin" => args::check(ctx, name, args, Args::None, session::origin),
|
||||
"session::sc" => args::check(ctx, name, args, Args::None, session::sc),
|
||||
"session::sd" => args::check(ctx, name, args, Args::None, session::sd),
|
||||
"session::token" => args::check(ctx, name, args, Args::None, session::token),
|
||||
//
|
||||
"string::concat" => args::check(ctx, name, args, Args::Any, string::concat),
|
||||
"string::endsWith" => args::check(ctx, name, args, Args::Two, string::ends_with),
|
||||
|
|
|
@ -7,6 +7,7 @@ use crate::sql::paths::NS;
|
|||
use crate::sql::paths::OR;
|
||||
use crate::sql::paths::SC;
|
||||
use crate::sql::paths::SD;
|
||||
use crate::sql::paths::TK;
|
||||
use crate::sql::value::Value;
|
||||
|
||||
pub fn db(ctx: &Context, _: Vec<Value>) -> Result<Value, Error> {
|
||||
|
@ -36,3 +37,7 @@ pub fn sc(ctx: &Context, _: Vec<Value>) -> Result<Value, Error> {
|
|||
pub fn sd(ctx: &Context, _: Vec<Value>) -> Result<Value, Error> {
|
||||
ctx.value("session").unwrap_or(&Value::None).pick(SD.as_ref()).ok()
|
||||
}
|
||||
|
||||
pub fn token(ctx: &Context, _: Vec<Value>) -> Result<Value, Error> {
|
||||
ctx.value("session").unwrap_or(&Value::None).pick(TK.as_ref()).ok()
|
||||
}
|
||||
|
|
|
@ -394,6 +394,7 @@ fn function_session(i: &str) -> IResult<&str, &str> {
|
|||
tag("session::origin"),
|
||||
tag("session::sc"),
|
||||
tag("session::sd"),
|
||||
tag("session::token"),
|
||||
))(i)
|
||||
}
|
||||
|
||||
|
|
|
@ -15,6 +15,8 @@ pub static SD: Lazy<[Part; 1]> = Lazy::new(|| [Part::from("sd")]);
|
|||
|
||||
pub static OR: Lazy<[Part; 1]> = Lazy::new(|| [Part::from("or")]);
|
||||
|
||||
pub static TK: Lazy<[Part; 1]> = Lazy::new(|| [Part::from("tk")]);
|
||||
|
||||
pub static IN: Lazy<[Part; 1]> = Lazy::new(|| [Part::from("in")]);
|
||||
|
||||
pub static OUT: Lazy<[Part; 1]> = Lazy::new(|| [Part::from("out")]);
|
||||
|
|
Loading…
Reference in a new issue