[][src]Struct firestore_db_and_auth::credentials::Credentials

pub struct Credentials {
    pub project_id: String,
    pub private_key_id: String,
    pub client_email: String,
    pub client_id: String,
    pub api_key: String,
    pub pub_key: BTreeMap<String, RSAKeyParameters>,
    pub private_key_der: Vec<u8>,
    // some fields omitted
}

Service account credentials

Especially the service account email is required to retrieve the public java web key set (jwks) for verifying Google Firestore tokens.

The api_key is necessary for interacting with the Firestore REST API.

The private key is used for signing java web tokens (jwk). Those can be exchanged into a refresh and access token.

Fields

project_id: Stringprivate_key_id: Stringclient_email: Stringclient_id: Stringapi_key: Stringpub_key: BTreeMap<String, RSAKeyParameters>

This is not defined in the json file and computed

private_key_der: Vec<u8>

This is not defined in the json file and computed

Methods

impl Credentials[src]

pub fn public_key(&self, kid: &str) -> Option<&RSAKeyParameters>[src]

Find the key in the set that matches the given key id, if any.

pub fn create_rsa_key_pair(&self) -> Result<RsaKeyPair>[src]

Creates a ring RsaKeyPair out of the private key of this credentials object

pub fn from_file(credential_file: &str) -> Result<Self>[src]

Create a Crentials object of a google-service-account json file.

The corresponding jwks (public keys) for the given service account as well as the "securetoken@system.gserviceaccount.com" are downloaded if you use this method.

pub fn add_jwks_public_keys(&mut self, jwkset: JWKSetDTO)[src]

Add a jwks file to verify Google access tokens

Example:

use firestore_db_and_auth::credentials::Credentials;

let mut c : Credentials = serde_json::from_str(include_str!("../firebase-service-account.json")).unwrap();
c.add_jwks_public_keys(serde_json::from_str(include_str!("../service-account-for-tests.jwks")).unwrap());
c.compute_missing_fields().unwrap();

pub fn compute_missing_fields(&mut self) -> Result<()>[src]

Call this method after deserializing.

If you haven't called [add_jwks_public_keys] before and manually added public keys, this method will download one for your google service account and one for the oauth related securetoken@system.gserviceaccount.com service account.

Trait Implementations

impl Default for Credentials[src]

impl Clone for Credentials[src]

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl FromStr for Credentials[src]

type Err = Error

The associated error which can be returned from parsing.

impl Serialize for Credentials[src]

impl<'de> Deserialize<'de> for Credentials[src]

Auto Trait Implementations

Blanket Implementations

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: Deserialize<'de>, 
[src]

impl<T> Erased for T

impl<'a, T> TryFrom<&'a str> for T where
    T: FromStr

type Err = <T as FromStr>::Err

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 

type Err = <U as TryFrom<T>>::Err