Struct rustwt::id_token::IDTokenBuilder [] [src]

pub struct IDTokenBuilder { /* fields omitted */ }

Utility structure for encoding ID-Tokens.

Example

use rustwt::id_token::{IDToken,IDTokenDecoder};
use rustwt::Algorithm;
static EC_PRIVATE_KEY: &str = include_str!("../test/ec_x9_62_prime256v1.private.key.pem");
static EC_PUBLIC_KEY: &str = include_str!("../test/ec_x9_62_prime256v1.public.key.pem");
let id_token = IDToken::build(
           "https://authority.example.org/auth",
           "user123",
           &["rp123"],
           60 * 2,
       ).acr("urn:mace:incommon:iap:silver")
           .amr(&["password"])
           .azp("rp123")
           .sign_with_pem(EC_PRIVATE_KEY, Algorithm::ES256)
           .expect("signing should work");

let id_token_decoder =
IDTokenDecoder::from_pem(EC_PUBLIC_KEY, "https://authority.example.org/auth", "rp123")
   .expect("should not fail");
let token_struct = id_token_decoder.decode(id_token).expect(
           "verification should not fail",
);
assert_eq!(token_struct.acr().unwrap(), "urn:mace:incommon:iap:silver");
assert_eq!(token_struct.amr()[0], "password");
assert_eq!(token_struct.azp().unwrap(), "rp123");

Methods

impl IDTokenBuilder
[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]