Socket
Socket
Sign inDemoInstall

slack-okta-bot

Package Overview
Dependencies
2
Maintainers
1
Alerts
File Explorer

Install Socket

Detect and block malicious and high-risk dependencies

Install

    slack-okta-bot

Provides quick access to Okta user management from Slack


Maintainers
1

Readme

slack-okta-bot

Provides the backend service for an Okta application that gives users the ability to execute common tasks

The backend can run:

  • As a standalone server
  • AWS Lambda Function URL
  • AWS Lambda as an ELB target

Current features:

  • Reset MFA Factors
  • Reset password

Configuration

The following env vars are used for configuration

NameDescriptionRequiredDefault
HELP_CHANNELHelp channel displayed in responses to userno#devops-help
HOME_HEADERHeader displayed in app home pageno:gear: Get help with common DevOps Okta tasks :gear:
HOME_VIEWAdditional info to show in app home pageno
RESET_MFA_COMMANDCommand the user sends to reset MFAno/reset-mfa
RESET_PASSWORD_COMMANDCommand the user sends to reset passwordno/reset-password
TEST_USERAn email address that, if set, be used instead of the user's slack email.no
PORTPort to run the local server onno3000
SLACK_BOT_TOKENSlack Bot User Oauth Tokenyes
SLACK_SIGNING_SECRETSlack Signing Secretyes
OKTA_URLOkta api endpoint <yourdomain.okta.com/api/v1>yes
OKTA_TOKENOkta API tokenyes

Usage

With AWS Lambda: The easy way

For convenience, if you don't need any additional logic in your handler, you can just build your package using build_lambda.sh (Described below) and set your Lambda's handler to slack_okta_bot.aws_lambda.lambda_handler.

AWS Lambda: Manual way

from json import dumps
from logging import getLogger

from slack_okta_bot.slack import slack_app
from slack_okta_bot.aws_lambda import LambdaHandler


getLogger().setLevel("INFO")


def handler(event, context):
  getLogger().info(dumps(event, indent=2))
  handler = LambdaHandler(slack_app)
  try:
    res = handler.handle(event, context)
    getLogger().info(res)
    return res
  except Exception as e:
    getLogger().info(e)

In your Lambda config You would set your lambda handler to module.handler where module is the name of your Lambda package module

Building a basic Lambda package

From source:

  • Run build_with_poetry.sh. It requires that poetry be installed and will install it if missing.
  • Upload the created zip file to S3 and configure your Lambda to pull from S3
  • Optionally upload the package manually in the AWS Lambda console
  • Set your Lambda's handler to slack_okta_bot.aws_lambda.lambda_handler

Using PIP

  • Run pip install slack-okta-bot -t packages
  • cd into ./packages directory
  • Run zip -r ../lambda.zip . -x '*.pyc'
  • Upload ../lambda.zip to S3 and configure your Lambda to pull from S3
  • Optionally upload the package manually in the AWS Lambda console
  • Set your Lambda's handler to slack_okta_bot.aws_lambda.lambda_handler

Running as a server

The package will install a shell script that can run a server

> slack-okta-bot
INFO:slack_okta_bot:Logging to stdout
⚡️ Bolt app is running! (development server)
127.0.0.1 - - [23/Dec/2022 12:11:02] "POST /slack/events HTTP/1.1" 200 -

If you need to import and run from your own script:

from slack_okta_bot import run_local

# do cool stuff

run_local()

Slack App

To install in Slack:

  • Update slack-okta-bot.yaml with the domain you will be using
  • Update any other options you would like to change
  • Go to applications in your Slack org's admin area (https://api.slack.com/apps)
  • Click the "Create New App" button
  • Click "From an app manifest"
  • Select workspace to install to
  • Make sure that "YAML" tab is selected
  • Under "Basic Information" save your Signing Secret so you can export it to the required env var
  • Get the Bot User Oauth Token from the "Oauth & Permissions" tab so you can export it to the required env var
  • Deploy your application backend
  • In the Slack app configuration page go to "Event Subscriptions"
  • If the Request URL is not marked as "Verified" click the verify button/link

Your app's homepage should now show and commands will become active. Test by entering a slash command in any channel in slack. Your interaction with the bot will be private and won't be displayed to other users in the chat. If the application is installed into the Apps side pane in Slack then you can also access the app's home page to see the description and available commands.

FAQs


Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc