Skip to content

imvenkat/okta-hooks

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Introduction

no hooks, still making them dance - Jonwayne

Hooks are a feature in Okta that allows Okta to call out to an API, to get direction (or commands) on what to do.

This repository contains code to deploy a serverless API using Zeit that uses query parameters to control the responses of the API. This allows for people to be able to demo Okta Hooks without needing to write code or deploy an API (such as https://github.com/omgitstom/cloudformation).

When specifying your hook URL location in Okta, you can specify query parameters allowing you to demo Okta hooks without modifying any code.

A quick example of this. If you wanted to show a pre-registration hook that updates the profile to include a frequent flyer number, you would specify this hook URL in Okta:

https://myfictionalapi.com/pre-reg?mode=profile-update&key=frequentFlyerNo&value=yH18kn3a

Installation

TBD

Pre-registration

Endpoint: https://{yourzeitdeployurl}.now.sh/pre-reg

Default Response:

{
    "commands": []
}

Controlling the response

Update profile

To update a profile, specify the mode to be profile-update in a query parameter:

https://{yourzeitdeployurl}.now.sh/pre-reg?mode=profile-update

This will return a command to update the profile:

{
    "commands": [
        {
            "type": "com.okta.user.profile.update",
            "value": {
                "customVariable": "customValue"
            }
        }
    ]
}

To control the propery and value that is set, you can also pass the key and value in the query parameters:

https://{yourzeitdeployurl}.now.sh/pre-reg?mode=profile-update&key=favoriteAnimal&value=Miley+Cyrus

This will return the specified value in the command:

{
    "commands": [
        {
            "type": "com.okta.user.profile.update",
            "value": {
                "favoriteAnimal": "Miley Cyrus"
            }
        }
    ]
}

Deny registration

To deny the registration, specify the mode to be profile-update in a query parameter:

https://{yourzeitdeployurl}.now.sh/pre-reg?mode=deny-registration

Response:

{
    "commands": [
        {
            "type": "com.okta.action.update",
            "value": {
                "registration": "DENY"
            }
        }
    ]
}

Error

To error to the end user, specify the mode to be error in a query parameter:

https://{yourzeitdeployurl}.now.sh/pre-reg?mode=error

Response:

{
  {
    "commands": [],
    "error": {
        "errorSummary": "Customized Error Summary",
        "errorCauses": [
            {
                "errorSummary": "Customized Error Summary",
                "reason": "INVALID_FORMAT",
                "locationType": "body",
                "location": "email",
                "domain": "user"
            }
        ]
    }
  }
}

Additional query parameters can be provided to override any property in the errorCauses array. For example:

https://{yourzeitdeployurl}.now.sh/pre-reg?mode=error&errorSummary=Something+went+wrong&reason=UNKNOWN_PROJECT_ID&locationType=body&location=projectId&domain=project

Will respond with:

{
    "commands": [],
    "error": {
        "errorSummary": "Something went wrong",
        "errorCauses": [
            {
                "errorSummary": "Something went wrong",
                "reason": "UNKNOWN_PROJECT_ID",
                "locationType": "body",
                "location": "projectId",
                "domain": "project"
            }
        ]
    }
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%