Code Monkey home page Code Monkey logo

okta-dac's Introduction

DAC

Disclaimer

ℹ️ This project serves as a Sample Application, that you can tweak or completely repurpose. It is community-supported and is maintained by members of the Okta team for developers and other IT professionals. okta-dac is not an official Okta product and does not qualify for any Okta support. Okta makes no warranties regarding this project. Anyone who chooses to use this project must ensure that their implementation meets any applicable legal obligations including any Okta terms and conditions.

ℹ️ It is recommended that you collaborate with your preferred Okta Solution Provider (link) to implement and adapt this app code sample within your existing portal. This app features frontend and backend components and like any web app hosted and running on your side, you should perform a code review, as well as security and scalability tests.

Introduction

This Sample Application demonstrates best practices for architecting multitenancy over a single Okta Org.

For a deep-dive into the architecture, refer to the documentation here.

TL;DR

When building a multitenant application, one key challenge is to build out functionality to manage user identities in each tenant, while segregating the administration of the tenants themselves in a self-service manner. Fortunately, Okta has many great features that support this scenario. In okta-dac, you will find sample implementation of key identity management functionality (for multitenant applications), which include:

  • A "Super Admin" UI – accessible to users having a "Super Admin role" – that provides a overarching view of all tenants. Among its functions, the Super Admin UI allows you to:
    • List all and add new tenants
    • Select applications that a tenant gets access to
    • Define the username domain(s) for the tenant(s). Usernames are confined to specific domains, so that usernames in one tenant do not collide with those from another (in our implementation of this sample multitenant app, the same username cannot exist in multiple tenants). Domains are also used to automatically configure routing-rules for idp-discovery functionality in the byob-dashboard companion app.
  • A "Tenant Admin" UI – accessible to users having a "Tenant Admin role" – that provides the following functionality:
    • Manage users in the tenant (Add users, update users, manage user statuses, etc.)
    • Assign apps to individual users
    • Assign apps "en-masse"
    • Self configure inbound SAML to the tenant
    • Self verify domain names

demo

Setup

Setting up the required configurations in Okta; the API Gateway and lambda functions (in AWS, for the REST APIs) are quite involved. So we've leveraged Terraform and Serverless, and provided a Makefile:

Prerequisites

  • Terraform == v0.13.x
  • NPM >= 6.12.x
  • Serverless >= 1.75.x
  1. macOS Catalina issues: You must be able to run npm install.

    • The Makefiles runs npm install commands. You should make sure that your machine is able to run this command without any issues.
    • If you are getting the error "gyp: No Xcode or CLT version detected!" on macOS Catalina, follow these steps
  2. Install terraform v0.13.x

    • The terraform files uses v0.13 syntax. If you have an older version of terraform, you need to upgrade. If you can't upgrade, skip terraform and do these manual steps:
    1. Follow the manual steps to configure Okta.
    2. Populate AWS SSM parameters
  3. Install Serverless

    e.g. via npm:

    npm install -g serverless
    

    Note: if you get WARN/ERR on MacOS, run:

    sudo npm install -g serverless
    
  4. Install vuecli

    e.g. via npm:

    npm install @vue/cli -g
    

    Note: if you get WARN/ERR on MacOS, run:

    sudo npm install -g @vue/cli --unsafe-perm
    
  5. Create a Named Profile in AWS. Steps

  6. Enable Programmatic Access for Okta. Steps

Environment Variables

  • Copy the file /terraform/terraform.tfvars.template into /terraform/terraform.tfvars and edit it with your Org variables:

    org_name          = "<org subdomain>"
    base_url          = "<oktapreview.com || okta.com>"
    api_token         = "<OKTA_API_TOKEN>"
    app_url           = "http://localhost:8080"
    superuser_login   = ""
    environment       = "dev"
    aws_region        = "us-east-1"
    aws_profile       = "(see Prerequisites Step 5.)"
    aws_ssm_prefix    = "dac"
    

    Where the above variables are:

    Variable Description Default Value
    org_name Okta Org subdomain name (e.g. "atko")
    base_url Base URL for the Okta org (okta.com or oktapreview.com) "okta.com"
    api_token OKTA_API_TOKEN, per Prerequisites Step 6.
    app_url Base URL for the SPA. "http://localhost:8080"
    superuser_login Enter the Super Admin username you use to login to your Org
    environment Stage configured in API Gateway (dev, prod, ...) "dev"
    aws_region Region to deploy AWS components. "us-east-1"
    aws_profile Profile configured in AWS CLI. per Prerequisites Step 5.
    aws_ssm_prefix Prefix for parameters created in AWS Parameter Store. "dac"

Make

Once /terraform/terraform.tfvars is populated correctly, run Make:

make all

The above will:

  1. Run the provided Terraform scripts to configure your Okta Org
  2. Deploy the API using Serverless
  3. Create the local env file (.env.development.local) for the SPA

If you didn't see any errors during make, you're almost ready to go. But there are a couple manual steps to complete:

(Required) Manual Step 1

