GithubHelp home page GithubHelp logo

authz-sdk's Introduction

The authz-sdk package provides a browser module that can be used to interact with the authz daemon. It facilitates building integrations with the Zingle authentication service.

AuthZ SDK

The AuthZ SDK should be served from the same host as the authz authentication service. The SDK auto-detects the authentication server based where it is being served.

Functions

oauth

oauth(provider:string, flow:string)

The oauth function begins the process of authenticating through an OAuth provider. The provider name must match an OAuth provider name handled by the authz daemon. The flow mode must be "popup".

Calling oauth redirects the browser to the OAuth provider site. Upon successful authentication, a JWT token will be generated. How this token is handled depends on the flow mode.

import {oauth} from "https://authz.example.com/sdk/latest/authz-sdk.js";
oauth("google", "popup");

Flow: popup

In "popup" flow mode, the oauth function must be called from a popup window that is hosted on the same origin as the window which opens the popup. The popup window uses Window.postMessage to deliver the JWT to the window that opened the popup. The popupForJWT function can be used to implement this flow for the window that opens the popup.

popupForJWT

popupForJWT(popupURL:string|URL, callback:function)

The popupForJWT function begins the "popup" flow for authenticating with the authz daemon. This will open the popupURL page in a new window. This page is expected to negotiate a JWT token, then deliver it back to the window that opens the popup using the Window.postMessage function on the opener window. When the JWT has been posted back to the opener window, the popup will be closed and the JWT will be passed to the callback. The oauth function can be used to implement this flow in the popup window.

import {popupForJWT} from "https://authz.example.com/sdk/latest/authz-sdk.js";
// in this example, the login.html page should call the oauth function
popupForJWT("login.html", jwt => console.log(jwt));

returnJWT

Returns a JWT to the client. How this is accomplished depends on the flow mode requested by the client.

Flow: popup

In "popup" flow mode, the returnJWT function will use Window.postMessage on the window which opened the popup to deliver the JWT.

authz-sdk's People

Contributors

richremer avatar

Watchers

Zachary Quintana avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.