• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

geosolutions-it / MapStore2 / 19060241474

04 Nov 2025 06:46AM UTC coverage: 76.943% (+0.02%) from 76.92%
19060241474

Pull #11648

github

web-flow
Merge 763e0cf1e into 19e678788
Pull Request #11648: #11644: Implement dynamic request configurations

32057 of 49801 branches covered (64.37%)

201 of 222 new or added lines in 39 files covered. (90.54%)

4 existing lines in 3 files now uncovered.

39801 of 51728 relevant lines covered (76.94%)

39.94 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

64.79
/web/client/actions/security.js
1
/**
2
 * Copyright 2015, GeoSolutions Sas.
3
 * All rights reserved.
4
 *
5
 * This source code is licensed under the BSD-style license found in the
6
 * LICENSE file in the root directory of this source tree.
7
 */
8

9
/**
10
 * Here you can change the API to use for AuthenticationAPI
11
 */
12
import AuthenticationAPI from '../api/GeoStoreDAO';
13

14
import {setCredentials, getToken, getRefreshToken} from '../utils/SecurityUtils';
15
import {encodeUTF8} from '../utils/EncodeUtils';
16

17
export const CHECK_LOGGED_USER = 'CHECK_LOGGED_USER';
1✔
18
export const LOGIN_SUBMIT = 'LOGIN_SUBMIT';
1✔
19
export const LOGIN_PROMPT_CLOSED = "LOGIN:LOGIN_PROMPT_CLOSED";
1✔
20
export const LOGIN_REQUIRED = "LOGIN:LOGIN_REQUIRED";
1✔
21
export const LOGIN_SUCCESS = 'LOGIN_SUCCESS';
1✔
22
export const LOGIN_FAIL = 'LOGIN_FAIL';
1✔
23
export const RESET_ERROR = 'RESET_ERROR';
1✔
24
export const CHANGE_PASSWORD = 'CHANGE_PASSWORD';
1✔
25
export const CHANGE_PASSWORD_SUCCESS = 'CHANGE_PASSWORD_SUCCESS';
1✔
26
export const CHANGE_PASSWORD_FAIL = 'CHANGE_PASSWORD_FAIL';
1✔
27
export const LOGOUT = 'LOGOUT';
1✔
28
export const REFRESH_SUCCESS = 'REFRESH_SUCCESS';
1✔
29
export const SESSION_VALID = 'SESSION_VALID';
1✔
30

31
export const SET_SHOW_MODAL_STATUS = 'SECURITY:SET_SHOW_MODAL_STATUS';
1✔
32
export const SET_CREDENTIALS = 'SECURITY:SET_CREDENTIALS';
1✔
33
export const CLEAR_SECURITY = 'SECURITY:CLEAR_SECURITY';
1✔
34
export const SET_PROTECTED_SERVICES = 'SECURITY:SET_PROTECTED_SERVICES';
1✔
35
export const REFRESH_SECURITY_LAYERS = 'SECURITY:REFRESH_SECURITY_LAYERS';
1✔
36

37
export const UPDATE_REQUESTS_RULES = 'SECURITY:UPDATE_REQUESTS_RULES';
1✔
38
export const LOAD_REQUESTS_RULES = 'SECURITY:LOAD_REQUESTS_RULES';
1✔
39
export const LOAD_REQUESTS_RULES_ERROR = 'SECURITY:LOAD_REQUESTS_RULES_ERROR';
1✔
40

41
export function loginSuccess(userDetails, username, password, authProvider) {
42
    return {
28✔
43
        type: LOGIN_SUCCESS,
44
        userDetails: userDetails,
45
        // set here for compatibility reasons
46
        // TODO: verify if the compatibility reasons still hold and remove otherwise
47
        authHeader: 'Basic ' + btoa(encodeUTF8(username) + ':' + encodeUTF8(password)),
48
        username: username,
49
        password: password,
50
        authProvider: authProvider
51
    };
52
}
53

54
export function loginFail(e) {
55
    return {
1✔
56
        type: LOGIN_FAIL,
57
        error: e
58
    };
59
}
60

61
export function resetError() {
62
    return {
2✔
63
        type: RESET_ERROR
64
    };
65
}
66

67
export function logout(redirectUrl) {
68
    return {
13✔
69
        type: LOGOUT,
70
        redirectUrl: redirectUrl
71
    };
72
}
73

74
/**
75
 * Asks for  login
76
 */
77
export function loginRequired() {
78
    return {
6✔
79
        type: LOGIN_REQUIRED
80
    };
81
}
82

83
/**
84
 * event of login close after a LOGIN_REQUIRED event
85
 * @param {string} owner
86
 */
87
export function loginPromptClosed() {
88
    return {
3✔
89
        type: LOGIN_PROMPT_CLOSED
90
    };
91
}
92

93
export function logoutWithReload() {
94
    return (dispatch) => {
1✔
95
        dispatch(logout(null));
×
96
    };
97
}
98

