All Projects → openid → Appauth Js

openid / Appauth Js

Licence: apache-2.0
JavaScript client SDK for communicating with OAuth 2.0 and OpenID Connect providers.

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to Appauth Js

IdentityServerSample
Sample ASP.NET Core MVC and Angular apps and API using Identity Server 4
Stars: ✭ 25 (-96.21%)
Mutual labels:  oauth2, openid-connect
Jpproject.identityserver4.sso
🔒 ASP.NET Core 3.1 Open Source SSO. Built within IdentityServer4 🔑
Stars: ✭ 298 (-54.78%)
Mutual labels:  oauth2, openid-connect
oxd
Client software to secure apps with OAuth 2.0, OpenID Connect, and UMA
Stars: ✭ 40 (-93.93%)
Mutual labels:  oauth2, openid-connect
Identityserver4.samples
Samples for IdentityServer4,use .net core 2.0
Stars: ✭ 561 (-14.87%)
Mutual labels:  oauth2, openid-connect
Django Oidc Provider
OpenID Connect and OAuth2 provider implementation for Djangonauts.
Stars: ✭ 320 (-51.44%)
Mutual labels:  oauth2, openid-connect
mock-oauth2-server
A scriptable/customizable web server for testing HTTP clients using OAuth2/OpenID Connect or applications with a dependency to a running OAuth2 server (i.e. APIs requiring signed JWTs from a known issuer)
Stars: ✭ 83 (-87.41%)
Mutual labels:  oauth2, openid-connect
Angularaspnetcoreoauth
Sample project demonstrating user authentication and identity with Angular, Asp.Net Core and IdentityServer4
Stars: ✭ 268 (-59.33%)
Mutual labels:  oauth2, openid-connect
Authing
🔥Authing - IDaaS/IAM solution that can Auth to web and mobile applications.
Stars: ✭ 247 (-62.52%)
Mutual labels:  oauth2, openid-connect
Identitymodel.oidcclient
Certified C#/NetStandard OpenID Connect Client Library for native mobile/desktop Applications (RFC 8252)
Stars: ✭ 316 (-52.05%)
Mutual labels:  oauth2, openid-connect
Oxauth
OAuth 2.0 server and client; OpenID Connect Provider (OP) & UMA Authorization Server (AS)
Stars: ✭ 308 (-53.26%)
Mutual labels:  oauth2, openid-connect
yii-auth-client
Yii Framework external authentication via OAuth and OpenID Extension
Stars: ✭ 20 (-96.97%)
Mutual labels:  oauth2, openid-connect
Cloudfront Auth
An AWS CloudFront [email protected] function to authenticate requests using Google Apps, Microsoft, Auth0, OKTA, and GitHub login
Stars: ✭ 471 (-28.53%)
Mutual labels:  oauth2, openid-connect
GoogleSignIn-iOS
Enables iOS and macOS apps to sign in with Google.
Stars: ✭ 198 (-69.95%)
Mutual labels:  oauth2, openid-connect
secure-oauth2-oidc-workshop
Hands-On Workshop for OAuth 2.0 and OpenID Connect 1.0
Stars: ✭ 58 (-91.2%)
Mutual labels:  oauth2, openid-connect
logto
🧑‍🚀 Logto helps you build the sign-in, auth, and user identity within minutes. We provide an OIDC-based identity service and the end-user experience with username, phone number, email, and social sign-in, with extendable multi-language support.
Stars: ✭ 3,421 (+419.12%)
Mutual labels:  oauth2, openid-connect
werther
An Identity Provider for ORY Hydra over LDAP
Stars: ✭ 103 (-84.37%)
Mutual labels:  oauth2, openid-connect
Auth0.net
.NET client for the Auth0 Authentication & Management APIs.
Stars: ✭ 200 (-69.65%)
Mutual labels:  oauth2, openid-connect
Authlib
The ultimate Python library in building OAuth, OpenID Connect clients and servers. JWS,JWE,JWK,JWA,JWT included.
Stars: ✭ 2,854 (+333.08%)
Mutual labels:  oauth2, openid-connect
Caddy Auth Portal
Authentication Plugin for Caddy v2 implementing Form-Based, Basic, Local, LDAP, OpenID Connect, OAuth 2.0 (Github, Google, Facebook, Okta, etc.), SAML Authentication
Stars: ✭ 291 (-55.84%)
Mutual labels:  oauth2, openid-connect
Passport
Simple, unobtrusive authentication for Node.js.
Stars: ✭ 19,608 (+2875.42%)
Mutual labels:  oauth2, openid-connect

AppAuth for JS

