GithubHelp home page GithubHelp logo

isabella232 / angular-jwt-authentication-example Goto Github PK

View Code? Open in Web Editor NEW

This project forked from oktadev/angular-jwt-authentication-example

0.0 0.0 0.0 204 KB

Angular Authentication with JWT

Home Page: https://developer.okta.com/blog/2019/05/16/angular-authentication-jwt

License: Apache License 2.0

JavaScript 18.16% TypeScript 72.68% CSS 0.54% HTML 8.63%

angular-jwt-authentication-example's Introduction

Angular Authentication with JWT

This example app shows how to build a JWT authentication with Node.js and Angular. It also shows how you can simplify JWT authentication by using Okta.

Please read Angular Authentication with JWT to see how this app was created.

Prerequisites: Node.js.

Okta has Authentication and User Management APIs that reduce development time with instant-on, scalable user infrastructure. Okta's intuitive API and expert support make it easy for developers to authenticate, manage and secure users and roles in any application.

Getting Started

To install this example application, run the following commands:

git clone https://github.com/oktadeveloper/angular-jwt-authentication-example.git
cd angular-jwt-authentication-example

This will get a copy of the project installed locally. There are a number of directories within this project:

jwt-client
jwt-server
okta-client
okta-server

If you'd like to run the bare-bones JWT examples (that doesn't use Okta), run npm install followed by npm start in the jwt-server and jwt-client directories. Make sure you do this in two separate terminal windows. You should then be able to register and authenticate at http://localhost:4200.

To run the Okta examples, you'll first need to create an OIDC app in Okta.

Create a New OIDC App in Okta

If you don't have an Okta developer account, please create one. Then, create a new OIDC app on Okta:

  1. Log in to your developer account, navigate to Applications > Add Application.
  2. Select Single-Page App > Next.
  3. Give the application a name, change all instances of https://localhost:8080 to https://localhost:4200, and click Done.

Server Configuration

Set your issuer and copy the clientId into okta-server/auth.js.

const oktaJwtVerifier = new OktaJwtVerifier({
  issuer: 'https://{yourOktaDomain}/oauth2/default',
  clientId: '{yourClientId}'
});

NOTE: The value of {yourOktaDomain} should be something like dev-123456.okta.com. Make sure you don't include -admin in the value!

Client Configuration

For the client, set the issuer and copy the clientId into okta-client/src/app/app.module.ts.

const oktaConfig = {
  issuer: 'https://{yourOktaDomain}/oauth2/default',
  redirectUri: 'http://localhost:4200/callback',
  clientId: '{yourClientId}',
  scope: 'openid profile'
}

Run npm install followed by npm start in the okta-server and okta-client directories. Make sure you do this in two separate terminal windows. You should then be able to authenticate at http://localhost:4200.

Links

This example uses the following open source libraries from Okta:

Help

Please post any questions as commnets on the blog post or ask them on the Okta Developer Forums. Our whole team monitors this channel and will see your questions. You can also enter them as issues on this project or ask them on Stack Overflow and add the okta tag.

License

Apache 2.0, see LICENSE.

angular-jwt-authentication-example's People

Contributors

holgerschmitz avatar mraible 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.