99
export function login(username, password) {
100
    return (dispatch) => {
×
101
        return AuthenticationAPI.login(username, password).then((response) => {
×
102
            dispatch(loginSuccess(response, username, password, AuthenticationAPI.authProviderName));
×
103
        }).catch((e) => {
104
            dispatch(loginFail(e));
×
105
        });
106
    };
107
}
108

109
export function changePasswordSuccess(user, newPassword) {
110
    return {
×
111
        type: CHANGE_PASSWORD_SUCCESS,
112
        user: user,
113
        authHeader: 'Basic ' + btoa(encodeUTF8(user.name) + ':' + encodeUTF8(newPassword))
114
    };
115
}
116

117
export function changePasswordFail(e) {
118
    return {
×
119
        type: CHANGE_PASSWORD_FAIL,
120
        error: e
121
    };
122
}
123

124
export function changePasswordStart() {
125
    return {
×
126
        type: CHANGE_PASSWORD
127
    };
128
}
129

130
export function changePassword(user, newPassword) {
131
    return (dispatch) => {
×
132
        dispatch(changePasswordStart());
×
133
        AuthenticationAPI.changePassword(user, newPassword).then(() => {
×
134
            dispatch(changePasswordSuccess(user, newPassword));
×
135
        }).catch((e) => {
136
            dispatch(changePasswordFail(e));
×
137
        });
138
    };
139
}
140

141
export function refreshSuccess(userDetails, authProvider) {
142
    return {
6✔
143
        type: REFRESH_SUCCESS,
144
        userDetails: userDetails,
145
        authProvider: authProvider
146
    };
147
}
148

149
export function refreshAccessToken() {
150
    return (dispatch) => {
7✔
151
        const accessToken = getToken();
×
152
        const refreshToken = getRefreshToken();
×
153
        AuthenticationAPI.refreshToken(accessToken, refreshToken).then((response) => {
×
154
            dispatch(refreshSuccess(response, AuthenticationAPI.authProviderName));
×
155
        }).catch(() => {
156
            dispatch(logout(null));
×
157
        });
158
    };
159
}
160

161
export function sessionValid(userDetails, authProvider) {
162
    return {
1✔
163
        type: SESSION_VALID,
164
        userDetails: userDetails,
165
        authProvider: authProvider
166
    };
167
}
168

169
export function verifySession() {
170
    return (dispatch) => {
×
171
        AuthenticationAPI.verifySession().then((response) => {
×
172
            dispatch(sessionValid(response, AuthenticationAPI.authProviderName));
×
173
        }).catch(() => {
174
            dispatch(logout(null));
×
175
        });
176
    };
177
}
178

179
export const checkLoggedUser = () => ({type: CHECK_LOGGED_USER});
2✔
180

181
/**
182
 * set status to show modal for inserting credentials
183
 * @param {boolean} status
184
 */
185
export const setShowModalStatus = (status) => {
1✔
186
    return {
1✔
187
        status,
188
        type: SET_SHOW_MODAL_STATUS
189
    };
190
};
191
/**
192
 * set protected services to request to provide username and password
193
 * @param {object[]} protectedServices
194
 */
195
export const setProtectedServices = (protectedServices) => {
1✔
196
    return {
1✔
197
        protectedServices,
198
        type: SET_PROTECTED_SERVICES
199
    };
200
};
201
/**
202
 * clear security of layers
203
 * @param {string} id
204
 */
205
export const clearSecurity = (protectedId) => {
1✔
206
    return {
5✔
207
        protectedId,
208
        type: CLEAR_SECURITY
209
    };
210
};
211
/**
212
 * set credentials for a service ogc
213
 * @param {object} protectedService
214
 */
215
export const setCredentialsAction = (protectedService, creds) => {
1✔
216
    if (creds && protectedService.protectedId) {
3✔
217
        setCredentials(protectedService.protectedId, {
2✔
218
            ...creds,
219
            url: protectedService.url
220
        });
221
    }
222
    return {
3✔
223
        protectedService,
224
        type: SET_CREDENTIALS
225
    };
226
};
227

228
/**
229
 * action to use to rerender layers in map when security changed
230
 */
231
export function refreshSecurityLayers() {
232
    return {
5✔
233
        type: REFRESH_SECURITY_LAYERS
234
    };
235
}
236

237
/**
238
 * Updates the request configuration rules
239
 * @param {Array} rules - Array of request configuration rules
240
 * @param {boolean} enabled - Whether request configuration is enabled
241
 */
242
export const updateRequestsRules = (rules) => {
1✔
NEW
243
    return {
×
244
        type: UPDATE_REQUESTS_RULES,
245
        rules
246
    };
247
};
248

249
/**
250
 * Starts loading request configuration rules
251
 */
252
export const loadRequestsRules = (rules) => {
1✔
NEW
253
    return {
×
254
        type: LOAD_REQUESTS_RULES,
255
        rules
256
    };
257
};
258

259
/**
260
 * Error loading request configuration rules
261
 * @param {Error} error - The error that occurred
262
 */
263
export const loadRequestsRulesError = (error) => {
1✔
NEW
264
    return {
×
265
        type: LOAD_REQUESTS_RULES_ERROR,
266
        error
267
    };
268
};
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc