initial upload
This commit is contained in:
commit
1cb1abd85d
5 changed files with 291 additions and 0 deletions
8
.gitignore
vendored
Normal file
8
.gitignore
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
/target
|
||||
|
||||
|
||||
# Added by cargo
|
||||
#
|
||||
# already existing elements were commented out
|
||||
|
||||
#/target
|
82
Cargo.lock
generated
Normal file
82
Cargo.lock
generated
Normal file
|
@ -0,0 +1,82 @@
|
|||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 4
|
||||
|
||||
[[package]]
|
||||
name = "arraydeque"
|
||||
version = "0.5.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7d902e3d592a523def97af8f317b08ce16b7ab854c1985a0c671e6f15cebc236"
|
||||
|
||||
[[package]]
|
||||
name = "cfg-if"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||
|
||||
[[package]]
|
||||
name = "encoding_rs"
|
||||
version = "0.8.35"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "75030f3c4f45dafd7586dd6780965a8c7e8e285a5ecb86713e63a79c5b2766f3"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "foldhash"
|
||||
version = "0.1.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a0d2fde1f7b3d48b8395d5f2de76c18a528bd6a9cdde438df747bfcba3e05d6f"
|
||||
|
||||
[[package]]
|
||||
name = "hashbrown"
|
||||
version = "0.15.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289"
|
||||
dependencies = [
|
||||
"foldhash",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hashlink"
|
||||
version = "0.10.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7382cf6263419f2d8df38c55d7da83da5c18aef87fc7a7fc1fb1e344edfe14c1"
|
||||
dependencies = [
|
||||
"hashbrown",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "memchr"
|
||||
version = "2.7.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3"
|
||||
|
||||
[[package]]
|
||||
name = "pyffparser"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"winnow",
|
||||
"yaml-rust2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winnow"
|
||||
version = "0.7.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0e7f4ea97f6f78012141bcdb6a216b2609f0979ada50b20ca5b52dde2eac2bb1"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "yaml-rust2"
|
||||
version = "0.10.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "232bdb534d65520716bef0bbb205ff8f2db72d807b19c0bc3020853b92a0cd4b"
|
||||
dependencies = [
|
||||
"arraydeque",
|
||||
"encoding_rs",
|
||||
"hashlink",
|
||||
]
|
9
Cargo.toml
Normal file
9
Cargo.toml
Normal file
|
@ -0,0 +1,9 @@
|
|||
[package]
|
||||
name = "pyffparser"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
winnow = "0.7.3"
|
||||
yaml-rust2 = "0.10.0"
|
||||
|
61
pyff.fd
Normal file
61
pyff.fd
Normal file
|
@ -0,0 +1,61 @@
|
|||
- when local:
|
||||
- reginfo:
|
||||
authority: https://md.fidus.skolverket.se/test/
|
||||
policy:
|
||||
en: https://skolverket.se/fidus
|
||||
- break
|
||||
- when clean:
|
||||
- xslt:
|
||||
stylesheet: tidy.xsl
|
||||
- check_xml_namespaces
|
||||
- break
|
||||
- when update:
|
||||
- load:
|
||||
- /opt/metadata/skolfederation-trial cleanup clean
|
||||
- /opt/metadata/swamid cleanup clean
|
||||
- /opt/metadata/test-idp cleanup clean via local
|
||||
- /opt/metadata/test-sp cleanup clean via local
|
||||
- select
|
||||
- fork:
|
||||
- select as downstream:
|
||||
- https://fidustest.skolverket.se/shibboleth
|
||||
- https://sso.skolverket.sonet.com.au/module.php/saml/sp/metadata.php/sp1
|
||||
- https://sso.am.uat.skolverket.sonet.com.au/module.php/saml/sp/metadata.php/sp1
|
||||
- https://am-sso-int.skol.sonet.net.au/module.php/saml/sp/metadata.php/sp1
|
||||
- https://am-sso-utb.skol.sonet.net.au/module.php/saml/sp/metadata.php/sp1
|
||||
- https://am-sso.skol.sonet.net.au/module.php/saml/sp/metadata.php/sp1
|
||||
- https://am-sso-uat.skol.sonet.net.au/module.php/saml/sp/metadata.php/sp1
|
||||
- https://humhub-idp-proxy.sunet.se/sp
|
||||
- https://idpproxy.dev.eduid.se/sp
|
||||
- https://vfu-test.su.se/Shibboleth.sso
|
||||
- https://vfusyd-test.su.se/Shibboleth.sso
|
||||
- https://betyg.test.uhr.se/beda-inrapportering
|
||||
- https://betyg.uhr.se/beda-inrapportering
|
||||
- https://otc-skol-uat-sso.am.rm.com/module.php/saml/sp/metadata.php/sp1
|
||||
- break
|
||||
- fork:
|
||||
- select as ds
|
||||
- break
|
||||
- break
|
||||
- when request:
|
||||
- select
|
||||
- pipe:
|
||||
- when accept application/xml:
|
||||
- xslt:
|
||||
stylesheet: tidy.xsl
|
||||
- pubinfo:
|
||||
publisher: https://md.fidus.skolverket.se/test/
|
||||
- first
|
||||
- finalize:
|
||||
baseURL: https://md.fidus.skolverket.se/test/
|
||||
cacheDuration: PT5H
|
||||
validUntil: P10D
|
||||
- sign:
|
||||
key: /etc/credentials/pyff-signing-key.pem
|
||||
cert: /etc/credentials/metadata.crt
|
||||
- emit application/xml
|
||||
- break
|
||||
- when accept application/json:
|
||||
- discojson
|
||||
- emit application/json:
|
||||
- break
|
131
src/main.rs
Normal file
131
src/main.rs
Normal file
|
@ -0,0 +1,131 @@
|
|||
use std::collections::HashMap;
|
||||
use std::fs;
|
||||
use winnow::Parser;
|
||||
use winnow::Result;
|
||||
use yaml_rust2::{Yaml, YamlEmitter, YamlLoader};
|
||||
enum PyffrVerb {
|
||||
// dump,
|
||||
// map,
|
||||
Then,
|
||||
// log_entity,
|
||||
// print,
|
||||
// end,
|
||||
// fork,
|
||||
// break,
|
||||
// pipe,
|
||||
When,
|
||||
// info,
|
||||
// sort,
|
||||
// publish,
|
||||
// load,
|
||||
// select,
|
||||
// filter,
|
||||
// pick,
|
||||
// first,
|
||||
// discojson,
|
||||
// discojson_sp,
|
||||
// discojson_sp_attr,
|
||||
// sign,
|
||||
// stats,
|
||||
// summary,
|
||||
// store,
|
||||
// xslt,
|
||||
// indent,
|
||||
// validate,
|
||||
// prune,
|
||||
// check_xml_namespaces,
|
||||
// drop_xsi_type,
|
||||
// certreport,
|
||||
// emit,
|
||||
// signcerts,
|
||||
// finalize,
|
||||
// reginfo,
|
||||
// pubinfo,
|
||||
// setattr,
|
||||
// nodecountry
|
||||
}
|
||||
struct Pipeline {
|
||||
verb: String,
|
||||
args: Yaml,
|
||||
}
|
||||
|
||||
//
|
||||
//}
|
||||
//pub fn parse_pyff(input: &Yaml) -> &str {
|
||||
// let docs = YamlLoader::load_from_str(fs::read_to_string("pyff.fd").unwrap().as_str()).unwrap();
|
||||
// let mut out_str = String::new();
|
||||
// let mut emitter = YamlEmitter::new(&mut out_str);
|
||||
// let doc = &docs[0];
|
||||
// emitter.dump(&doc[0]).unwrap();
|
||||
// dbg!(out_str);
|
||||
// return "ok";
|
||||
//}
|
||||
|
||||
//[cfg(test)]
|
||||
//mod tests {
|
||||
// use super::*;
|
||||
//
|
||||
//[test]
|
||||
// fn test_pyff_parse() {
|
||||
// let docs = YamlLoader::load_from_str("[when, 2, 3]").unwrap();
|
||||
// let result = parse_pyff("asd");
|
||||
// assert_eq!(result, "asd");
|
||||
// }
|
||||
//}
|
||||
|
||||
fn when_fn(args: &Yaml) {
|
||||
println!("{:?}\n\n\n", args);
|
||||
}
|
||||
|
||||
fn parse(input: &Yaml, pipelines: Option<Vec<Pipeline>>) -> Vec<Pipeline> {
|
||||
let mut tmp: Vec<Pipeline> = pipelines.unwrap_or(Vec::new());
|
||||
for pipeline in input.as_vec().unwrap() {
|
||||
if pipeline.is_array() {
|
||||
println!("Is Array");
|
||||
}
|
||||
if pipeline.is_hash() {
|
||||
println!("Is Array");
|
||||
}
|
||||
for key in pipeline.as_hash().unwrap().keys() {
|
||||
let _key = key
|
||||
.as_str()
|
||||
.unwrap()
|
||||
.split_ascii_whitespace()
|
||||
.nth(0)
|
||||
.unwrap();
|
||||
println!("{:?}", key);
|
||||
println!("{:?}", pipeline.as_hash().unwrap()[key].clone());
|
||||
match _key {
|
||||
_ => tmp.push(Pipeline {
|
||||
verb: _key.to_string(),
|
||||
args: pipeline.as_hash().unwrap()[key].clone(), // TODO check is_string ->
|
||||
// recurse
|
||||
}),
|
||||
}
|
||||
}
|
||||
}
|
||||
return tmp;
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let docs = YamlLoader::load_from_str(fs::read_to_string("pyff.fd").unwrap().as_str()).unwrap();
|
||||
let doc = &docs[0];
|
||||
let pipelines = parse(doc, None);
|
||||
for pipeline in pipelines {
|
||||
println!("main: {:?}", pipeline.args.as_hash().unwrap().keys());
|
||||
for key in pipeline.args.as_hash().unwrap().keys() {
|
||||
match key
|
||||
.as_str()
|
||||
.unwrap()
|
||||
.split_ascii_whitespace()
|
||||
.nth(0)
|
||||
.unwrap()
|
||||
{
|
||||
"when" => when_fn(&pipeline.args),
|
||||
_ => println!("Unimplemented: {:?}", key),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// println!("{:?}", doc);
|
||||
}
|
Loading…
Add table
Reference in a new issue