Git Product home page Git Product logo

muharremokutan / okta-angular-openid-connect-example Goto Github PK

View Code? Open in Web Editor NEW

This project forked from oktadev/okta-angular-openid-connect-example

0.0 1.0 0.0 1.98 MB

Angular + Angular CLI with Authentication from OpenID Connect and Okta

Home Page: http://developer.okta.com/blog/2017/04/17/angular-authentication-with-oidc

License: Apache License 2.0

JavaScript 5.51% TypeScript 84.03% HTML 9.07% CSS 1.38%

okta-angular-openid-connect-example's Introduction

Angular Authentication with OpenID Connect and Okta

This example app shows how to use angular-oauth2-oidc and the Okta Auth SDK to perform authentication in an Angular app.

Please read Angular Authentication with OpenID Connect and Okta in 20 Minutes to learn how to create this application.

This project was generated with Angular CLI version 6.0.0.

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/okta-angular-openid-connect-example.git
cd okta-angular-openid-connect-example
npm install

This will get a copy of the project installed locally, install all of its dependencies and start the app.

Create an OIDC App in Okta

You will need to create an OIDC App in Okta to get your values to perform authentication.

OpenID Connect is built on top of the OAuth 2.0 protocol. It allows clients to verify the identity of the user and, as well as to obtain their basic profile information. To learn more, see http://openid.net/connect.

Login to your Okta account, or create one if you don't have one. Navigate to Applications and click on the Add Application button. Select SPA and click Next. On the next page, specify http://localhost:4200 as a Base URI, Login redirect URI, and Logout redirect URI. Click Done and copy the generated Client ID.

In src/app/app.component.ts, set the issuer and paste your clientId.

constructor(private oauthService: OAuthService) {
  this.oauthService.redirectUri = window.location.origin;
  this.oauthService.clientId = '{clientId}';
  this.oauthService.scope = 'openid profile email';
  this.oauthService.issuer = 'https://{yourOktaDomain}.com/oauth2/default';
  this.oauthService.tokenValidationHandler = new JwksValidationHandler();
  
  // Load Discovery Document and then try to login the user
  this.oauthService.loadDiscoveryDocumentAndTryLogin();
}

You'll also need to update the url in src/app/shared/auth/okta.auth.wrapper.ts.

constructor(private oauthService: OAuthService) {
  this.authClient = new OktaAuth({
    url: 'https://{yourOktaDomain}.com',
    issuer: 'default'
  });
}

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

After making these changes, you should be able to start the app (using ng serve) and log in with your credentials at http://localhost:4200.

Links

This example uses the following libraries provided by Okta:

It also uses the following library provided by Manfred Steyer:

Help

Please post any questions as comments on the blog post, or visit our Okta Developer Forums. You can also email [email protected] if would like to create a support ticket.

To get more help on the Angular CLI use ng help or go check out the Angular CLI README.

License

Apache 2.0, see LICENSE.

okta-angular-openid-connect-example's People

Contributors

mraible avatar jmelberg-okta avatar

Watchers

James Cloos 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.