App to demonstrate angular 2 app with MEAN stack using the Angular CLI. Doing server side authetication using okta open id connect.It will do CRUD operations for posts. Please check mongoose schema file.
#MEAN Stack Prerequisites
MongoDB: https://docs.mongodb.com/manual/introduction/
Express.js: http://expressjs.com/
Angular 2: http://angular.io
Node.js: https://nodejs.org
Make sure you have angular cli installed.
$ npm install -g angular-cli
Clone the repo
$ git clone https://github.com/tusharbudhe0302/okta-ng2-mean-stack.git
$ cd okta-ng2-mean-stack
#oidc-middleware
This package makes it easy to get your users logged in with Okta using OpenId Connect (OIDC). It enables your Express application to participate in the [authorization code flow][auth-code-docs] flow by redirecting the user to Okta for authentication and handling the callback from Okta. Once this flow is complete, a local session is created and the user context is saved for the duration of the session.
You will need an Okta Developer Org, you can sign up for an account at Markup : Developer Link
Go to server.js in root directory and change with your app configurations.
To configure your OIDC integration, create an instance of ExpressOIDC
and pass options. Most apps will need this basic configuration:
const { ExpressOIDC } = require('@okta/oidc-middleware');
const oidc = new ExpressOIDC({
issuer: YOUR_ISSUER,
client_id: YOUR_CLIENT_ID,
client_secret: YOUR_CLIENT_SECRET,
redirect_uri: YOUR_REDIRECT_URI,
scope: 'openid profile' /*optional you can remove this line.*/
});
Required config:
- issuer - The OIDC provider (e.g.
https://YOUR_ORG.oktapreview.com/oauth2/default
) - client_id - An id provided when you create an OIDC app in your Okta Org
- client_secret - A secret provided when you create an OIDC app in your Okta Org
- redirect_uri - The callback for your app. Locally, this is usually
http://localhost:3000/authorization-code/callback
. When deployed, this should behttps://YOUR_PROD_DOMAIN/authorization-code/callback
.
Optional config:
- response_type - Defaults to
code
- scope - Defaults to
openid
, which will only return thesub
claim. To obtain more information about the user, useopenid profile
. For a list of scopes and claims, please see Scope-dependent claims for more information. - routes - Allows customization of the generated routes. See Customizing Routes for details.
- maxClockSkew - Defaults to 120. This is the maximum difference allowed between your server's clock and Okta's in seconds. Setting this to 0 is not recommended, because it increases the likelihood that valid jwts will fail verification due to
nbf
andexp
issues.
Install dependencies
$ npm install
Run mongodb
$ mongod
Run the app
$ npm run build
Open Browser : http://localhost:3000/posts