From bdbdef21ca1fbee5cc6edfda12e9aacf9d52dd8f Mon Sep 17 00:00:00 2001 From: Vijet M Date: Mon, 13 Sep 2021 22:12:48 -0700 Subject: [PATCH] Changes for Heroku integration --- README.md | 20 ++++++++++++++++++++ app.json | 33 +++++++++++++++++++++++++++++++++ custom-login/package.json | 2 +- custom-login/server.js | 17 +++++++++++++++++ package.json | 6 +++++- 5 files changed, 76 insertions(+), 2 deletions(-) create mode 100644 app.json create mode 100644 custom-login/server.js diff --git a/README.md b/README.md index d8cbce6..3e24d73 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,25 @@ Please find the sample that fits your use-case from the table below. [Okta Angular Library]: https://github.com/okta/okta-oidc-js/tree/master/packages/okta-angular +## Quick Start: Automatic Setup with Heroku + +You need a [Heroku](https://signup.heroku.com/) account to follow these instructions. + +You can create a free Okta Developer org and deploy this app directly to Heroku by clicking the purple button: + +[![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy) + +To deploy the app, you will need an Okta org setup as described in the section above. + +You will also need to replace the config values for `ISSUER` and `CLIENT_ID` in Heroku configuration based on your Okta org. +Also be sure to add your Heroku app's base URL to the list of trusted origins in your Okta admin settings. + +After you deploy the app, click on **View** on the result screen to navigate to the newly deployed app. + +Click **Login** button on the app. Browser displays the sign-in page to authenticate. + +You can use your Okta user credentials to login to the application. That's it! You've successfully logged in using Okta. + ## Running the resource server The samples include a page which accesses a protected resource (messages). To start the sample resource server: @@ -55,3 +74,4 @@ PASSWORD=testpass ``` With these variables set, you should be able to run `npm test` and bask in the glory of passing tests. + diff --git a/app.json b/app.json new file mode 100644 index 0000000..c80c0f4 --- /dev/null +++ b/app.json @@ -0,0 +1,33 @@ +{ + "name": "Custom Login Sample", + "description": "Sample that demonstrates use of Custom Login/Embedded Sign-in Widget", + "repository": "https://github.com/okta/samples-js-vue/custom-login", + "keywords": ["oidc", "identity", "security", "authentication"], + "success_url": "/", + "env": { + "ISSUER": { + "description": "Issuer URL for your org", + "value": "https://qa-st-cda1.oktapreview.com/oauth2/default" + }, + "CLIENT_ID": { + "description": "Client ID for your application", + "value": "0oa1mb3urzAsFdkNc0x7" + }, + "NPM_CONFIG_PRODUCTION": { + "description": "npm config production", + "value": "false" + }, + "OKTA_TESTING_DISABLEHTTPSCHECK": { + "description": "Okta test disable https check", + "value": "false" + }, + "USE_INTERACTION_CODE": { + "description": "Use interaction code flow", + "value": "true" + }, + "YARN_PRODUCTION": { + "description": "Yarn production", + "value": "false" + } + } +} \ No newline at end of file diff --git a/custom-login/package.json b/custom-login/package.json index 353f443..f8102f3 100644 --- a/custom-login/package.json +++ b/custom-login/package.json @@ -4,7 +4,7 @@ "license": "MIT", "scripts": { "ng": "ng", - "start": "ng serve", + "start": "node server.js", "build": "ng build --prod", "test": "npm run lint && npm run test:custom-login --prefix ../", "lint": "ng lint" diff --git a/custom-login/server.js b/custom-login/server.js new file mode 100644 index 0000000..52737d5 --- /dev/null +++ b/custom-login/server.js @@ -0,0 +1,17 @@ +const express = require('express'); +const serveStatic = require("serve-static"); +const path = require('path'); + +const app = express(); + +//here we are configuring dist to serve app files +app.use("/", serveStatic(path.join(__dirname, "/dist"))); + +// this * route is to serve project on different page routes except root `/` +app.get(/.*/, function(req, res) { + res.sendFile(path.join(__dirname, "/dist/index.html")); +}); + +const port = process.env.PORT || 8080; +app.listen(port); +console.log(`app is listening on port: ${port}`); \ No newline at end of file diff --git a/package.json b/package.json index 56f44d3..54a045c 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,11 @@ "setup-env": "node scripts/setup-env.js", "install-custom-login": "cd custom-login && npm install", "install-okta-hosted-login": "cd okta-hosted-login && npm install", - "webdriver-update-legacy": "webdriver-manager update --versions.standalone=3.141.59 --versions.chrome 2.45 --gecko false" + "webdriver-update-legacy": "webdriver-manager update --versions.standalone=3.141.59 --versions.chrome 2.45 --gecko false", + + "start": "npm run --prefix custom-login start", + "serve": "npm run --prefix custom-login serve", + "build": "npm run --prefix custom-login build" }, "author": "", "license": "Apache-2.0",