[DEPRECATE] Remove Google Analytics (#1021)

* it doesn't work with our current CSP
* it's probably not used by anyone
* it isn't in harmony with our security purposes
* literally removes all use of it
* suggestions from code review
* remove useless test.

Co-authored-by: Amir Zarrinkafsh <nightah@me.com>
Co-authored-by: Clement Michaud <clement.michaud34@gmail.com>
pull/1023/head
James Elliott 2020-05-16 09:41:42 +10:00 committed by GitHub
parent 991ce29e4b
commit a4cf2e675f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
20 changed files with 55 additions and 169 deletions

View File

@ -39,11 +39,6 @@ jwt_secret: a_very_important_secret
# be redirected upon successful authentication.
default_redirection_url: https://home.example.com:8080/
# Google Analytics Tracking ID to track the usage of the portal
# using a Google Analytics dashboard.
#
## google_analytics: UA-00000-01
# TOTP Settings
#
# Parameters used for TOTP generation

View File

@ -2,7 +2,7 @@
layout: default
title: Access Control
parent: Configuration
nav_order: 2
nav_order: 1
---
# Access Control

View File

@ -2,7 +2,7 @@
layout: default
title: Duo Push Notifications
parent: Configuration
nav_order: 3
nav_order: 2
---
# Duo Push Notifications

View File

@ -1,15 +0,0 @@
---
layout: default
title: Google Analytics
parent: Configuration
nav_order: 4
---
# Google Analytics
It is possible to provide a Google Analytics ID to Authelia in order
to monitor the usage of the Sign-In portal.
```yaml
google_analytics: UA-00000-01
```

View File

@ -2,7 +2,7 @@
layout: default
title: Miscellaneous
parent: Configuration
nav_order: 5
nav_order: 3
---
# Miscellaneous

View File

@ -2,7 +2,7 @@
layout: default
title: One-Time Password
parent: Configuration
nav_order: 6
nav_order: 4
---
# One-Time Password

View File

@ -2,7 +2,7 @@
layout: default
title: Regulation
parent: Configuration
nav_order: 7
nav_order: 5
---
# Regulation

View File

@ -2,7 +2,7 @@
layout: default
title: Secrets
parent: Configuration
nav_order: 8
nav_order: 6
---
# Secrets

View File

@ -2,7 +2,7 @@
layout: default
title: Server
parent: Configuration
nav_order: 9
nav_order: 7
---
# Server

View File

@ -2,7 +2,7 @@
layout: default
title: Session
parent: Configuration
nav_order: 10
nav_order: 8
---
# Session

View File

@ -2,17 +2,15 @@ package schema
// Configuration object extracted from YAML configuration file.
type Configuration struct {
Host string `mapstructure:"host"`
Port int `mapstructure:"port"`
TLSCert string `mapstructure:"tls_cert"`
TLSKey string `mapstructure:"tls_key"`
LogLevel string `mapstructure:"log_level"`
LogFilePath string `mapstructure:"log_file_path"`
JWTSecret string `mapstructure:"jwt_secret"`
DefaultRedirectionURL string `mapstructure:"default_redirection_url"`
GoogleAnalyticsTrackingID string `mapstructure:"google_analytics"`
Host string `mapstructure:"host"`
Port int `mapstructure:"port"`
TLSCert string `mapstructure:"tls_cert"`
TLSKey string `mapstructure:"tls_key"`
LogLevel string `mapstructure:"log_level"`
LogFilePath string `mapstructure:"log_file_path"`
JWTSecret string `mapstructure:"jwt_secret"`
DefaultRedirectionURL string `mapstructure:"default_redirection_url"`
// TODO: Consider refactoring the following pointers as they don't seem to need to be pointers: TOTP, Notifier, Regulation
AuthenticationBackend AuthenticationBackendConfiguration `mapstructure:"authentication_backend"`
Session SessionConfiguration `mapstructure:"session"`
TOTP *TOTPConfiguration `mapstructure:"totp"`

View File

@ -10,18 +10,17 @@ var validKeys = []string{
"jwt_secret",
"tls_key",
"tls_cert",
"google_analytics",
// Server Keys.
"server.read_buffer_size",
"server.write_buffer_size",
// TOTP Keys
// TOTP Keys.
"totp.issuer",
"totp.period",
"totp.skew",
// Access Control Keys
// Access Control Keys.
"access_control.rules",
"access_control.default_policy",
@ -130,8 +129,9 @@ var validKeys = []string{
}
var specificErrorKeys = map[string]string{
"logs_file_path": "config key replaced: logs_file is now log_file",
"logs_level": "config key replaced: logs_level is now log_level",
"logs_file_path": "config key replaced: logs_file is now log_file",
"logs_level": "config key replaced: logs_level is now log_level",
"google_analytics": "config key removed: google_analytics - this functionality has been deprecated",
"authentication_backend.file.password_options.algorithm": "config key incorrect: authentication_backend.file.password_options should be authentication_backend.file.password",
"authentication_backend.file.password_options.iterations": "config key incorrect: authentication_backend.file.password_options should be authentication_backend.file.password",
"authentication_backend.file.password_options.key_length": "config key incorrect: authentication_backend.file.password_options should be authentication_backend.file.password",

View File

@ -35,7 +35,6 @@ const unableToRegisterSecurityKeyMessage = "Unable to register your security key
const unableToResetPasswordMessage = "Unable to reset your password."
const mfaValidationFailedMessage = "Authentication failed, please retry later."
const testGATrackingID = "ABC"
const testInactivity = "10"
const testRedirectionURL = "http://redirection.local"
const testResultAllow = "allow"

View File

@ -4,17 +4,15 @@ import "github.com/authelia/authelia/internal/middlewares"
// ConfigurationBody configuration parameters exposed to the frontend.
type ConfigurationBody struct {
GoogleAnalyticsTrackingID string `json:"ga_tracking_id,omitempty"`
RememberMe bool `json:"remember_me"` // whether remember me is enabled or not
ResetPassword bool `json:"reset_password"`
RememberMe bool `json:"remember_me"` // whether remember me is enabled or not
ResetPassword bool `json:"reset_password"`
}
// ConfigurationGet fetches configuration parameters for frontend mutation.
func ConfigurationGet(ctx *middlewares.AutheliaCtx) {
body := ConfigurationBody{
GoogleAnalyticsTrackingID: ctx.Configuration.GoogleAnalyticsTrackingID,
RememberMe: ctx.Providers.SessionProvider.RememberMe != 0,
ResetPassword: !ctx.Configuration.AuthenticationBackend.DisableResetPassword,
RememberMe: ctx.Providers.SessionProvider.RememberMe != 0,
ResetPassword: !ctx.Configuration.AuthenticationBackend.DisableResetPassword,
}
ctx.SetJSONBody(body) //nolint:errcheck // TODO: Legacy code, consider refactoring time permitting.
}

View File

@ -5,7 +5,6 @@ import (
"github.com/stretchr/testify/suite"
"github.com/authelia/authelia/internal/configuration/schema"
"github.com/authelia/authelia/internal/mocks"
"github.com/authelia/authelia/internal/session"
)
@ -24,31 +23,13 @@ func (s *ConfigurationSuite) TearDownTest() {
s.mock.Close()
}
func (s *ConfigurationSuite) TestShouldReturnConfiguredGATrackingID() {
GATrackingID := testGATrackingID
s.mock.Ctx.Configuration.GoogleAnalyticsTrackingID = GATrackingID
s.mock.Ctx.Configuration.Session.RememberMeDuration = schema.DefaultSessionConfiguration.RememberMeDuration
expectedBody := ConfigurationBody{
GoogleAnalyticsTrackingID: GATrackingID,
RememberMe: true,
ResetPassword: true,
}
ConfigurationGet(s.mock.Ctx)
s.mock.Assert200OK(s.T(), expectedBody)
}
func (s *ConfigurationSuite) TestShouldDisableRememberMe() {
GATrackingID := testGATrackingID
s.mock.Ctx.Configuration.GoogleAnalyticsTrackingID = GATrackingID
s.mock.Ctx.Configuration.Session.RememberMeDuration = "0"
s.mock.Ctx.Providers.SessionProvider = session.NewProvider(
s.mock.Ctx.Configuration.Session)
expectedBody := ConfigurationBody{
GoogleAnalyticsTrackingID: GATrackingID,
RememberMe: false,
ResetPassword: true,
RememberMe: false,
ResetPassword: true,
}
ConfigurationGet(s.mock.Ctx)
@ -56,13 +37,10 @@ func (s *ConfigurationSuite) TestShouldDisableRememberMe() {
}
func (s *ConfigurationSuite) TestShouldDisableResetPassword() {
GATrackingID := testGATrackingID
s.mock.Ctx.Configuration.GoogleAnalyticsTrackingID = GATrackingID
s.mock.Ctx.Configuration.AuthenticationBackend.DisableResetPassword = true
expectedBody := ConfigurationBody{
GoogleAnalyticsTrackingID: GATrackingID,
RememberMe: true,
ResetPassword: false,
RememberMe: true,
ResetPassword: false,
}
ConfigurationGet(s.mock.Ctx)

View File

@ -18,8 +18,6 @@ import { Notification } from './models/Notifications';
import NotificationBar from './components/NotificationBar';
import SignOut from './views/LoginPortal/SignOut/SignOut';
import { useConfiguration } from './hooks/Configuration';
import Tracker from "./components/Tracker";
import { useTracking } from "./hooks/Tracking";
import '@fortawesome/fontawesome-svg-core/styles.css'
import {config as faConfig} from '@fortawesome/fontawesome-svg-core';
@ -28,7 +26,6 @@ faConfig.autoAddCss = false;
const App: React.FC = () => {
const [notification, setNotification] = useState(null as Notification | null);
const [configuration, fetchConfig, , fetchConfigError] = useConfiguration();
const tracker = useTracking(configuration);
useEffect(() => {
if (fetchConfigError) {
@ -41,34 +38,32 @@ const App: React.FC = () => {
return (
<NotificationsContext.Provider value={{ notification, setNotification }} >
<Router>
<Tracker tracker={tracker}>
<NotificationBar onClose={() => setNotification(null)} />
<Switch>
<Route path={ResetPasswordStep1Route} exact>
<ResetPasswordStep1 />
</Route>
<Route path={ResetPasswordStep2Route} exact>
<ResetPasswordStep2 />
</Route>
<Route path={RegisterSecurityKeyRoute} exact>
<RegisterSecurityKey />
</Route>
<Route path={RegisterOneTimePasswordRoute} exact>
<RegisterOneTimePassword />
</Route>
<Route path={LogoutRoute} exact>
<SignOut />
</Route>
<Route path={FirstFactorRoute}>
<LoginPortal
rememberMe={configuration?.remember_me === true}
resetPassword={configuration?.reset_password === true} />
</Route>
<Route path="/">
<Redirect to={FirstFactorRoute}></Redirect>
</Route>
</Switch>
</Tracker>
<NotificationBar onClose={() => setNotification(null)} />
<Switch>
<Route path={ResetPasswordStep1Route} exact>
<ResetPasswordStep1 />
</Route>
<Route path={ResetPasswordStep2Route} exact>
<ResetPasswordStep2 />
</Route>
<Route path={RegisterSecurityKeyRoute} exact>
<RegisterSecurityKey />
</Route>
<Route path={RegisterOneTimePasswordRoute} exact>
<RegisterOneTimePassword />
</Route>
<Route path={LogoutRoute} exact>
<SignOut />
</Route>
<Route path={FirstFactorRoute}>
<LoginPortal
rememberMe={configuration?.remember_me === true}
resetPassword={configuration?.reset_password === true} />
</Route>
<Route path="/">
<Redirect to={FirstFactorRoute}></Redirect>
</Route>
</Switch>
</Router>
</NotificationsContext.Provider>
);

View File

@ -1,11 +0,0 @@
import React from 'react';
import { mount } from "enzyme";
import Tracker from "./Tracker";
import { MemoryRouter as Router } from 'react-router-dom';
const mountWithRouter = node => mount(<Router>{node}</Router>);
it('renders without crashing', () => {
mountWithRouter(<Tracker trackingIDs={[]} />);
});

View File

@ -1,35 +0,0 @@
import React, { useEffect, useCallback, Fragment, ReactNode } from "react";
import { useLocation } from "react-router";
import ReactGA, { Tracker } from "react-ga";
export interface Props {
tracker: Tracker | undefined;
children?: ReactNode;
}
export default function (props: Props) {
const location = useLocation();
const trackPage = useCallback((page: string) => {
if (props.tracker) {
ReactGA.set({ page });
ReactGA.pageview(page);
}
}, [props.tracker]);
useEffect(() => {
if (props.tracker) {
ReactGA.initialize([props.tracker]);
}
}, [props.tracker]);
useEffect(() => {
trackPage(location.pathname + location.search);
}, [trackPage, location.pathname, location.search]);
return (
<Fragment>
{props.children}
</Fragment>
)
}

View File

@ -1,15 +0,0 @@
import { useState, useEffect } from "react";
import { Configuration } from "../models/Configuration";
import { Tracker } from "react-ga";
export function useTracking(configuration: Configuration | undefined) {
const [trackingIds, setTrackingIds] = useState(undefined as Tracker | undefined);
useEffect(() => {
if (configuration && configuration.ga_tracking_id) {
setTrackingIds({ trackingId: configuration.ga_tracking_id });
}
}, [configuration]);
return trackingIds;
}

View File

@ -1,7 +1,6 @@
import { SecondFactorMethod } from "./Methods";
export interface Configuration {
ga_tracking_id: string;
remember_me: boolean;
reset_password: boolean;
}