generated from slack-samples/bolt-python-custom-step-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
027d36b
commit 46710f6
Showing
12 changed files
with
136 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
from slack_bolt import Ack, BoltContext | ||
|
||
from jira.oauth.installation_store.file import JiraFileInstallationStore | ||
from utils.constants import CONTEXT | ||
|
||
|
||
def disconnect_account_callback(ack: Ack, context: BoltContext): | ||
ack() | ||
JiraFileInstallationStore().delete_installation( | ||
CONTEXT.jira_installation_store.delete_installation( | ||
enterprise_id=context.enterprise_id, team_id=context.team_id, user_id=context.user_id | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import logging | ||
import uuid | ||
from logging import Logger | ||
from typing import Dict, Optional | ||
|
||
from jira.oauth.state_store.models import JiraUserIdentity | ||
from jira.oauth.state_store.state_store import JiraOAuthStateStore | ||
|
||
|
||
class MockJiraOAuthStateStore(JiraOAuthStateStore): | ||
def __init__( | ||
self, | ||
*, | ||
logger: Logger = logging.getLogger(__name__), | ||
): | ||
self.state_table: Dict[str, JiraUserIdentity] = {} | ||
self.logger = logger | ||
|
||
def issue(self, user_identity: JiraUserIdentity) -> str: | ||
state = uuid.uuid4().hex | ||
self.state_table[state] = user_identity | ||
return state | ||
|
||
def consume(self, state: str) -> Optional[JiraUserIdentity]: | ||
if state not in self.state_table: | ||
message = f"Failed to find any persistent data for state: {state} - Key Error" | ||
self.logger.warning(message) | ||
return self.state_table.pop(state, None) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
import secrets | ||
from utils.context import Context | ||
|
||
OAUTH_REDIRECT_PATH = "/oauth/redirect" | ||
JIRA_CODE_VERIFIER = secrets.token_urlsafe(96)[:128] | ||
CONTEXT = Context() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import os | ||
import secrets | ||
from typing import Optional | ||
from urllib.parse import urljoin | ||
|
||
from jira.oauth.installation_store.file import JiraFileInstallationStore | ||
from jira.oauth.installation_store.installation_store import JiraInstallationStore | ||
from jira.oauth.state_store.file import JiraFileOAuthStateStore | ||
from jira.oauth.state_store.state_store import JiraOAuthStateStore | ||
|
||
|
||
class Context: | ||
def __init__( | ||
self, | ||
jira_base_url: Optional[str] = None, | ||
jira_client_id: Optional[str] = None, | ||
jira_client_secret: Optional[str] = None, | ||
jira_code_verifier: Optional[str] = None, | ||
app_base_url: Optional[str] = None, | ||
jira_oauth_redirect_path: str = "/oauth/redirect", | ||
app_home_page_url: Optional[str] = None, | ||
jira_state_store: JiraOAuthStateStore = JiraFileOAuthStateStore(), | ||
jira_installation_store: JiraInstallationStore = JiraFileInstallationStore(), | ||
): | ||
self.jira_base_url = jira_base_url or os.getenv("JIRA_BASE_URL") | ||
self.jira_client_id = jira_client_id or os.getenv("JIRA_CLIENT_ID") | ||
self.jira_client_secret = jira_client_secret or os.getenv("JIRA_CLIENT_SECRET") | ||
self.app_base_url = app_base_url or os.getenv("APP_BASE_URL") | ||
self.app_home_page_url = app_home_page_url or os.getenv("APP_HOME_PAGE_URL") | ||
|
||
self.jira_code_verifier = jira_code_verifier or secrets.token_urlsafe(96)[:128] | ||
self.jira_oauth_redirect_path = jira_oauth_redirect_path | ||
self.jira_redirect_uri = urljoin(self.app_base_url, self.jira_oauth_redirect_path) | ||
|
||
self.jira_state_store = jira_state_store | ||
self.jira_installation_store = jira_installation_store |
This file was deleted.
Oops, something went wrong.