Terraform currently does not support granting Okta API Scopes. These scopes are required for okta-dac to properly function.

oauth scopes

  1. Login to your Org's Admin Console. Search for the okta-dac app
  2. Navigate to the Okta API Scopes tab and Grant the following scopes:
    • okta.groups.manage
    • okta.users.manage

(Required) Manual Step 2

Terraform currently does not support updating email templates so you have to do the following manually to get the welcome email to be redirect to the user activation path of the locally running app: localhost:8080/activate.

  • Update the User Activation email template: Replace ${activationLink} with http://localhost:8080/activate/${activationToken} user activation email

Run

cd into the dac-spa folder and run

npm run serve

Then, open your browser to http://localhost:8080 and login


Step-by-step Options

If you would rather do things step by step, do not run make all. Deploying this project has 3 parts:

  1. Run the provided Terraform scripts. Click here for next steps.
  2. Deploy the API. Click here for next steps.
  3. Bring up the spa on localhost. Click here for next steps.

okta-dac's People

Contributors

andymarch avatar dependabot[bot] avatar eatplaysleep avatar imgbotapp avatar nicotriballier avatar reverentgeek avatar sahuhaus avatar tommycwu avatar zeekhoo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

okta-dac's Issues

Update HCL scripts for Terraform v0.13.x

The HCL scripts located in /terraform authored against v0.12.x. The latest version v0.13 has explicitly new HCL provider code block that must be used.

  • Update the documentation to explicitly say what version terraform to use.
  • Update the main.tf or add verison.tf to /terraform.

Workaround:

$ terraform 0.13upgrade .  

⚠️ Don't forget the "." in the command above.

domain verification verify failing

I could not get domain verification to verify. I was able to get it working by updating line 20 of verify.js

from
if (dns.data === "${dnsVerificationString}") verified = true;

to
if (dns.data === dnsVerificationString) verified = true;

Not sure if this is a difference in dns responses or not.

Handle user existing in multiple tenants

Where a user exists in multiple tenants switching logic should be implemented to set tehe context of a user.
Current behaviour: user is logged in as a superset of their permissions.

make spa fails

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: [email protected]
npm ERR! Found: [email protected]
npm ERR! node_modules/eslint
npm ERR!   dev eslint@"^7.1.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer eslint@">= 1.6.0 < 7.0.0" from @vue/[email protected]
npm ERR! node_modules/@vue/cli-plugin-eslint
npm ERR!   dev @vue/cli-plugin-eslint@"^4.4.4" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! See /Users/warblack/.npm/eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/warblack/.npm/_logs/2021-03-09T18_21_01_686Z-debug.log
make: *** [setupSpa] Error 1

I fixed by:

diff --git a/Makefile b/Makefile
index 3ea0081..d223d18 100644
--- a/Makefile
+++ b/Makefile
@@ -108,7 +108,7 @@ createVueEnv: createEnvLocal
 .PHONY: setupSpa
 setupSpa: createVueEnv
        @cd ${SPA_DIR} && \
-       npm install
+       npm install --legacy-peer-deps

 .PHONY: spa
 spa: setupSpa

Update for macOS on Apple Silicon

Any chance this will be updated to support macOS on Apple Silicon (which has been out for a year)? Currently having to try running everything in Rosetta, will report if that works.

Email Template error when building the terraform template

When I build the dac project on my Okta tenant jay.okta.com, I am getting this error on the terraform -

Error: The API returned an error: You do not have permission to perform the requested action
 on main.tf line 195, in resource "okta_template_email" "email-welcome":
 195: resource "okta_template_email" "email-welcome" {

The reason being my tenant doesn't have permissions to edit the email template, and there are no APIs for this either.

`serverless deploy -v` in Makefile doesn't deploy

I'm new to some of this stuff, but I'm noticing that when I run make api, it runs serverless deploy -v. I think this was used to deploy verbosely, but apparently now it just reports versions:

➜  dac-api git:(master) ✗ serverless deploy -v                                               
Running "serverless" from node_modules
Framework Core: 3.21.0 (local) 3.21.0 (global)
Plugin: 6.2.2
SDK: 4.3.2

Removing the -v and re-running make api actually deployed.

Missing o4o token when inCognito

Missing o4o token when inCognito (Chrome)

Can't create users without the o4o token, tenants are spun up correctly.

Works fine when not in inCognito and o4o token is present in local storage.

Internal server error from Okta during `make all`

I got the following error when following README instructions down to make all:

Error: The API returned an error: Internal Server Error

  on main.tf line 181, in resource "okta_auth_server_policy_rule" "okta-dac-catch-all":
 181: resource "okta_auth_server_policy_rule" "okta-dac-catch-all" {

make: *** [okta] Error 1

I added -parallelism=1 to the terraform apply command in the planOkta and that seemed to help.

Is this still available in Okta?

Hello, is this application still available? I am not able to find it in the OIN. Also, with "virtual tenants" in a single org, are duplicate ID's supported and if so, how?

Thanks,

John

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.