All Projects → durch → rust-goauth

durch / rust-goauth

Licence: MIT license
Crate for authenticating Server to Server Apps for Google Cloud Engine.

Programming Languages

rust
11053 projects
Dockerfile
14818 projects

Projects that are alternatives of or similar to rust-goauth

google-kubernetes-engine-plugin
The Google Kubernetes Engine (GKE) Plugin allows you to deploy build artifacts to Kubernetes clusters running in GKE with Jenkins.
Stars: ✭ 33 (+65%)
Mutual labels:  google-cloud
astrobase
Simple, fast, and secure deployments anywhere.
Stars: ✭ 47 (+135%)
Mutual labels:  google-cloud
laravel-vue-starter
Well Documented Laravel Starter App From Development to Production. For Full Blown RESTFUL API and SPA with Beautiful UI Using Buefy / ElementUi For Reusable Vue Components
Stars: ✭ 80 (+300%)
Mutual labels:  jwt-authentication
datacatalog-tag-manager
Python package to manage Google Cloud Data Catalog tags, loading metadata from external sources -- currently supports the CSV file format
Stars: ✭ 17 (-15%)
Mutual labels:  google-cloud
spring-examples
Starter projects with Spring using Java and Kotlin. Contains modules that covers Security with JWT, Spring with Kotlin, Dependency injection simplified etc.
Stars: ✭ 33 (+65%)
Mutual labels:  jwt-authentication
NodeScalableArchitecture
A Scalable Node Architecture/Server. This repository contains a complete implementation of writing scalable nodejs server/architecture on my medium blog.
Stars: ✭ 62 (+210%)
Mutual labels:  jwt-authentication
online-training
Online Training website using ASP.Net Core 2.0 & Angular 4
Stars: ✭ 26 (+30%)
Mutual labels:  jwt-authentication
API-Authentication-NodeJs
API Authentication using JWT's (JSON Web Tokens). Plug n Play inside any app which requires authentication. NodeJs Express MongoDB & Redis.
Stars: ✭ 162 (+710%)
Mutual labels:  jwt-authentication
socialApp-MERN
Social Networking web app similar to Instagram.
Stars: ✭ 35 (+75%)
Mutual labels:  jwt-authentication
cloud-pubsub
Google Cloud PubSub client in rust
Stars: ✭ 27 (+35%)
Mutual labels:  google-cloud
december-2018-meetup
🤖 Build an API with Laravel 5.7
Stars: ✭ 27 (+35%)
Mutual labels:  jwt-authentication
drf-jwt-example
Code samples of the tutorial "How to Use JWT Authentication with Django REST Framework"
Stars: ✭ 31 (+55%)
Mutual labels:  jwt-authentication
sails-jwt-login
How to implement login with JWT (JSON Web Tokens) in Sails 1.0
Stars: ✭ 18 (-10%)
Mutual labels:  jwt-authentication
Auth-using-Vuejs-express-jwt-nodejs
Login and signup form and authentication using Vue.js, express, mongodb, JWT and bootstrap-vue
Stars: ✭ 17 (-15%)
Mutual labels:  jwt-authentication
microprofile1.2-samples
Eclipse MicroProfile 1.2 Samples
Stars: ✭ 22 (+10%)
Mutual labels:  jwt-authentication
drf-angular-docker-tutorial
Dockerized Django Back-end API using DRF with Angular Front-end Tutorial
Stars: ✭ 53 (+165%)
Mutual labels:  jwt-authentication
jersey-jwt-springsecurity
Example of REST API with JWT authentication using Spring Boot, Spring Security, Jersey and Jackson.
Stars: ✭ 44 (+120%)
Mutual labels:  jwt-authentication
Php-Google-Vision-Api
Google Vision Api for PHP (https://cloud.google.com/vision/)
Stars: ✭ 61 (+205%)
Mutual labels:  google-cloud
node-mongodb-graphql-starter
A boilerplate for Node.js, MongoDB & GraphQL applications.
Stars: ✭ 56 (+180%)
Mutual labels:  jwt-authentication
flask-jwt-login
Flask extension that helps authentication using JWT (for a personal purpose, not maintained now)
Stars: ✭ 12 (-40%)
Mutual labels:  jwt-authentication

build MIT licensed

rust-goauth [docs]

Crate for using OAuth 2.0 with Server to Server Applications for Google Cloud Engine, with tentative support for all supported Scopes. Supports sync or async requests via Futures.

Provides a serialisable Token struct for use in other applications that require authenticated interactions with Google Cloud.

Usage

#[macro_use]
extern crate log;

use goauth::auth::JwtClaims;
use goauth::scopes::Scope;
use goauth::{get_token, get_token_blocking, GoErr};
use goauth::credentials::Credentials;
use goauth::fetcher::TokenFetcher;
use smpl_jwt::{RSAKey, Jwt};
use time::Duration;

fn main() -> Result<(), GoErr>{
  let token_url = "https://www.googleapis.com/oauth2/v4/token";
  let iss = "<some-iss>"; // https://developers.google.com/identity/protocols/OAuth2ServiceAccount

  let credentials = Credentials::from_file("dummy_credentials_file_for_tests.json").unwrap();
  let claims = JwtClaims::new(String::from(iss),
                             &Scope::DevStorageReadWrite,
                             String::from(token_url),
                             None, None);
  let jwt = Jwt::new(claims, credentials.rsa_key().unwrap(), None);

  // Use async
  let token = async {
    match get_token(&jwt, &credentials).await {
      Ok(token) => token,
      Err(e) => panic!(e)
    }
  };

  // Or sync
  let token = get_token_blocking(&jwt, &credentials)?;

  // Token provides `access_token` method that outputs a value that should be placed in the Authorization header

  // Or use the TokenFetcher abstraction which will automatically refresh tokens
  let fetcher = TokenFetcher::new(jwt, credentials, Duration::new(1, 0));

  let token = async {
    match fetcher.fetch_token().await {
      Ok(token) => token,
      Err(e) => panic!(e)
    }
  };

  // Now a couple seconds later we want the token again - the initial token is cached so it will re-use
  // the same token, saving a network trip to fetch another token
  let new_token = async {
    match fetcher.fetch_token().await {
      Ok(token) => token,
      Err(e) => panic!(e)
    }
  };

  assert_eq!(token, new_token);

  // Now say the token has expired or is close to expiring ("close" defined by the configurable
  // `refresh_buffer` parameter) at this point "later in the program." The next call to
  // `fetch_token` will notice this and automatically fetch a new token, cache it, and return it.
  let new_token = async {
    match fetcher.fetch_token().await {
      Ok(token) => token,
      Err(e) => panic!(e)
    }
  };

  assert_ne!(token, new_token);

  Ok(())
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].