AppAuth for JavaScript is a client SDK for public clients for communicating with OAuth 2.0 and OpenID Connect providers following the best practice RFC 8252 - OAuth 2.0 for Native Apps. The library is designed for use in Web Apps, Node.js CLI applications, Chrome Apps and applications that use Electron or similar frameworks.

It strives to directly map the requests and responses of those specifications, while following the idiomatic style of the implementation language.

The library also supports the PKCE extension to OAuth which was created to secure authorization codes in public clients when custom URI scheme redirects are used. The library is friendly to other extensions (standard or otherwise) with the ability to handle additional parameters in all protocol requests and responses.

Examples

An example application using the library is included in the src/node_app folder and at https://github.com/googlesamples/appauth-js-electron-sample.

Auth Flow

AppAuth supports manual interaction with the Authorization Server where you need to perform your own token exchanges. This example performs a manual exchange.

Fetch Service Configuration
AuthorizationServiceConfiguration.fetchFromIssuer(openIdConnectUrl)
  .then(response => {
    log('Fetched service configuration', response);
    this.configuration = response;
    this.showMessage('Completed fetching configuration');
  })
  .catch(error => {
    log('Something bad happened', error);
    this.showMessage(`Something bad happened ${error}`)
  });
Make Authorization Requests
this.notifier = new AuthorizationNotifier();
// uses a redirect flow
this.authorizationHandler = new RedirectRequestHandler();
// set notifier to deliver responses
this.authorizationHandler.setAuthorizationNotifier(this.notifier);
// set a listener to listen for authorization responses
this.notifier.setAuthorizationListener((request, response, error) => {
  log('Authorization request complete ', request, response, error);
  if (response) {
    this.code = response.code;
    this.showMessage(`Authorization Code ${response.code}`);
  }
});

// create a request
let request = new AuthorizationRequest({
    client_id: clientId,
    redirect_uri: redirectUri,
    scope: scope,
    response_type: AuthorizationRequest.RESPONSE_TYPE_CODE,
    state: undefined,
    extras: {'prompt': 'consent', 'access_type': 'offline'}
  });

// make the authorization request
this.authorizationHandler.performAuthorizationRequest(this.configuration, request);
Making Token Requests
this.tokenHandler = new BaseTokenRequestHandler();

let request: TokenRequest|null = null;

if (this.code) {
  let extras: StringMap|undefined = undefined;
  if (this.request && this.request.internal) {
    extras = {};
    extras['code_verifier'] = this.request.internal['code_verifier'];
  }
  // use the code to make the token request.
  request = new TokenRequest({
      client_id: clientId,
      redirect_uri: redirectUri,
      grant_type: GRANT_TYPE_AUTHORIZATION_CODE,
      code: this.code,
      refresh_token: undefined,
      extras: extras
    });
} else if (this.tokenResponse) {
  // use the token response to make a request for an access token
  request = new TokenRequest({
      client_id: clientId,
      redirect_uri: redirectUri,
      grant_type: GRANT_TYPE_REFRESH_TOKEN,
      code: undefined,
      refresh_token: this.tokenResponse.refreshToken,
      extras: undefined
    });
}

this.tokenHandler.performTokenRequest(this.configuration, request)
  .then(response => {
    // ... do something with token response
  });

Development

Preamble

This client has been written with TypeScript.

Setup

  • Install the latest version of Node. NVM (Node Version Manager is highly recommended).

  • Use nvm install to install the recommended Node.js version.

  • Download the latest version of Visual Studio Code from here.

Provision Dependencies

This app uses npm to provision it dependencies.

  • git clone the AppAuthJS library and go to the root folder of the project containing package.json file.
  • npm install to install all the dev and project dependencies.

Thats it! You are now ready to start working on AppAuthJS.

Development Workflow

The project uses npm scripts to automate development workflows. These scripts are made available via the package.json file.

The following scripts are included:

  • npm run-script compile or tsc will compile all your TypeScript files. All compiled files go into the built/ folder.

  • npm run-script watch or tsc --watch will compile your TypeScript files in watch mode. Recommended if you want to get continuous feedback.

  • npm run-script build-app generates the output bundle.js file in the built/ directory. This includes the full AppAuthJS library including all its dependencies.

  • npm test provisions the Karma test runner to run all unit tests. All tests are written using Jasmine. To DEBUG your tests, click on the Debug button in the Karma test runner to look at the actual source of the tests. You can attach break points here.

  • npm run-script app builds the test app on a local web server. This is an end-to-end app which uses AppAuthJS and is a demonstration on how to use the library.

  • npm run-script node-app builds a Node.js CLI sample app. This is an end-to-end app which uses AppAuthJS in a Node.js context.

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].