Skip to content

Commit 36385e3

Browse files
enhance: Add support for PagerDuty app (#1790)
Added PagerDuty OAuthAppType to exclude sending Basic Auth creds. Added PagerDuty OAuthApp default settings. Added PagerDuty OAuthApp setup. Signed-off-by: Bill Maxwell <[email protected]>
1 parent 877fb77 commit 36385e3

File tree

8 files changed

+112
-1
lines changed

8 files changed

+112
-1
lines changed

apiclient/types/oauthapp.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const (
1111
OAuthAppTypeSalesforce OAuthAppType = "salesforce"
1212
OAuthAppTypeZoom OAuthAppType = "zoom"
1313
OAuthAppTypeLinkedIn OAuthAppType = "linkedin"
14+
OAuthAppTypePagerDuty OAuthAppType = "pagerduty"
1415
OAuthAppTypeCustom OAuthAppType = "custom"
1516
)
1617

pkg/gateway/server/oauth_apps.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,8 @@ func (s *Server) callbackOAuthApp(apiContext api.Context) error {
403403
return fmt.Errorf("failed to create token request: %w", err)
404404
}
405405
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
406-
if app.Spec.Manifest.Type != types2.OAuthAppTypeGoogle {
406+
if app.Spec.Manifest.Type != types2.OAuthAppTypeGoogle &&
407+
app.Spec.Manifest.Type != types2.OAuthAppTypePagerDuty {
407408
req.SetBasicAuth(url.QueryEscape(app.Spec.Manifest.ClientID), url.QueryEscape(app.Spec.Manifest.ClientSecret))
408409
}
409410

pkg/gateway/types/oauth_apps.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ const (
3434

3535
LinkedInAuthorizeURL = "https://www.linkedin.com/oauth/v2/authorization"
3636
LinkedInTokenURL = "https://www.linkedin.com/oauth/v2/accessToken"
37+
38+
PagerDutyAuthorizeURL = "https://identity.pagerduty.com/oauth/authorize"
39+
PagerDutyTokenURL = "https://identity.pagerduty.com/oauth/token"
3740
)
3841

3942
var (
@@ -85,6 +88,9 @@ func ValidateAndSetDefaultsOAuthAppManifest(r *types.OAuthAppManifest, create bo
8588
case types.OAuthAppTypeLinkedIn:
8689
r.AuthURL = LinkedInAuthorizeURL
8790
r.TokenURL = LinkedInTokenURL
91+
case types.OAuthAppTypePagerDuty:
92+
r.AuthURL = PagerDutyAuthorizeURL
93+
r.TokenURL = PagerDutyTokenURL
8894
case types.OAuthAppTypeSalesforce:
8995
salesforceAuthorizeFragment := "/services/oauth2/authorize"
9096
salesforceTokenFragment := "/services/oauth2/token"

ui/admin/app/components/oauth-apps/OAuthAppTypeIcon.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
FaSalesforce,
1212
FaSlack,
1313
} from "react-icons/fa";
14+
import { SiPagerduty } from "react-icons/si";
1415

1516
import { OAuthProvider } from "~/lib/model/oauthApps/oauth-helpers";
1617
import { cn } from "~/lib/utils";
@@ -26,6 +27,7 @@ const IconMap = {
2627
[OAuthProvider.Notion]: NotionLogoIcon,
2728
[OAuthProvider.Zoom]: BiLogoZoom,
2829
[OAuthProvider.LinkedIn]: FaLinkedin,
30+
[OAuthProvider.PagerDuty]: SiPagerduty,
2931
[OAuthProvider.Custom]: KeyIcon,
3032
};
3133

ui/admin/app/lib/model/oauthApps/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { HubSpotOAuthApp } from "~/lib/model/oauthApps/providers/hubspot";
99
import { LinkedInOAuthApp } from "~/lib/model/oauthApps/providers/linkedin";
1010
import { Microsoft365OAuthApp } from "~/lib/model/oauthApps/providers/microsoft365";
1111
import { NotionOAuthApp } from "~/lib/model/oauthApps/providers/notion";
12+
import { PagerDutyOAuthApp } from "~/lib/model/oauthApps/providers/pagerduty";
1213
import { SalesforceOAuthApp } from "~/lib/model/oauthApps/providers/salesforce";
1314
import { SlackOAuthApp } from "~/lib/model/oauthApps/providers/slack";
1415
import { ZoomOAuthApp } from "~/lib/model/oauthApps/providers/zoom";
@@ -25,6 +26,7 @@ export const OAuthAppSpecMap = {
2526
[OAuthProvider.Notion]: NotionOAuthApp,
2627
[OAuthProvider.Zoom]: ZoomOAuthApp,
2728
[OAuthProvider.LinkedIn]: LinkedInOAuthApp,
29+
[OAuthProvider.PagerDuty]: PagerDutyOAuthApp,
2830
// Custom OAuth apps are intentionally omitted from the map.
2931
// They are handled separately
3032
} as const;

ui/admin/app/lib/model/oauthApps/oauth-helpers.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export const OAuthProvider = {
1313
Notion: "notion",
1414
Zoom: "zoom",
1515
LinkedIn: "linkedin",
16+
PagerDuty: "pagerduty",
1617
Custom: "custom",
1718
} as const;
1819
export type OAuthProvider = (typeof OAuthProvider)[keyof typeof OAuthProvider];
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
import { z } from "zod";
2+
3+
import {
4+
OAuthAppSpec,
5+
OAuthFormStep,
6+
getOAuthLinks,
7+
} from "~/lib/model/oauthApps/oauth-helpers";
8+
import { assetUrl } from "~/lib/utils";
9+
10+
const schema = z.object({
11+
clientID: z.string().min(1, "Client ID is required"),
12+
clientSecret: z.string().min(1, "Client Secret is required"),
13+
});
14+
15+
const steps: OAuthFormStep<typeof schema.shape>[] = [
16+
{
17+
type: "markdown",
18+
text:
19+
"### Step 1: Access PagerDuty Integrations\n" +
20+
"- Log in to your PagerDuty account\n" +
21+
"- Click on 'Integrations' in the top navigation\n" +
22+
"- Select 'App Registration' from the dropdown menu\n" +
23+
"- Click '+ New App'",
24+
},
25+
{
26+
type: "markdown",
27+
text:
28+
"### Step 2: Create OAuth App\n" +
29+
"- Fill in the app details:\n" +
30+
" - Name: Choose a name for your integration (e.g., 'Obot')\n" +
31+
" - Description: Brief description of how you'll use Obot\n" +
32+
"- Under 'Authentication Type', select 'OAuth 2.0'\n" +
33+
"- Click 'Next'",
34+
},
35+
{
36+
type: "copy",
37+
text: getOAuthLinks("pagerduty").redirectURL,
38+
},
39+
{
40+
type: "markdown",
41+
text:
42+
"### Step 3: Configure OAuth Settings\n" +
43+
"- In the OAuth Configuration section:\n" +
44+
"- Copy and paste your Obot redirect URL (shown above) into the 'Redirect URLs' field\n" +
45+
"- Select the following required scopes:\n" +
46+
" - incidents.read\n" +
47+
" - incidents.write\n" +
48+
" - users.read\n" +
49+
"- Click 'Register App'",
50+
},
51+
{
52+
type: "markdown",
53+
text:
54+
"### Step 4: Get Your App Credentials\n" +
55+
"- After saving, you'll see your app's 'OAuth 2.0 Client Information'\n" +
56+
"- Copy the 'Client ID' and 'Client Secret'\n" +
57+
"- Enter these values in the fields below\n" +
58+
"- Download the 'Client Credentials' file and save it in a secure location",
59+
},
60+
{
61+
type: "input",
62+
input: "clientID",
63+
label: "Client ID",
64+
},
65+
{
66+
type: "input",
67+
input: "clientSecret",
68+
label: "Client Secret",
69+
inputType: "password",
70+
},
71+
];
72+
73+
export const PagerDutyOAuthApp = {
74+
schema,
75+
alias: "pagerduty",
76+
type: "pagerduty",
77+
displayName: "PagerDuty",
78+
logo: assetUrl("/assets/pagerduty_logo.svg"),
79+
steps: steps,
80+
} satisfies OAuthAppSpec;
Lines changed: 18 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)