juice-shop
113 строк · 2.7 Кб
1/*
2* Copyright (c) 2014-2024 Bjoern Kimminich & the OWASP Juice Shop contributors.
3* SPDX-License-Identifier: MIT
4*/
5
6import { environment } from '../../environments/environment'
7import { Injectable } from '@angular/core'
8import { HttpClient } from '@angular/common/http'
9import { catchError, map } from 'rxjs/operators'
10import { type Observable } from 'rxjs'
11
12interface ConfigResponse {
13config: Config
14}
15export interface Config {
16server: {
17port: number
18}
19application: {
20domain: string
21name: string
22logo: string
23favicon: string
24theme: string
25showVersionNumber: boolean
26showGitHubLinks: boolean
27localBackupEnabled: boolean
28numberOfRandomFakeUsers: number
29altcoinName: string
30privacyContactEmail: string
31social: {
32twitterUrl: string
33facebookUrl: string
34slackUrl: string
35redditUrl: string
36pressKitUrl: string
37nftUrl: string
38questionnaireUrl: string
39}
40recyclePage: {
41topProductImage: string
42bottomProductImage: string
43}
44welcomeBanner: {
45showOnFirstStart: boolean
46title: string
47message: string
48}
49cookieConsent: {
50message: string
51dismissText: string
52linkText: string
53linkUrl: string
54}
55securityTxt: {
56contact: string
57encryption: string
58acknowledgements: string
59}
60promotion: {
61video: string
62subtitles: string
63}
64easterEggPlanet: {
65name: string
66overlayMap: string
67}
68googleOauth: {
69clientId: string
70authorizedRedirects: any[]
71}
72}
73challenges: {
74showSolvedNotifications: boolean
75showHints: boolean
76showMitigations: boolean
77codingChallengesEnabled: string
78restrictToTutorialsFirst: boolean
79safetyMode: string
80overwriteUrlForProductTamperingChallenge: string
81showFeedbackButtons: boolean
82}
83hackingInstructor: {
84isEnabled: boolean
85avatarImage: string
86}
87products: any[]
88memories: any[]
89ctf: {
90showFlagsInNotifications: boolean
91showCountryDetailsInNotifications: string
92countryMapping: any[]
93}
94}
95
96@Injectable({
97providedIn: 'root'
98})
99export class ConfigurationService {
100private readonly hostServer = environment.hostServer
101private readonly host = this.hostServer + '/rest/admin'
102private configObservable: any
103constructor (private readonly http: HttpClient) { }
104
105getApplicationConfiguration (): Observable<Config> {
106if (this.configObservable) {
107return this.configObservable
108} else {
109this.configObservable = this.http.get<ConfigResponse>(this.host + '/application-configuration').pipe(map((response: ConfigResponse) => response.config, catchError((err) => { throw err })))
110return this.configObservable
111}
112}
113}
114