web: manage version via package.json
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
parent
ef218ff1ff
commit
022401b60e
|
@ -17,4 +17,4 @@ tag_name = version/{new_version}
|
|||
|
||||
[bumpversion:file:internal/constants/constants.go]
|
||||
|
||||
[bumpversion:file:web/src/constants.ts]
|
||||
[bumpversion:file:web/package.json]
|
||||
|
|
|
@ -4,5 +4,3 @@ node_modules
|
|||
dist
|
||||
# don't lint nyc coverage output
|
||||
coverage
|
||||
# don't lint generated code
|
||||
api/
|
||||
|
|
|
@ -4,7 +4,5 @@ node_modules
|
|||
dist
|
||||
# don't lint nyc coverage output
|
||||
coverage
|
||||
# don't lint generated code
|
||||
api/
|
||||
# Import order matters
|
||||
poly.ts
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "authentik-web",
|
||||
"version": "0.0.0",
|
||||
"name": "@goauthentik/web",
|
||||
"version": "2022.6.3",
|
||||
"private": true,
|
||||
"license": "GNU GPLv3",
|
||||
"scripts": {
|
||||
|
|
|
@ -7,6 +7,8 @@ import copy from "rollup-plugin-copy";
|
|||
import cssimport from "rollup-plugin-cssimport";
|
||||
import { terser } from "rollup-plugin-terser";
|
||||
|
||||
import pkg from "./package.json";
|
||||
|
||||
const extensions = [".js", ".jsx", ".ts", ".tsx"];
|
||||
|
||||
export const resources = [
|
||||
|
@ -73,6 +75,12 @@ export const defaultOptions = {
|
|||
plugins: [
|
||||
cssimport(),
|
||||
markdown(),
|
||||
replace({
|
||||
"process.env.NODE_ENV": JSON.stringify(isProdBuild ? "production" : "development"),
|
||||
"process.env.AK_API_BASE_PATH": JSON.stringify(apiBasePath),
|
||||
"process.env.AK_VERSION": JSON.stringify(pkg.version),
|
||||
"preventAssignment": true,
|
||||
}),
|
||||
nodeResolve({ extensions, browser: true }),
|
||||
commonjs(),
|
||||
babel({
|
||||
|
@ -80,11 +88,6 @@ export const defaultOptions = {
|
|||
babelHelpers: "runtime",
|
||||
include: ["src/**/*"],
|
||||
}),
|
||||
replace({
|
||||
"process.env.NODE_ENV": JSON.stringify(isProdBuild ? "production" : "development"),
|
||||
"process.env.AK_API_BASE_PATH": JSON.stringify(apiBasePath),
|
||||
"preventAssignment": true,
|
||||
}),
|
||||
isProdBuild && terser(),
|
||||
].filter((p) => p),
|
||||
watch: {
|
||||
|
|
|
@ -1,20 +1,29 @@
|
|||
import { Config, Configuration, CoreApi, CurrentTenant, FetchParams, Middleware, RequestContext, ResponseContext, RootApi } from "@goauthentik/api";
|
||||
import { getCookie } from "@goauthentik/web/utils";
|
||||
import { APIMiddleware } from "@goauthentik/web/elements/notifications/APIDrawer";
|
||||
import { MessageMiddleware } from "@goauthentik/web/elements/messages/Middleware";
|
||||
import { VERSION } from "@goauthentik/web/constants";
|
||||
import { MessageMiddleware } from "@goauthentik/web/elements/messages/Middleware";
|
||||
import { APIMiddleware } from "@goauthentik/web/elements/notifications/APIDrawer";
|
||||
import { getCookie } from "@goauthentik/web/utils";
|
||||
|
||||
import {
|
||||
Config,
|
||||
Configuration,
|
||||
CoreApi,
|
||||
CurrentTenant,
|
||||
FetchParams,
|
||||
Middleware,
|
||||
RequestContext,
|
||||
ResponseContext,
|
||||
RootApi,
|
||||
} from "@goauthentik/api";
|
||||
|
||||
export class LoggingMiddleware implements Middleware {
|
||||
|
||||
post(context: ResponseContext): Promise<Response | void> {
|
||||
tenant().then(tenant => {
|
||||
tenant().then((tenant) => {
|
||||
let msg = `authentik/api[${tenant.matchedDomain}]: `;
|
||||
msg += `${context.response.status} ${context.init.method} ${context.url}`;
|
||||
console.debug(msg);
|
||||
});
|
||||
return Promise.resolve(context.response);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
let globalConfigPromise: Promise<Config>;
|
||||
|
@ -28,21 +37,25 @@ export function config(): Promise<Config> {
|
|||
let globalTenantPromise: Promise<CurrentTenant>;
|
||||
export function tenant(): Promise<CurrentTenant> {
|
||||
if (!globalTenantPromise) {
|
||||
globalTenantPromise = new CoreApi(DEFAULT_CONFIG).coreTenantsCurrentRetrieve().then(tenant => {
|
||||
globalTenantPromise = new CoreApi(DEFAULT_CONFIG)
|
||||
.coreTenantsCurrentRetrieve()
|
||||
.then((tenant) => {
|
||||
/**
|
||||
* <link rel="icon" href="/static/dist/assets/icons/icon.png">
|
||||
* <link rel="shortcut icon" href="/static/dist/assets/icons/icon.png">
|
||||
*/
|
||||
const rels = ["icon", "shortcut icon"];
|
||||
rels.forEach(rel => {
|
||||
let relIcon = document.head.querySelector<HTMLLinkElement>(`link[rel='${rel}']`);
|
||||
rels.forEach((rel) => {
|
||||
let relIcon = document.head.querySelector<HTMLLinkElement>(
|
||||
`link[rel='${rel}']`,
|
||||
);
|
||||
if (!relIcon) {
|
||||
relIcon = document.createElement('link');
|
||||
relIcon = document.createElement("link");
|
||||
relIcon.rel = rel;
|
||||
document.getElementsByTagName('head')[0].appendChild(relIcon);
|
||||
document.getElementsByTagName("head")[0].appendChild(relIcon);
|
||||
}
|
||||
relIcon.href = tenant.brandingFavicon;
|
||||
})
|
||||
});
|
||||
return tenant;
|
||||
});
|
||||
}
|
||||
|
|
|
@ -74,10 +74,10 @@ export class PlexAPIClient {
|
|||
headers: headers,
|
||||
});
|
||||
if (pinResponse.status > 200) {
|
||||
throw new SentryIgnoredError("Invalid response code")
|
||||
throw new SentryIgnoredError("Invalid response code");
|
||||
}
|
||||
const pin: PlexPinResponse = await pinResponse.json();
|
||||
console.debug(`authentik/plex: polling Pin`);
|
||||
console.debug("authentik/plex: polling Pin");
|
||||
return pin.authToken;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
import { SentryIgnoredError } from "@goauthentik/web/common/errors";
|
||||
import { VERSION } from "@goauthentik/web/constants";
|
||||
import * as Sentry from "@sentry/browser";
|
||||
import { Integrations } from "@sentry/tracing";
|
||||
import { VERSION } from "@goauthentik/web/constants";
|
||||
import { SentryIgnoredError } from "@goauthentik/web/common/errors";
|
||||
import { me } from "./Users";
|
||||
import { config } from "./Config";
|
||||
|
||||
import { Config } from "@goauthentik/api";
|
||||
|
||||
import { config } from "./Config";
|
||||
import { me } from "./Users";
|
||||
|
||||
export const TAG_SENTRY_COMPONENT = "authentik.component";
|
||||
export const TAG_SENTRY_CAPABILITIES = "authentik.capabilities";
|
||||
|
||||
|
@ -15,13 +17,13 @@ export function configureSentry(canDoPpi = false): Promise<Config> {
|
|||
Sentry.init({
|
||||
dsn: "https://a579bb09306d4f8b8d8847c052d3a1d3@sentry.beryju.org/8",
|
||||
ignoreErrors: [
|
||||
/network/ig,
|
||||
/fetch/ig,
|
||||
/network/gi,
|
||||
/fetch/gi,
|
||||
// Error on edge on ios,
|
||||
// https://stackoverflow.com/questions/69261499/what-is-instantsearchsdkjsbridgeclearhighlight
|
||||
/instantSearchSDKJSBridgeClearHighlight/ig,
|
||||
/instantSearchSDKJSBridgeClearHighlight/gi,
|
||||
// Seems to be an issue in Safari and Firefox
|
||||
/MutationObserver.observe/ig,
|
||||
/MutationObserver.observe/gi,
|
||||
],
|
||||
release: `authentik@${VERSION}`,
|
||||
tunnel: "/api/v3/sentry/",
|
||||
|
@ -32,14 +34,20 @@ export function configureSentry(canDoPpi = false): Promise<Config> {
|
|||
],
|
||||
tracesSampleRate: config.errorReporting.tracesSampleRate,
|
||||
environment: config.errorReporting.environment,
|
||||
beforeSend: async (event: Sentry.Event, hint: Sentry.EventHint | undefined): Promise<Sentry.Event | null> => {
|
||||
beforeSend: async (
|
||||
event: Sentry.Event,
|
||||
hint: Sentry.EventHint | undefined,
|
||||
): Promise<Sentry.Event | null> => {
|
||||
if (!hint) {
|
||||
return event;
|
||||
}
|
||||
if (hint.originalException instanceof SentryIgnoredError) {
|
||||
return null;
|
||||
}
|
||||
if (hint.originalException instanceof Response || hint.originalException instanceof DOMException) {
|
||||
if (
|
||||
hint.originalException instanceof Response ||
|
||||
hint.originalException instanceof DOMException
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
return event;
|
||||
|
@ -48,10 +56,12 @@ export function configureSentry(canDoPpi = false): Promise<Config> {
|
|||
Sentry.setTag(TAG_SENTRY_CAPABILITIES, config.capabilities.join(","));
|
||||
if (window.location.pathname.includes("if/")) {
|
||||
Sentry.setTag(TAG_SENTRY_COMPONENT, `web/${currentInterface()}`);
|
||||
Sentry.configureScope((scope) => scope.setTransactionName(`authentik.web.if.${currentInterface()}`));
|
||||
Sentry.configureScope((scope) =>
|
||||
scope.setTransactionName(`authentik.web.if.${currentInterface()}`),
|
||||
);
|
||||
}
|
||||
if (config.errorReporting.sendPii && canDoPpi) {
|
||||
me().then(user => {
|
||||
me().then((user) => {
|
||||
Sentry.setUser({ email: user.user.email });
|
||||
console.debug("authentik/config: Sentry with PII enabled.");
|
||||
});
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
import { CoreApi, ResponseError, SessionUser } from "@goauthentik/api";
|
||||
import { activateLocale } from "@goauthentik/web/interfaces/locale";
|
||||
|
||||
import { CoreApi, ResponseError, SessionUser } from "@goauthentik/api";
|
||||
|
||||
import { DEFAULT_CONFIG } from "./Config";
|
||||
|
||||
let globalMePromise: Promise<SessionUser> | undefined;
|
||||
|
@ -11,17 +13,22 @@ export function refreshMe(): Promise<SessionUser> {
|
|||
|
||||
export function me(): Promise<SessionUser> {
|
||||
if (!globalMePromise) {
|
||||
globalMePromise = new CoreApi(DEFAULT_CONFIG).coreUsersMeRetrieve().then((user) => {
|
||||
globalMePromise = new CoreApi(DEFAULT_CONFIG)
|
||||
.coreUsersMeRetrieve()
|
||||
.then((user) => {
|
||||
if (!user.user.settings || !("locale" in user.user.settings)) {
|
||||
return user;
|
||||
}
|
||||
const locale = user.user.settings.locale;
|
||||
if (locale && locale !== "") {
|
||||
console.debug(`authentik/locale: Activating user's configured locale '${locale}'`);
|
||||
console.debug(
|
||||
`authentik/locale: Activating user's configured locale '${locale}'`,
|
||||
);
|
||||
activateLocale(locale);
|
||||
}
|
||||
return user;
|
||||
}).catch((ex: ResponseError) => {
|
||||
})
|
||||
.catch((ex: ResponseError) => {
|
||||
const defaultUser: SessionUser = {
|
||||
user: {
|
||||
pk: -1,
|
||||
|
@ -33,7 +40,7 @@ export function me(): Promise<SessionUser> {
|
|||
username: "",
|
||||
name: "",
|
||||
settings: {},
|
||||
}
|
||||
},
|
||||
};
|
||||
if (ex.response.status === 401 || ex.response.status === 403) {
|
||||
window.location.assign("/");
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
// Placeholder, replaced by rollup;
|
||||
export const VERSION = process.env.AK_VERSION;
|
||||
|
||||
export const SECONDARY_CLASS = "pf-m-secondary";
|
||||
export const SUCCESS_CLASS = "pf-m-success";
|
||||
export const ERROR_CLASS = "pf-m-danger";
|
||||
export const PROGRESS_CLASS = "pf-m-in-progress";
|
||||
export const CURRENT_CLASS = "pf-m-current";
|
||||
export const VERSION = "2022.6.3";
|
||||
export const TITLE_DEFAULT = "authentik";
|
||||
export const ROUTE_SEPARATOR = ";";
|
||||
|
||||
|
|
Reference in New Issue