juice-shop

Форк
0
/
configuration.service.ts 
113 строк · 2.7 Кб
1
/*
2
 * Copyright (c) 2014-2024 Bjoern Kimminich & the OWASP Juice Shop contributors.
3
 * SPDX-License-Identifier: MIT
4
 */
5

6
import { environment } from '../../environments/environment'
7
import { Injectable } from '@angular/core'
8
import { HttpClient } from '@angular/common/http'
9
import { catchError, map } from 'rxjs/operators'
10
import { type Observable } from 'rxjs'
11

12
interface ConfigResponse {
13
  config: Config
14
}
15
export interface Config {
16
  server: {
17
    port: number
18
  }
19
  application: {
20
    domain: string
21
    name: string
22
    logo: string
23
    favicon: string
24
    theme: string
25
    showVersionNumber: boolean
26
    showGitHubLinks: boolean
27
    localBackupEnabled: boolean
28
    numberOfRandomFakeUsers: number
29
    altcoinName: string
30
    privacyContactEmail: string
31
    social: {
32
      twitterUrl: string
33
      facebookUrl: string
34
      slackUrl: string
35
      redditUrl: string
36
      pressKitUrl: string
37
      nftUrl: string
38
      questionnaireUrl: string
39
    }
40
    recyclePage: {
41
      topProductImage: string
42
      bottomProductImage: string
43
    }
44
    welcomeBanner: {
45
      showOnFirstStart: boolean
46
      title: string
47
      message: string
48
    }
49
    cookieConsent: {
50
      message: string
51
      dismissText: string
52
      linkText: string
53
      linkUrl: string
54
    }
55
    securityTxt: {
56
      contact: string
57
      encryption: string
58
      acknowledgements: string
59
    }
60
    promotion: {
61
      video: string
62
      subtitles: string
63
    }
64
    easterEggPlanet: {
65
      name: string
66
      overlayMap: string
67
    }
68
    googleOauth: {
69
      clientId: string
70
      authorizedRedirects: any[]
71
    }
72
  }
73
  challenges: {
74
    showSolvedNotifications: boolean
75
    showHints: boolean
76
    showMitigations: boolean
77
    codingChallengesEnabled: string
78
    restrictToTutorialsFirst: boolean
79
    safetyMode: string
80
    overwriteUrlForProductTamperingChallenge: string
81
    showFeedbackButtons: boolean
82
  }
83
  hackingInstructor: {
84
    isEnabled: boolean
85
    avatarImage: string
86
  }
87
  products: any[]
88
  memories: any[]
89
  ctf: {
90
    showFlagsInNotifications: boolean
91
    showCountryDetailsInNotifications: string
92
    countryMapping: any[]
93
  }
94
}
95

96
@Injectable({
97
  providedIn: 'root'
98
})
99
export class ConfigurationService {
100
  private readonly hostServer = environment.hostServer
101
  private readonly host = this.hostServer + '/rest/admin'
102
  private configObservable: any
103
  constructor (private readonly http: HttpClient) { }
104

105
  getApplicationConfiguration (): Observable<Config> {
106
    if (this.configObservable) {
107
      return this.configObservable
108
    } else {
109
      this.configObservable = this.http.get<ConfigResponse>(this.host + '/application-configuration').pipe(map((response: ConfigResponse) => response.config, catchError((err) => { throw err })))
110
      return this.configObservable
111
    }
112
  }
113
}
114

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.