Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle 401 unauthorized error in the UI #3640

Conversation

ChengYanJin
Copy link
Contributor

@ChengYanJin ChengYanJin commented Dec 14, 2021

Component: UI

Context:
The aim of this PR is to handle correctly the 401 unauthorize error on the UI side.

Summary:
Add Error Reducer in order to dispatch authErrorAction.
We throw out AuthError when we get unauthorized status from Salt API and K8s API, and catch it at the top of reducer.
In the PrivateRoute, we display the <ErrorPage401/> if isAuthError is true in the redux-store.

Acceptance criteria:
EN:
image
FR:
image

Core-ui v0.25.0 includes this 401 unauthorized error page.

@bert-e
Copy link
Contributor

bert-e commented Dec 14, 2021

Hello chengyanjin,

My role is to assist you with the merge of this
pull request. Please type @bert-e help to get information
on this process, or consult the user documentation.

Status report is not available.

@bert-e
Copy link
Contributor

bert-e commented Dec 14, 2021

Conflict

A conflict has been raised during the creation of
integration branch w/2.11/bugfix/ARTESCA-2572-handle-unauthorized-error-in-the-UI with contents from bugfix/ARTESCA-2572-handle-unauthorized-error-in-the-UI
and development/2.11.

I have not created the integration branch.

Here are the steps to resolve this conflict:

 $ git fetch
 $ git checkout -B w/2.11/bugfix/ARTESCA-2572-handle-unauthorized-error-in-the-UI origin/development/2.11
 $ git merge origin/bugfix/ARTESCA-2572-handle-unauthorized-error-in-the-UI
 $ # <intense conflict resolution>
 $ git commit
 $ git push -u origin w/2.11/bugfix/ARTESCA-2572-handle-unauthorized-error-in-the-UI

@Cuervino Cuervino requested a review from a team December 14, 2021 17:12
@Cuervino
Copy link

@scality/doc Could you please review the wording?
I'm not sure about the "supplied".

@ChengYanJin ChengYanJin force-pushed the bugfix/ARTESCA-2572-handle-unauthorized-error-in-the-UI branch from a6a8e09 to 298082f Compare December 15, 2021 13:46
gaudiauj
gaudiauj previously approved these changes Dec 15, 2021
Copy link
Contributor

@gaudiauj gaudiauj left a comment

Choose a reason for hiding this comment

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

just couple of questions, but besides that it looks good.

approved

