Skip to content

Commit

Permalink
enhance: Add support for PagerDuty app (#1790)
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
cloudnautique authored Feb 20, 2025
1 parent 877fb77 commit 36385e3
Show file tree
Hide file tree
Showing 8 changed files with 112 additions and 1 deletion.
1 change: 1 addition & 0 deletions apiclient/types/oauthapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const (
OAuthAppTypeSalesforce OAuthAppType = "salesforce"
OAuthAppTypeZoom OAuthAppType = "zoom"
OAuthAppTypeLinkedIn OAuthAppType = "linkedin"
OAuthAppTypePagerDuty OAuthAppType = "pagerduty"
OAuthAppTypeCustom OAuthAppType = "custom"
)

Expand Down
3 changes: 2 additions & 1 deletion pkg/gateway/server/oauth_apps.go
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,8 @@ func (s *Server) callbackOAuthApp(apiContext api.Context) error {
return fmt.Errorf("failed to create token request: %w", err)
}
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
if app.Spec.Manifest.Type != types2.OAuthAppTypeGoogle {
if app.Spec.Manifest.Type != types2.OAuthAppTypeGoogle &&
app.Spec.Manifest.Type != types2.OAuthAppTypePagerDuty {
req.SetBasicAuth(url.QueryEscape(app.Spec.Manifest.ClientID), url.QueryEscape(app.Spec.Manifest.ClientSecret))
}

Expand Down
6 changes: 6 additions & 0 deletions pkg/gateway/types/oauth_apps.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ const (

LinkedInAuthorizeURL = "https://www.linkedin.com/oauth/v2/authorization"
LinkedInTokenURL = "https://www.linkedin.com/oauth/v2/accessToken"

PagerDutyAuthorizeURL = "https://identity.pagerduty.com/oauth/authorize"
PagerDutyTokenURL = "https://identity.pagerduty.com/oauth/token"
)

var (
Expand Down Expand Up @@ -85,6 +88,9 @@ func ValidateAndSetDefaultsOAuthAppManifest(r *types.OAuthAppManifest, create bo
case types.OAuthAppTypeLinkedIn:
r.AuthURL = LinkedInAuthorizeURL
r.TokenURL = LinkedInTokenURL
case types.OAuthAppTypePagerDuty:
r.AuthURL = PagerDutyAuthorizeURL
r.TokenURL = PagerDutyTokenURL
case types.OAuthAppTypeSalesforce:
salesforceAuthorizeFragment := "/services/oauth2/authorize"
salesforceTokenFragment := "/services/oauth2/token"
Expand Down
2 changes: 2 additions & 0 deletions ui/admin/app/components/oauth-apps/OAuthAppTypeIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
FaSalesforce,
FaSlack,
} from "react-icons/fa";
import { SiPagerduty } from "react-icons/si";

import { OAuthProvider } from "~/lib/model/oauthApps/oauth-helpers";
import { cn } from "~/lib/utils";
Expand All @@ -26,6 +27,7 @@ const IconMap = {
[OAuthProvider.Notion]: NotionLogoIcon,
[OAuthProvider.Zoom]: BiLogoZoom,
[OAuthProvider.LinkedIn]: FaLinkedin,
[OAuthProvider.PagerDuty]: SiPagerduty,
[OAuthProvider.Custom]: KeyIcon,
};

Expand Down
2 changes: 2 additions & 0 deletions ui/admin/app/lib/model/oauthApps/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { HubSpotOAuthApp } from "~/lib/model/oauthApps/providers/hubspot";
import { LinkedInOAuthApp } from "~/lib/model/oauthApps/providers/linkedin";
import { Microsoft365OAuthApp } from "~/lib/model/oauthApps/providers/microsoft365";
import { NotionOAuthApp } from "~/lib/model/oauthApps/providers/notion";
import { PagerDutyOAuthApp } from "~/lib/model/oauthApps/providers/pagerduty";
import { SalesforceOAuthApp } from "~/lib/model/oauthApps/providers/salesforce";
import { SlackOAuthApp } from "~/lib/model/oauthApps/providers/slack";
import { ZoomOAuthApp } from "~/lib/model/oauthApps/providers/zoom";
Expand All @@ -25,6 +26,7 @@ export const OAuthAppSpecMap = {
[OAuthProvider.Notion]: NotionOAuthApp,
[OAuthProvider.Zoom]: ZoomOAuthApp,
[OAuthProvider.LinkedIn]: LinkedInOAuthApp,
[OAuthProvider.PagerDuty]: PagerDutyOAuthApp,
// Custom OAuth apps are intentionally omitted from the map.
// They are handled separately
} as const;
Expand Down
1 change: 1 addition & 0 deletions ui/admin/app/lib/model/oauthApps/oauth-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export const OAuthProvider = {
Notion: "notion",
Zoom: "zoom",
LinkedIn: "linkedin",
PagerDuty: "pagerduty",
Custom: "custom",
} as const;
export type OAuthProvider = (typeof OAuthProvider)[keyof typeof OAuthProvider];
Expand Down
80 changes: 80 additions & 0 deletions ui/admin/app/lib/model/oauthApps/providers/pagerduty.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
import { z } from "zod";

import {
OAuthAppSpec,
OAuthFormStep,
getOAuthLinks,
} from "~/lib/model/oauthApps/oauth-helpers";
import { assetUrl } from "~/lib/utils";

const schema = z.object({
clientID: z.string().min(1, "Client ID is required"),
clientSecret: z.string().min(1, "Client Secret is required"),
});

const steps: OAuthFormStep<typeof schema.shape>[] = [
{
type: "markdown",
text:
"### Step 1: Access PagerDuty Integrations\n" +
"- Log in to your PagerDuty account\n" +
"- Click on 'Integrations' in the top navigation\n" +
"- Select 'App Registration' from the dropdown menu\n" +
"- Click '+ New App'",
},
{
type: "markdown",
text:
"### Step 2: Create OAuth App\n" +
"- Fill in the app details:\n" +
" - Name: Choose a name for your integration (e.g., 'Obot')\n" +
" - Description: Brief description of how you'll use Obot\n" +
"- Under 'Authentication Type', select 'OAuth 2.0'\n" +
"- Click 'Next'",
},
{
type: "copy",
text: getOAuthLinks("pagerduty").redirectURL,
},
{
type: "markdown",
text:
"### Step 3: Configure OAuth Settings\n" +
"- In the OAuth Configuration section:\n" +
"- Copy and paste your Obot redirect URL (shown above) into the 'Redirect URLs' field\n" +
"- Select the following required scopes:\n" +
" - incidents.read\n" +
" - incidents.write\n" +
" - users.read\n" +
"- Click 'Register App'",
},
{
type: "markdown",
text:
"### Step 4: Get Your App Credentials\n" +
"- After saving, you'll see your app's 'OAuth 2.0 Client Information'\n" +
"- Copy the 'Client ID' and 'Client Secret'\n" +
"- Enter these values in the fields below\n" +
"- Download the 'Client Credentials' file and save it in a secure location",
},
{
type: "input",
input: "clientID",
label: "Client ID",
},
{
type: "input",
input: "clientSecret",
label: "Client Secret",
inputType: "password",
},
];

export const PagerDutyOAuthApp = {
schema,
alias: "pagerduty",
type: "pagerduty",
displayName: "PagerDuty",
logo: assetUrl("/assets/pagerduty_logo.svg"),
steps: steps,
} satisfies OAuthAppSpec;
18 changes: 18 additions & 0 deletions ui/admin/public/assets/pagerduty-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 36385e3

Please sign in to comment.