changed the infrastructure of cms-oauth
MODIFY
aws-ts-netlify-cms-and-oauth/cms-oauth/infrastructure/index.ts
aws-ts-netlify-cms-and-oauth/cms-oauth/infrastructure/index.ts
@@ -15,6 +15,9 @@ const cmsStackConfig = {
githubSecret : pulumiConfig.requireSecret("githubSecret"),
// The domain of the OAuth Server that we want
targetDomain : pulumiConfig.require("targetDomain"),
+ // (Optional) the github scope we want CMS to edit, the values are in this link https://developer.github.com/apps/building-oauth-apps/understanding-scopes-for-oauth-apps/
+ // You can also specify multiple scopes and separate by comma
+ githubScope: pulumiConfig.get("githubScope"),
// (Optional) Port number of the target group if not specified use port 80
targetGroupPort : pulumiConfig.getNumber("targetGroupPort")
}
@@ -141,6 +144,9 @@ const sessionSecretRandomString = new random.RandomPassword("random", {
length: 32,
}, { additionalSecretOutputs: ["result"] });
+
+let inputGithubScope: pulumi.Input<string> = cmsStackConfig.githubScope!;
+
// Create a Fargate service task that can scale out.
const appService = new awsx.ecs.FargateService("app-svc", {
cluster,
@@ -170,7 +176,11 @@ const appService = new awsx.ecs.FargateService("app-svc", {
{
name: "TARGET_PORT",
value: pulumi.interpolate `${inputTargetGroupPort}`
- }
+ },
+ {
+ name: "GITHUB_SCOPE",
+ value: inputGithubScope
+ },
]
},
},

MODIFY
aws-ts-netlify-cms-and-oauth/cms-oauth/main.go
aws-ts-netlify-cms-and-oauth/cms-oauth/main.go
@@ -4,6 +4,7 @@ import (
"fmt"
"net/http"
"os"
+ "strings"
"github.com/gorilla/pat"
"github.com/markbates/goth"
@@ -124,6 +125,9 @@ func init() {
fmt.Sprintf("%s/callback/gitlab", host),
)
}
+
+ githubScope := os.Getenv("GITHUB_SCOPE")
+ if githubScope == "" {
goth.UseProviders(
github.New(
os.Getenv("GITHUB_KEY"), os.Getenv("GITHUB_SECRET"),
@@ -137,6 +141,22 @@ func init() {
),
gitlabProvider,
)
+ } else {
+ scopeArray := strings.Split(githubScope, ",")
+ goth.UseProviders(
+ github.New(
+ os.Getenv("GITHUB_KEY"), os.Getenv("GITHUB_SECRET"),
+ // concatenate with the host name
+ fmt.Sprintf("%s/callback/github", host),
+ scopeArray...,
+ ),
+ bitbucket.New(
+ os.Getenv("BITBUCKET_KEY"), os.Getenv("BITBUCKET_SECRET"),
+ fmt.Sprintf("%s/callback//bitbucket", host),
+ ),
+ gitlabProvider,
+ )
+ }
}
func main() {
@@ -151,9 +171,15 @@ func main() {
//
http.Handle("/", router)
//
+ // if TARGET_PORT is unset or do not present then set it to be port 80
targetGroupPort := os.Getenv("TARGET_PORT")
+ if targetGroupPort == "" {
+ targetGroupPort = "80"
+ }
listenPort := ":" + targetGroupPort
fmt.Print("Started running on", listenPort, "\n")
// listen on port 80 where we created the target group
fmt.Println(http.ListenAndServe(listenPort, nil))
}
+
+}

MODIFY
aws-ts-netlify-cms-and-oauth/cms/public/config.yml
aws-ts-netlify-cms-and-oauth/cms/public/config.yml
backend:
name: github
# Replace this with the Github repo you want to make change
- repo: your-github-repo
+ repo: github-username/target-github-repo
# This site_domain and base_url are sudo domains
# Replace site_domain with targetDomain pulumi stack configuration inside cms/infrastructure folder
# Replace base_url with targetDomain pulumi stack configuration inside cms-oauth/infrastructure folder

changed the infrastructure of cms-oauth