Use compute auth service and fix static code analyzer warnings (#15)

* Clean up formatting

* Use new compute_auth service
Implment SSO
Implement token refresh
Clean up unit tests

* Fix unit tests

* Fix auth test
Fix warnings

* Update default settings for compute_auth
This commit is contained in:
John Wu
2021-03-04 14:30:56 -08:00
committed by GitHub
parent e1f0006d5e
commit 39e779dc1d
34 changed files with 703 additions and 1462 deletions

View File

@@ -1,34 +1,34 @@
const AUTH_URL = process.env.REACT_APP_AUTH_SERVICE_URL || "https://dev-auth.fiskerdps.com";
const AUTH_URL = process.env.REACT_APP_AUTH_SERVICE_URL || "https://gw-dev.fiskerdps.com/compute_auth";
const CALLBACK_URL = process.env.REACT_APP_AUTH_CALLBACK_URL || "https://dev-ota-admin.fiskerdps.com";
const auth = {
signIn: (username, password) => fetch(`${AUTH_URL}/auth/login`, {
ssoAuthorize: () => `${AUTH_URL}/authorize?redirect=${CALLBACK_URL}`,
ssoLogout: () => `${AUTH_URL}/logout?redirect=${CALLBACK_URL}`,
signIn: (code) => fetch(`${AUTH_URL}/token`, {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify({
username,
password,
code,
redirect: CALLBACK_URL,
})
}).then((response) => response.json()),
signUp: (username, password) => fetch(`${AUTH_URL}/auth/register`, {
verify: (idToken) => fetch(`${AUTH_URL}/verify`, {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify({
username,
password,
})
body: JSON.stringify({ token: idToken })
}).then((response) => response.json()),
verify: (accessToken) => fetch(`${AUTH_URL}/auth/verify`, {
refresh: (refreshToken) => fetch(`${AUTH_URL}/refresh`, {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify({ token: accessToken })
body: JSON.stringify({ refresh_token: refreshToken })
}).then((response) => response.json()),
};