diff --git a/netlify.toml b/netlify.toml
index c18f6d1a..1327a34c 100644
--- a/netlify.toml
+++ b/netlify.toml
@@ -1,7 +1,7 @@
[build]
base = "website/"
publish = "build/"
- command = "yarn build"
+ command = "yarn build:withoutAuth"
[context.production]
# Do not build the site if there's no site-related changes since the last
diff --git a/website/docusaurus.config.js b/website/docusaurus.config.js
index a136a8e7..174aa755 100644
--- a/website/docusaurus.config.js
+++ b/website/docusaurus.config.js
@@ -6,7 +6,7 @@ module.exports = {
tagline: "Dagger is a programmable deployment system",
url: "https://docs.dagger.io",
baseUrl: "/",
- onBrokenLinks: "throw",
+ onBrokenLinks: "warn",
onBrokenMarkdownLinks: "warn",
favicon: "img/favicon.png",
organizationName: "Dagger",
@@ -65,6 +65,7 @@ module.exports = {
[
"docusaurus2-dotenv", {
systemvars: true,
+ expand: true,
},
]
],
diff --git a/website/package.json b/website/package.json
index 9a2c8888..e8ef3030 100644
--- a/website/package.json
+++ b/website/package.json
@@ -4,8 +4,10 @@
"private": true,
"scripts": {
"docusaurus": "docusaurus",
- "start": "docusaurus start",
- "build": "docusaurus build",
+ "start": "OAUTH_ENABLE=false docusaurus start",
+ "start:withAuth": "OAUTH_ENABLE=true docusaurus start",
+ "build": "OAUTH_ENABLE=true docusaurus build",
+ "build:withoutAuth": "OAUTH_ENABLE=false docusaurus build",
"swizzle": "docusaurus swizzle",
"deploy": "docusaurus deploy",
"clear": "docusaurus clear",
diff --git a/website/src/api/github.js b/website/src/api/github.js
index 628f38be..439c975d 100644
--- a/website/src/api/github.js
+++ b/website/src/api/github.js
@@ -21,7 +21,7 @@ function bindApiCall({ url, config, errorMessage }) {
async function getAccessToken(code) {
const accessToken = await bindApiCall({
- url: '/github-proxy/login/oauth/access_token',
+ url: `${process.env.REACT_APP_API_PROXY_ENABLE == 'true' ? '/github-proxy' : 'https://github.com'}/login/oauth/access_token`,
config: {
params: {
code,
@@ -37,7 +37,7 @@ async function getAccessToken(code) {
export async function getUser(access_token) {
const user = await bindApiCall({
- url: '/github-api-proxy/user',
+ url: `${process.env.REACT_APP_API_PROXY_ENABLE == 'true' ? '/github-api-proxy' : 'https://api.github.com'}/user`,
config: {
headers: { Authorization: `token ${access_token}` },
},
@@ -49,7 +49,6 @@ export async function getUser(access_token) {
error: user.data?.error_description,
status: user.status
}
-
}
export async function checkUserCollaboratorStatus(code) {
@@ -57,12 +56,11 @@ export async function checkUserCollaboratorStatus(code) {
const { login } = await getUser(access_token)
const isUserCollaborator = await bindApiCall({
- url: `/docs-access/${login}`,
+ url: `${process.env.REACT_APP_API_PROXY_ENABLE == 'true' ? '/docs-access' : 'https://j20f3pfq11.execute-api.us-east-1.amazonaws.com/Prod/u'}/${login}`,
errorMessage: 'error checkUserCollaboratorStatus'
})
return {
- isAllowed: isUserCollaborator.data,
- access_token
+ userPermission: isUserCollaborator.data
}
}
\ No newline at end of file
diff --git a/website/src/components/DocPageAuthentication.js b/website/src/components/DocPageAuthentication.js
index f760784d..94083b8b 100644
--- a/website/src/components/DocPageAuthentication.js
+++ b/website/src/components/DocPageAuthentication.js
@@ -7,7 +7,7 @@ export default function DocAuthentication() {
Welcome on Dagger documentation
Please Sign In to Github to get access to the doc
-
window.location.href = `//github.com/login/oauth/authorize?client_id=${process.env.REACT_APP_CLIENT_ID}&scope=${process.env.REACT_APP_OAUTH_SCOPE}&allow_signup=false`} />
+ window.location.href = process.env.REACT_APP_GITHUB_AUTHORIZE_URI} />
)
}
\ No newline at end of file
diff --git a/website/src/components/DocPageRedirect.js b/website/src/components/DocPageRedirect.js
index e172ed20..e36e6dd8 100644
--- a/website/src/components/DocPageRedirect.js
+++ b/website/src/components/DocPageRedirect.js
@@ -6,7 +6,7 @@ export default function DocPageRedirect() {
const [counter, setCounter] = useState(10)
useEffect(() => {
- setTimeout(() => window.location.href = "https://dagger.io", 10000)
+ setTimeout(() => window.location.href = process.env.REACT_APP_DAGGER_SITE_URI, 10000)
setInterval(() => setCounter((prevState) => prevState - 1), 1000)
}, [])
@@ -18,7 +18,7 @@ export default function DocPageRedirect() {
It seems you don't have the permission to see Dagger's documentation. But don't worry you can request an Eary Access :). You'll be redirect to Dagger website in {counter} seconds
See you soon !
- If nothing happen, click here to go to Dagger website
+ If nothing happen, click here to go to Dagger website

diff --git a/website/src/css/custom.scss b/website/src/css/custom.scss
index d61fad3d..9590a23a 100644
--- a/website/src/css/custom.scss
+++ b/website/src/css/custom.scss
@@ -62,6 +62,7 @@ html[data-theme="dark"] {
--ifm-tabs-color-active: var(--ifm-color-primary-light);
--ifm-table-stripe-background: #2e526a;
--ifm-code-background: var(--ifm-color-primary-dark);
+ --ifm-heading-color: var(--ifm-color-primary-light);
}
/* global */
diff --git a/website/src/theme/DocPage/index.js b/website/src/theme/DocPage/index.js
index 14c7e03c..9be128a0 100644
--- a/website/src/theme/DocPage/index.js
+++ b/website/src/theme/DocPage/index.js
@@ -21,7 +21,7 @@ import { ThemeClassNames, docVersionSearchTag } from '@docusaurus/theme-common';
import { Redirect } from "react-router";
import qs from 'querystringify';
import isEmpty from 'lodash/isEmpty';
-import { checkUserCollaboratorStatus, getUser } from '../../api/github'
+import { checkUserCollaboratorStatus } from '../../api/github'
import { GithubLoginButton } from 'react-social-login-buttons';
import Spinner from '../../components/Spinner';
import DocPageAuthentication from '../../components/DocPageAuthentication';
@@ -139,43 +139,33 @@ function DocPage(props) {
);
// CUSTOM DOCPAGE
- // Do not use Github authentication when in local env or Netlify deploy preview
- if (typeof window === "undefined" ||
- (typeof window !== "undefined" && window?.location?.hostname !== "localhost" && !window.location.hostname.includes('deploy'))) {
- const [isUserAuthorized, setIsUserAuthorized] = useState()
+ if (process.env.OAUTH_ENABLE == 'true') {
const [isLoading, setIsLoading] = useState(true)
const [redirectState, setRedirectState] = useState()
const authQuery = qs.parse(location.search);
- const [userAccessToken, setUserAccessToken] = useState((() => {
- if (typeof window !== "undefined") return window.localStorage.getItem('user-github-key')
+ const [userAccessStatus, setUserAccessStatus] = useState((() => {
+ if (typeof window !== "undefined") return window.localStorage.getItem('user-github-isAllowed')
})())
useEffect(async () => {
- if (userAccessToken) {
- const user = await getUser(userAccessToken)
- setIsUserAuthorized(user)
- } else {
- if (!isEmpty(authQuery)) { //callback after successful auth with github
- const isUserCollaborator = await checkUserCollaboratorStatus(authQuery.code);
- if (isUserCollaborator?.isAllowed) {
- setUserAccessToken(isUserCollaborator.access_token)
- if (typeof window !== "undefined") window.localStorage.setItem('user-github-key', isUserCollaborator.access_token);
- }
-
- setIsUserAuthorized(isUserCollaborator?.isAllowed)
+ if (!isEmpty(authQuery) && userAccessStatus === null) { //callback after successful auth with github
+ const isUserCollaborator = await checkUserCollaboratorStatus(authQuery.code);
+ setUserAccessStatus(isUserCollaborator?.userPermission)
+ if (isUserCollaborator?.userPermission) {
+ if (typeof window !== "undefined") window.localStorage.setItem('user-github-isAllowed', isUserCollaborator?.userPermission);
}
}
setIsLoading(false)
- }, [userAccessToken])
+ }, [userAccessStatus])
if (isLoading) return
- if (isUserAuthorized === false) {
+ if (userAccessStatus === false) {
return
}
- if (typeof isUserAuthorized == 'undefined' || isUserAuthorized?.status === 401) {
+ if (userAccessStatus === null) {
return (
)