Back to all Bounties
Earn 1,111 ($11.11)
due 2 years ago
In Progress
Rust code to turn OAuth signature (e.g. Authentik) into a DID Verifiable Credential (e.g. disco.xyz, gitcoin passport)
bmorphism
Details
Applications
6
Discussion
Bounty Description
Identity signal
In the process of gathering a latent set of time-constrained signals from existing OAUth identity services a given user might bring from either SaaS (e.g. LinkedIn, Twitter, ...) or sovereignly operated (e.g. Authentik, self-hosted) GitLab -- for a universal interface of OAuth idP authn / authz.
# Specifically, adapt this codebaseextern crate reqwest;extern crate serde_json;use serde_json::{Value};// Function to retrieve DID from OAuth providerasync fn get_did(access_token: &str) -> Result<String, reqwest::Error> {let client = reqwest::Client::new();let api_url = format!("https://oauthprovider.com/api/did?access_token={}", access_token);let response = client.get(&api_url).send().await?;let did: String = response.json().await?;Ok(did)}// Function to sign VC using issuer's private keyfn sign_vc(vc: &str, private_key: &str) -> String {// Implementation to sign VC using private key goes here// ...let signed_vc = "signed VC".to_string();signed_vc}// Main function to sign Verifiable Credential#[tokio::main]async fn main() -> Result<(), Box<dyn std::error::Error>> {let access_token = "OAuth access token";let did = get_did(access_token).await?;let vc = "Verifiable Credential";let private_key = "Private key associated with issuer's DID";let signed_vc = sign_vc(vc, private_key);println!("Signed VC: {}", signed_vc);println!("Issuer's DID: {}", did);Ok(())}