Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Authentication can be optionally disabled #89

Merged
merged 16 commits into from
Aug 24, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion env.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ const PLUGINS_MODULE = process.env.PLUGINS_MODULE;
// If it has no protocol, it will be treated as relative to window.location.origin
const STATUS_URL = process.env.STATUS_URL;

const ENABLE_AUTH = process.env.ENABLE_AUTH || true ;

module.exports = {
ADMIN_API_URL,
BASE_URL,
Expand All @@ -39,6 +41,7 @@ module.exports = {
BASE_URL,
CORS_PROXY_PREFIX,
NODE_ENV,
STATUS_URL
STATUS_URL,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two small things:

  1. These are sorted alphabetically, would prefer if you can keep that.
  2. It's not documented, but the way this object works is that items in processEnv will be sent to the client, and items outside of it are available on the server. I think this new variable should be in both places, so can you add it at both levels of the object?

ENABLE_AUTH
}
};
5 changes: 3 additions & 2 deletions src/models/AdminEntity/AdminEntity.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { env } from 'common/env';
import axios, { AxiosRequestConfig } from 'axios';

import { generateAdminApiQuery } from './AdminApiQuery';
Expand Down Expand Up @@ -44,7 +45,7 @@ async function request(
const finalOptions = {
...options,
url: adminApiUrl(endpoint),
withCredentials: true
withCredentials: env.ENABLE_AUTH
};

try {
Expand All @@ -70,7 +71,7 @@ export async function getProtobufObject<ResponseType>(
headers,
method: 'get',
responseType: 'arraybuffer',
withCredentials: true
withCredentials: env.ENABLE_AUTH
};

const { data } = await axios.request(options);
Expand Down