Skip to content

Fix #10966 improved basic auth modal and logic#11077

Merged
MV88 merged 3 commits intogeosolutions-it:masterfrom
MV88:10966_creds_part_2
May 7, 2025
Merged

Fix #10966 improved basic auth modal and logic#11077
MV88 merged 3 commits intogeosolutions-it:masterfrom
MV88:10966_creds_part_2

Conversation

@MV88
Copy link
Copy Markdown
Contributor

@MV88 MV88 commented May 6, 2025

Description

new modal is like this

image

Adding these points to be done

  • basic auth must be added also to GetCapabilities requests
  • add x in top right, remove cancel button
  • position of clear button same height of ok, all fields inline taking flex space
  • show credentials when modal opens
  • check context edit button --> mandatory and hidden of pluginsconfig
  • add show password button

Please check if the PR fulfills these requirements

What kind of change does this PR introduce? (check one with "x", remove the others)

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Other... Please describe:

Issue

What is the current behavior?

Fix #10966

What is the new behavior?

see description

Breaking change

Does this PR introduce a breaking change? (check one with "x", remove the other)

  • Yes, and I documented them in migration notes
  • No

Other useful information

@MV88 MV88 added this to the 2025.02.00 milestone May 6, 2025
@MV88 MV88 requested a review from allyoucanmap May 6, 2025 20:17
@MV88 MV88 self-assigned this May 6, 2025
@MV88 MV88 added the New Feature used for new functionalities label May 6, 2025
Copy link
Copy Markdown
Contributor

@allyoucanmap allyoucanmap left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed that here we are using protectedId to select the credential while inside WFSLayerUtils is using sourceId, is this correct?

export const needsCredentials = (options) => {
const security = options?.security || {};
const {type, sourceId} = security;
const {username, password} = getCredentials(sourceId) ?? {};
return type?.toLowerCase?.() === "basic" && (!username || !password);
};
export const getConfig = (options) => {
const security = options?.security || {};
const config = {};
const {type, sourceId} = security;
const credentials = getCredentials(sourceId);
if (credentials) {
const {username, password} = credentials;
switch (type?.toLowerCase?.()) {
case "basic":
config.headers = {
Authorization: `Basic ${btoa(`${username}:${password}`)}`
};
break;
case "bearer":
config.headers = {
Authorization: `Bearer ${credentials.token}`
};
break;
default:
break;
}
}
return config;
};

@MV88 MV88 requested a review from allyoucanmap May 7, 2025 08:49
@MV88
Copy link
Copy Markdown
Contributor Author

MV88 commented May 7, 2025

I noticed that here we are using protectedId to select the credential while inside WFSLayerUtils is using sourceId, is this correct?

export const needsCredentials = (options) => {
const security = options?.security || {};
const {type, sourceId} = security;
const {username, password} = getCredentials(sourceId) ?? {};
return type?.toLowerCase?.() === "basic" && (!username || !password);
};
export const getConfig = (options) => {
const security = options?.security || {};
const config = {};
const {type, sourceId} = security;
const credentials = getCredentials(sourceId);
if (credentials) {
const {username, password} = credentials;
switch (type?.toLowerCase?.()) {
case "basic":
config.headers = {
Authorization: `Basic ${btoa(`${username}:${password}`)}`
};
break;
case "bearer":
config.headers = {
Authorization: `Bearer ${credentials.token}`
};
break;
default:
break;
}
}
return config;
};

I answer also here in order to explain the reasoning:
protectedId is for services data, and sourceId was a preexisting name used in layer.security object (for WFS mainly)
So in order to avoid confusion I have created two different names, but I can quickly replace them.

@MV88 MV88 enabled auto-merge (squash) May 7, 2025 08:52
@MV88 MV88 merged commit f6acbb6 into geosolutions-it:master May 7, 2025
5 checks passed
@ElenaGallo
Copy link
Copy Markdown
Contributor

@MV88 If the credentials are still "basic", once set in the protected service pop-up, the service can no longer be saved.

error.mp4

MV88 added a commit to MV88/MapStore2 that referenced this pull request May 8, 2025
…utions-it#11077)

* Fix geosolutions-it#10966 improved basic auth modal and logic

* fix tests

* created getAuthorizationBasic to harmonize code and tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

New Feature used for new functionalities

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Insert credentials at runtime when connecting to secured services

4 participants