slack-okta-bot


Nameslack-okta-bot JSON
Version 0.0.4 PyPI version JSON
download
home_pagehttps://github.com/mathewmoon/slack-okta-bot
SummaryProvides quick access to Okta user management from Slack
upload_time2023-01-03 18:07:45
maintainer
docs_urlNone
authorMathew Moon
requires_python>=3.9,<4.0
license
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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

| Name                   | Description                                                               | Required | Default                                              |   |
|------------------------|---------------------------------------------------------------------------|----------|------------------------------------------------------|---|
| HELP_CHANNEL           | Help channel displayed in responses to user                               | no       | #devops-help                                         |   |
| HOME_HEADER            | Header displayed in app home page                                         | no       | :gear: Get help with common DevOps Okta tasks :gear: |   |
| RESET_MFA_COMMAND      | Command the user sends to reset MFA                                       | no       | /reset-mfa                                           |   |
| RESET_PASSWORD_COMMAND | Command the user sends to reset password                                  | no       | /reset-password                                      |   |
| TEST_USER              | An email address that, if set, be used instead of the user's slack email. | no       |                                                      |   |
| PORT                   | Port to run the local server on                                           | no       | 3000                                                 |   |
| SLACK_BOT_TOKEN        | Slack Bot User Oauth Token                                                | yes      |                                                      |   |
| SLACK_SIGNING_SECRET   | Slack Signing Secret                                                      | yes      |                                                      |   |
| OKTA_URL               | Okta api endpoint <yourdomain.okta.com/api/v1>                            | yes      |                                                      |   |
| OKTA_TOKEN             | Okta API token                                                            | yes      |                                                      |   |



## 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
```python
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
* Run `build_lambda.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`


### 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:

```python
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.


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/mathewmoon/slack-okta-bot",
    "name": "slack-okta-bot",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.9,<4.0",
    "maintainer_email": "",
    "keywords": "",
    "author": "Mathew Moon",
    "author_email": "me@mathewmoon.net",
    "download_url": "https://files.pythonhosted.org/packages/54/54/2d87859b0b806fd08e0b30baddcb5cfce8465780640938e017e51b8b804e/slack_okta_bot-0.0.4.tar.gz",
    "platform": null,
    "description": "# slack-okta-bot\n\n### Provides the backend service for an Okta application that gives users the ability to execute common tasks\nThe backend can run:\n* As a standalone server\n* AWS Lambda Function URL\n* AWS Lambda as an ELB target\n\nCurrent features:\n* Reset MFA Factors\n* Reset password\n\n## Configuration\nThe following env vars are used for configuration\n\n| Name                   | Description                                                               | Required | Default                                              |   |\n|------------------------|---------------------------------------------------------------------------|----------|------------------------------------------------------|---|\n| HELP_CHANNEL           | Help channel displayed in responses to user                               | no       | #devops-help                                         |   |\n| HOME_HEADER            | Header displayed in app home page                                         | no       | :gear: Get help with common DevOps Okta tasks :gear: |   |\n| RESET_MFA_COMMAND      | Command the user sends to reset MFA                                       | no       | /reset-mfa                                           |   |\n| RESET_PASSWORD_COMMAND | Command the user sends to reset password                                  | no       | /reset-password                                      |   |\n| TEST_USER              | An email address that, if set, be used instead of the user's slack email. | no       |                                                      |   |\n| PORT                   | Port to run the local server on                                           | no       | 3000                                                 |   |\n| SLACK_BOT_TOKEN        | Slack Bot User Oauth Token                                                | yes      |                                                      |   |\n| SLACK_SIGNING_SECRET   | Slack Signing Secret                                                      | yes      |                                                      |   |\n| OKTA_URL               | Okta api endpoint <yourdomain.okta.com/api/v1>                            | yes      |                                                      |   |\n| OKTA_TOKEN             | Okta API token                                                            | yes      |                                                      |   |\n\n\n\n## Usage\n\n### With AWS Lambda: The easy way\nFor convenience, if you don't need any additional logic in your handler, you can just\nbuild your package using `build_lambda.sh` (Described below) and set your Lambda's handler to `slack_okta_bot.aws_lambda.lambda_handler`.\n\n\n\n### AWS Lambda: Manual way\n```python\nfrom json import dumps\nfrom logging import getLogger\n\nfrom slack_okta_bot.slack import slack_app\nfrom slack_okta_bot.aws_lambda import LambdaHandler\n\n\ngetLogger().setLevel(\"INFO\")\n\n\ndef handler(event, context):\n  getLogger().info(dumps(event, indent=2))\n  handler = LambdaHandler(slack_app)\n  try:\n    res = handler.handle(event, context)\n    getLogger().info(res)\n    return res\n  except Exception as e:\n    getLogger().info(e)\n```\n\nIn your Lambda config You would set your lambda handler to `module.handler` where `module` is the name of your Lambda package module\n\n\n## Building a basic Lambda package\n* Run `build_lambda.sh`. It requires that `poetry` be installed and will install it if missing.\n* Upload the created zip file to S3 and configure your Lambda to pull from S3\n* Optionally upload the package manually in the AWS Lambda console\n* Set your Lambda's handler to `slack_okta_bot.aws_lambda.lambda_handler`\n\n\n### Running as a server\nThe package will install a shell script that can run a server\n\n```\n> slack-okta-bot\nINFO:slack_okta_bot:Logging to stdout\n\u26a1\ufe0f Bolt app is running! (development server)\n127.0.0.1 - - [23/Dec/2022 12:11:02] \"POST /slack/events HTTP/1.1\" 200 -\n```\n\nIf you need to import and run from your own script:\n\n```python\nfrom slack_okta_bot import run_local\n\n# do cool stuff\n\nrun_local()\n\n```\n\n## Slack App\nTo install in Slack:\n\n* Update slack-okta-bot.yaml with the domain you will be using\n* Update any other options you would like to change\n* Go to applications in your Slack org's admin area (https://api.slack.com/apps)\n* Click the \"Create New App\" button\n* Click \"From an app manifest\"\n* Select workspace to install to\n* Make sure that \"YAML\" tab is selected\n* Under \"Basic Information\" save your Signing Secret so you can export it to the required env var\n* Get the Bot User Oauth Token from the \"Oauth & Permissions\" tab so you can export it to the required env var\n* Deploy your application backend\n* In the Slack app configuration page go to \"Event Subscriptions\"\n* If the Request URL is not marked as \"Verified\" click the verify button/link\n\nYour 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.\n\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Provides quick access to Okta user management from Slack",
    "version": "0.0.4",
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "54542d87859b0b806fd08e0b30baddcb5cfce8465780640938e017e51b8b804e",
                "md5": "4b6839994647c6045c26e37621c22a3c",
                "sha256": "74060df9489bf7b25a6f8d6f586087f1149e8d3fa822991a160975b8cc428db4"
            },
            "downloads": -1,
            "filename": "slack_okta_bot-0.0.4.tar.gz",
            "has_sig": false,
            "md5_digest": "4b6839994647c6045c26e37621c22a3c",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9,<4.0",
            "size": 8446,
            "upload_time": "2023-01-03T18:07:45",
            "upload_time_iso_8601": "2023-01-03T18:07:45.966656Z",
            "url": "https://files.pythonhosted.org/packages/54/54/2d87859b0b806fd08e0b30baddcb5cfce8465780640938e017e51b8b804e/slack_okta_bot-0.0.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-01-03 18:07:45",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "mathewmoon",
    "github_project": "slack-okta-bot",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "slack-okta-bot"
}
        
Elapsed time: 0.05481s