@@ -47,7 +47,7 @@
"webpack-dev-server": "^3.11.2"
},
"dependencies": {
"@scality/core-ui": "github:scality/core-ui.git#v0.22.2.1",
"@scality/core-ui": "github:scality/core-ui.git#695c63c",
Copy link
Contributor

Choose a reason for hiding this comment

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

do we really want to keep the commit hash rather than deploying a new version ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. You are right. We should tag a new version for the core-ui.
I am just waiting a bit to see if I can get a review from @scality/doc about the wording in the 401 unauthorized page.

Comment on lines +14 to +25
export default function reducer(
state: AuthErrorState = defaultState,
action: AuthErrorAction,
) {
switch (action.type) {
case 'AUTH_ERROR': {
return { ...state, isAuthError: true };
}
default:
return { ...state };
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

i'm not familiar with the way it work but what i see from the code, there is no way to remove the isAuthError. And we check in privateRoute.js if isAuthError is true. Are we sure that if the user relogin the isAuthError is reset ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hello @gaudiauj ,
It's a very good concern! but thanks to the authentication workflow, the isAuthError should be reset if we re-login again.

Once the user triggers logout action, the page will be redirected to the IDP, either dex or Keycloak.

Given the page is fully reloaded, the redux store will be re-initiated as well.

@ChengYanJin ChengYanJin force-pushed the bugfix/ARTESCA-2572-handle-unauthorized-error-in-the-UI branch 2 times, most recently from 0dbba18 to 898aaad Compare December 16, 2021 14:23
@bert-e
Copy link
Contributor

bert-e commented Dec 16, 2021

Integration data created

I have created the integration data for the additional destination branches.

The following branches will NOT be impacted:

  • development/2.0
  • development/2.1
  • development/2.2
  • development/2.3
  • development/2.4
  • development/2.5
  • development/2.6
  • development/2.7
  • development/2.8
  • development/2.9

You can set option create_pull_requests if you need me to create
integration pull requests in addition to integration branches, with:

@bert-e create_pull_requests

@bert-e
Copy link
Contributor

bert-e commented Dec 16, 2021

Waiting for approval

The following approvals are needed before I can proceed with the merge:

  • the author

  • one peer

Peer approvals must include at least 1 approval from the following list:

@ChengYanJin ChengYanJin changed the base branch from development/2.10 to development/2.11 December 16, 2021 14:24
@ChengYanJin ChengYanJin force-pushed the bugfix/ARTESCA-2572-handle-unauthorized-error-in-the-UI branch from 898aaad to e43c69f Compare December 16, 2021 14:47
@bert-e
Copy link
Contributor

bert-e commented Dec 16, 2021

History mismatch

Merge commit #898aaada770194e5d835311af7a9158a6f77fe24 on the integration branch
w/123.0/bugfix/ARTESCA-2572-handle-unauthorized-error-in-the-UI is merging a branch which is neither the current
branch bugfix/ARTESCA-2572-handle-unauthorized-error-in-the-UI nor the development branch
development/123.0.

It is likely due to a rebase of the branch bugfix/ARTESCA-2572-handle-unauthorized-error-in-the-UI and the
merge is not possible until all related w/* branches are deleted or updated.

Please use the reset command to have me reinitialize these branches.

@ChengYanJin ChengYanJin force-pushed the bugfix/ARTESCA-2572-handle-unauthorized-error-in-the-UI branch from e43c69f to 4897a2c Compare December 17, 2021 13:00
Copy link
Contributor

@JBWatenbergScality JBWatenbergScality left a comment

Choose a reason for hiding this comment

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

Other than this comment and Jean's comment LGTM

@@ -113,4 +128,9 @@ export async function getNodesIPsInterfaces(
'ip_interfaces',
],
});
if (result.error) {
handleUnAuthorizedError({ error: result.error });
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it may need to be returned

client: 'runner',
fun: 'jobs.print_job',
arg: [jid],
});
if (result.error) {
handleUnAuthorizedError({ error: result.error });
Copy link
Contributor

Choose a reason for hiding this comment

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

here too

@ChengYanJin ChengYanJin force-pushed the bugfix/ARTESCA-2572-handle-unauthorized-error-in-the-UI branch from 4897a2c to 370e5c6 Compare December 17, 2021 15:04
@bert-e
Copy link
Contributor

bert-e commented Dec 17, 2021

History mismatch

Merge commit #2432f52b5feba423da595be39b60efbdb66ec818 on the integration branch
w/123.0/bugfix/ARTESCA-2572-handle-unauthorized-error-in-the-UI is merging a branch which is neither the current
branch bugfix/ARTESCA-2572-handle-unauthorized-error-in-the-UI nor the development branch
development/123.0.

It is likely due to a rebase of the branch bugfix/ARTESCA-2572-handle-unauthorized-error-in-the-UI and the
merge is not possible until all related w/* branches are deleted or updated.

Please use the reset command to have me reinitialize these branches.

@ChengYanJin ChengYanJin force-pushed the bugfix/ARTESCA-2572-handle-unauthorized-error-in-the-UI branch 2 times, most recently from 3d2d869 to 846c8cf Compare December 17, 2021 15:12
@cathydossantospinto
Copy link
Contributor

cathydossantospinto commented Dec 17, 2021

@ChengYanJin Here's my suggestion for the French part.

! Accès refusé
Les identifiants fournis ne vous permettent pas de consulter cette page.
Vous pouvez contacter le support pour signaler le problème.

@lucieleonard Feel free to suggest something better if you can 😛

@John-VanHook will review the English part 😉

@John-VanHook
Copy link

The content of the dialog box is not wrong. You could keep it as is. But I suggest this is better:

You don’t have permission to view this page using the credentials you have supplied.

You can contact support to report this issue.

@ChengYanJin ChengYanJin force-pushed the bugfix/ARTESCA-2572-handle-unauthorized-error-in-the-UI branch from 846c8cf to 2eb5c9c Compare December 20, 2021 10:58
@ChengYanJin
Copy link
Contributor Author

/status

@bert-e
Copy link
Contributor

bert-e commented Dec 20, 2021

Status

Status report is not available.

@bert-e
Copy link
Contributor

bert-e commented Dec 20, 2021

History mismatch

Merge commit #2432f52b5feba423da595be39b60efbdb66ec818 on the integration branch
w/123.0/bugfix/ARTESCA-2572-handle-unauthorized-error-in-the-UI is merging a branch which is neither the current
branch bugfix/ARTESCA-2572-handle-unauthorized-error-in-the-UI nor the development branch
development/123.0.

It is likely due to a rebase of the branch bugfix/ARTESCA-2572-handle-unauthorized-error-in-the-UI and the
merge is not possible until all related w/* branches are deleted or updated.

Please use the reset command to have me reinitialize these branches.

@ChengYanJin
Copy link
Contributor Author

/reset

@bert-e
Copy link
Contributor

bert-e commented Dec 20, 2021

Reset complete

I have successfully deleted this pull request's integration branches.

@bert-e
Copy link
Contributor

bert-e commented Dec 20, 2021

Integration data created

I have created the integration data for the additional destination branches.

The following branches will NOT be impacted:

  • development/2.0
  • development/2.1
  • development/2.10
  • development/2.2
  • development/2.3
  • development/2.4
  • development/2.5
  • development/2.6
  • development/2.7
  • development/2.8
  • development/2.9

You can set option create_pull_requests if you need me to create
integration pull requests in addition to integration branches, with:

@bert-e create_pull_requests

@bert-e
Copy link
Contributor

bert-e commented Dec 20, 2021

Waiting for approval

The following approvals are needed before I can proceed with the merge:

  • the author

  • one peer

Peer approvals must include at least 1 approval from the following list:

1 similar comment
@bert-e
Copy link
Contributor

bert-e commented Dec 20, 2021

Waiting for approval

The following approvals are needed before I can proceed with the merge:

  • the author

  • one peer

Peer approvals must include at least 1 approval from the following list:

@ChengYanJin
Copy link
Contributor Author

/status

@bert-e
Copy link
Contributor

bert-e commented Dec 21, 2021

Status

Status report is not available.

@bert-e
Copy link
Contributor

bert-e commented Dec 21, 2021

Waiting for approval

The following approvals are needed before I can proceed with the merge:

  • the author

  • one peer

Peer approvals must include at least 1 approval from the following list:

@ChengYanJin
Copy link
Contributor Author

/approve

@bert-e
Copy link
Contributor

bert-e commented Dec 22, 2021

In the queue

The changeset has received all authorizations and has been added to the
relevant queue(s). The queue(s) will be merged in the target development
branch(es) as soon as builds have passed.

The changeset will be merged in:

  • ✔️ development/2.11

  • ✔️ development/123.0

The following branches will NOT be impacted:

  • development/2.0
  • development/2.1
  • development/2.10
  • development/2.2
  • development/2.3
  • development/2.4
  • development/2.5
  • development/2.6
  • development/2.7
  • development/2.8
  • development/2.9

There is no action required on your side. You will be notified here once
the changeset has been merged. In the unlikely event that the changeset
fails permanently on the queue, a member of the admin team will
contact you to help resolve the matter.

IMPORTANT

Please do not attempt to modify this pull request.

  • Any commit you add on the source branch will trigger a new cycle after the
    current queue is merged.
  • Any commit you add on one of the integration branches will be lost.

If you need this pull request to be removed from the queue, please contact a
member of the admin team now.

The following options are set: approve

@bert-e
Copy link
Contributor

bert-e commented Dec 22, 2021

I have successfully merged the changeset of this pull request
into targetted development branches:

  • ✔️ development/2.11

  • ✔️ development/123.0

The following branches have NOT changed:

  • development/2.0
  • development/2.1
  • development/2.10
  • development/2.2
  • development/2.3
  • development/2.4
  • development/2.5
  • development/2.6
  • development/2.7
  • development/2.8
  • development/2.9

Please check the status of the associated issue ARTESCA-2572.

Goodbye chengyanjin.

@bert-e bert-e merged commit c010477 into development/2.11 Dec 22, 2021
@bert-e bert-e deleted the bugfix/ARTESCA-2572-handle-unauthorized-error-in-the-UI branch December 22, 2021 11:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants