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

http-gateway/web: Added handling for error 401 (Unauthorized) #1330

Merged
merged 4 commits into from
Jun 3, 2024

Conversation

PatrikMatiasko
Copy link
Contributor

@PatrikMatiasko PatrikMatiasko commented Jun 3, 2024

This PR introduces a mechanism to handle HTTP 401 (Unauthorized) errors by automatically logging out the user. When a 401 error is encountered during any request, the system will now log out the user and redirect them to the login page, ensuring that they are aware of the need to reauthenticate.

@PatrikMatiasko PatrikMatiasko requested a review from jkralik June 3, 2024 09:05
@PatrikMatiasko PatrikMatiasko self-assigned this Jun 3, 2024
Copy link
Contributor

coderabbitai bot commented Jun 3, 2024

Walkthrough

This update primarily addresses typo corrections in function calls, ensuring the correct methods are invoked throughout the codebase. Additionally, it introduces the unauthorizedCallback parameter in various API calls and functions, enhancing the security and error-handling mechanisms. The Config struct in the security module also sees the addition of an EndSessionEndpoint field, improving session management capabilities.

Changes

Files/Paths Change Summary
http-gateway/web/packages/shared-ui Updated subproject commit hash.
http-gateway/web/src/containers/App/App.tsx Corrected typo in function call from security.setWellKnowConfig to security.setWellKnownConfig.
http-gateway/web/src/containers/App/AppInner/AppInner.tsx Added useCallback, WellKnownConfigType, and isFunction imports. Introduced unauthorizedCallback and added it to contextValue dependencies.
http-gateway/web/src/containers/App/AppLayout/AppLayout.tsx Corrected typo in function call from security.getWellKnowConfig to security.getWellKnownConfig.
http-gateway/web/src/containers/Certificates/hooks.ts Added unauthorizedCallback to useContext and useStreamApi calls. Corrected function name from getWellKnow to getWellKnown.
http-gateway/web/src/containers/Certificates/rest.ts Corrected function name from getWellKnow to getWellKnown.
http-gateway/web/src/containers/DeviceProvisioning/EnrollmentGroups/NewEnrollmentGroupsPage/... Corrected typo in function call from getWellKnowConfig to getWellKnownConfig.
http-gateway/web/src/containers/DeviceProvisioning/LinkedHubs/DetailHeader/DetailHeader.tsx Modified deleteInformation array in DeleteModal component to remove an item with a placeholder value.
http-gateway/web/src/containers/DeviceProvisioning/ProvisioningRecords/DetailPage/Tabs/Tab2... Corrected typo in function call from security.getWellKnowConfig to security.getWellKnownConfig.
http-gateway/web/src/containers/DeviceProvisioning/hooks.ts Renamed getWellKnow to getWellKnown. Added unauthorizedCallback to context and API calls.
http-gateway/web/src/containers/Devices/Detail/DevicesDetailsPage/DevicesDetailsPage.tsx Corrected typo in function call from security.getWellKnowConfig to security.getWellKnownConfig.
http-gateway/web/src/containers/Devices/Detail/DevicesDetailsPage/Tabs/Tab2/Tab2.tsx Corrected typo in function call from getWellKnowConfig to getWellKnownConfig.
http-gateway/web/src/containers/Devices/List/ProvisionNewDevice/ProvisionNewDevice.tsx Corrected typo in function call from getWellKnowConfig to getWellKnownConfig.
http-gateway/web/src/containers/Devices/hooks.ts Added unauthorizedCallback to multiple functions and API calls. Corrected function name from getWellKnow to getWellKnown.
http-gateway/web/src/containers/Devices/rest.ts Added unauthorizedCallback to various API calls.
pkg/security/openid/config.go Added EndSessionEndpoint field to Config struct.
test/oauth-server/service/getOpenIDConfiguration.go Included EndSessionEndpoint in openid.Config struct.
test/oauth-server/service/logOut.go Enhanced logOut function to handle different HTTP methods for determining the redirect URI.
test/oauth-server/uri/uri.go Added new constant PostLogoutRedirectURIKey.

Poem

In code, we found a typo's lair,
Corrected paths with utmost care.
WellKnown now stands in place,
Security's call, a smoother grace.
Endpoints end, sessions close,
With callbacks, our code now glows.
A rabbit's joy in changes made,
In every line, our craft displayed.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@PatrikMatiasko PatrikMatiasko changed the title Pm/error 401 handling Added handling for error 401 (Unauthorized) by logging out the user for all requests Jun 3, 2024
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Outside diff range and nitpick comments (11)
http-gateway/web/src/containers/Devices/List/ProvisionNewDevice/ProvisionNewDevice.tsx (1)

Line range hint 32-32: Specify explicit types instead of using any.

- const handleFetch = async () => {
+ const handleFetch = async (): Promise<void> => {
- const { providerName } = (security.getDeviceOAuthConfig() as any) || {}
+ const { providerName } = (security.getDeviceOAuthConfig() as Record<string, any>) || {}

Using explicit types instead of any improves type safety and code maintainability.

Also applies to: 63-63

Tools
Biome

[error] 63-63: Unexpected any. Specify a different type.

http-gateway/web/src/containers/DeviceProvisioning/EnrollmentGroups/NewEnrollmentGroupsPage/NewEnrollmentGroupsPage.tsx (1)

Line range hint 28-28: Specify explicit types instead of using any.

- const NewEnrollmentGroupsPage: FC<any> = () => {
+ const NewEnrollmentGroupsPage: FC<Props> = () => {
- const defaultFormData = {
+ const defaultFormData: FormData = {
- const onSubmit = async () => {
+ const onSubmit = async (): Promise<void> => {
- const context = useMemo(
+ const context: FormContextType = useMemo(

Using explicit types instead of any improves type safety and code maintainability.

Also applies to: 65-65, 94-94, 110-110

http-gateway/web/src/containers/Devices/hooks.ts (1)

Line range hint 26-26: Specify explicit types instead of using any.

- const useEmitter(DEVICES_STATUS_WS_KEY, (newDeviceData: any) => {
+ const useEmitter(DEVICES_STATUS_WS_KEY, (newDeviceData: DeviceDataType) => {

Using explicit types instead of any improves type safety and code maintainability.

http-gateway/web/src/containers/App/App.tsx (1)

Line range hint 31-31: Specify explicit types instead of using any.

- const [wellKnownConfig, setWellKnownConfig] = useState<any>(null)
+ const [wellKnownConfig, setWellKnownConfig] = useState<WellKnownConfigType | null>(null)
- const [configError, setConfigError] = useState<any>(null)
+ const [configError, setConfigError] = useState<Error | null>(null)
- const Wrapper = (child: any) => (
+ const Wrapper = (child: ReactNode) => (

Using explicit types instead of any improves type safety and code maintainability.

Also applies to: 33-33, 119-119

http-gateway/web/src/containers/Devices/Detail/DevicesDetailsPage/DevicesDetailsPage.tsx (5)

Line range hint 168-168: Remove the non-null assertion to prevent potential runtime errors.

- const { data } = await updateDevicesResourceApi({ deviceId: id, href: href!, ttl }, { n: name });
+ const { data } = await updateDevicesResourceApi({ deviceId: id, href: href, ttl }, { n: name });

Ensure that href is checked for null or undefined before this call.


Line range hint 71-71: Adjust the dependencies of the useEffect hook to match its actual usage.

- }, [data, loading])
+ }, [data?.metadata?.twinEnabled])

This change ensures that the hook only re-runs when data.metadata.twinEnabled changes, which is the only piece of data it uses.


Line range hint 78-78: Include all relevant dependencies in the useEffect hook.

- }, [])
+ }, [refresh])

This ensures that the hook correctly responds to changes in the refresh function, maintaining the integrity of the component's reactive behavior.


Line range hint 87-87: Ensure all dependencies are specified in the useCallback hook.

- }, [id])
+ }, [id, navigate, refreshPendingCommands, refreshSoftwareUpdate])

This change ensures that the hook is correctly memoized and only re-computed when any of the specified dependencies change.


Line range hint 1-1: Use import type for imports that are only used as types.

- import { FC, lazy, useCallback, useEffect, useState } from 'react'
+ import type { FC } from 'react'
+ import { lazy, useCallback, useEffect, useState } from 'react'

This change clarifies that these imports are used for type checking only and may help optimize bundling by potentially excluding them from the runtime bundle.

Also applies to: 6-7, 14-15, 30-31

http-gateway/web/src/containers/Devices/Detail/DevicesDetailsPage/Tabs/Tab2/Tab2.tsx (2)

Line range hint 239-239: Specify a more precise type instead of any.

Using any can lead to potential type safety issues. It would be beneficial to define a more specific type for resourceDataUpdate to enhance code robustness and maintainability.


Line range hint 1-1: Optimize type-only imports.

Consider consolidating all type-only imports using the type keyword to clarify that they are not used at runtime. This can help clean up the import statements and make the codebase more maintainable.

- import { FC, useEffect, useMemo, useState } from 'react'
+ import type { FC } from 'react'
+ import { useEffect, useMemo, useState } from 'react'

- import { useIsMounted, WellKnownConfigType } from '@shared-ui/common/hooks'
+ import type { WellKnownConfigType } from '@shared-ui/common/hooks'
+ import { useIsMounted } from '@shared-ui/common/hooks'

- import {
-     DevicesDetailsResourceModalData,
-     DevicesResourcesModalParamsType,
- } from '@shared-ui/components/Organisms/DevicesResourcesModal/DevicesResourcesModal.types'
+ import type {
+     DevicesDetailsResourceModalData,
+     DevicesResourcesModalParamsType,
+ } from '@shared-ui/components/Organisms/DevicesResourcesModal/DevicesResourcesModal.types'

Also applies to: 5-6, 10-14, 17-18, 19-20

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 18ec69a and 62fe9ad.

Files selected for processing (20)
  • http-gateway/web/packages/shared-ui (1 hunks)
  • http-gateway/web/src/containers/App/App.tsx (1 hunks)
  • http-gateway/web/src/containers/App/AppInner/AppInner.tsx (5 hunks)
  • http-gateway/web/src/containers/App/AppLayout/AppLayout.tsx (1 hunks)
  • http-gateway/web/src/containers/Certificates/hooks.ts (1 hunks)
  • http-gateway/web/src/containers/Certificates/rest.ts (1 hunks)
  • http-gateway/web/src/containers/DeviceProvisioning/EnrollmentGroups/NewEnrollmentGroupsPage/NewEnrollmentGroupsPage.tsx (1 hunks)
  • http-gateway/web/src/containers/DeviceProvisioning/LinkedHubs/DetailHeader/DetailHeader.tsx (1 hunks)
  • http-gateway/web/src/containers/DeviceProvisioning/ProvisioningRecords/DetailPage/Tabs/Tab2/Tab2.tsx (1 hunks)
  • http-gateway/web/src/containers/DeviceProvisioning/ProvisioningRecords/DetailPage/Tabs/Tab3/Tab3.tsx (1 hunks)
  • http-gateway/web/src/containers/DeviceProvisioning/hooks.ts (16 hunks)
  • http-gateway/web/src/containers/DeviceProvisioning/rest.ts (8 hunks)
  • http-gateway/web/src/containers/Devices/Detail/DevicesDetailsPage/DevicesDetailsPage.tsx (1 hunks)
  • http-gateway/web/src/containers/Devices/Detail/DevicesDetailsPage/Tabs/Tab2/Tab2.tsx (1 hunks)
  • http-gateway/web/src/containers/Devices/List/ProvisionNewDevice/ProvisionNewDevice.tsx (1 hunks)
  • http-gateway/web/src/containers/Devices/hooks.ts (4 hunks)
  • http-gateway/web/src/containers/Devices/rest.ts (8 hunks)
  • http-gateway/web/src/containers/PendingCommands/hooks.ts (1 hunks)
  • http-gateway/web/src/containers/PendingCommands/rest.ts (1 hunks)
  • http-gateway/web/src/containers/RemoteClients/RemoteClientsPage/RemoteClientsPage.tsx (2 hunks)
Files skipped from review due to trivial changes (1)
  • http-gateway/web/packages/shared-ui
Additional context used
Biome
http-gateway/web/src/containers/Certificates/rest.ts

[error] 6-7: All these imports are only used as types.

http-gateway/web/src/containers/PendingCommands/rest.ts

[error] 4-5: All these imports are only used as types.

http-gateway/web/src/containers/Certificates/hooks.ts

[error] 6-7: All these imports are only used as types.

http-gateway/web/src/containers/PendingCommands/hooks.ts

[error] 8-9: All these imports are only used as types.

http-gateway/web/src/containers/App/AppInner/AppInner.tsx

[error] 55-70: This else clause can be omitted because previous branches break early.


[error] 7-8: Some named imports are only used as types.


[error] 9-10: All these imports are only used as types.


[error] 14-15: All these imports are only used as types.

http-gateway/web/src/containers/DeviceProvisioning/LinkedHubs/DetailHeader/DetailHeader.tsx

[error] 46-46: Unexpected any. Specify a different type.


[error] 1-1: Some named imports are only used as types.


[error] 10-11: All these imports are only used as types.


[error] 29-29: This hook does not specify all of its dependencies: _


[error] 29-29: This hook does not specify all of its dependencies: navigate

http-gateway/web/src/containers/Devices/List/ProvisionNewDevice/ProvisionNewDevice.tsx

[error] 32-32: Unexpected any. Specify a different type.


[error] 63-63: Unexpected any. Specify a different type.

http-gateway/web/src/containers/DeviceProvisioning/EnrollmentGroups/NewEnrollmentGroupsPage/NewEnrollmentGroupsPage.tsx

[error] 28-28: Unexpected any. Specify a different type.


[error] 65-65: Unexpected any. Specify a different type.


[error] 94-94: Unexpected any. Specify a different type.


[error] 110-110: Unexpected any. Specify a different type.


[error] 1-1: Some named imports are only used as types.


[error] 12-13: All these imports are only used as types.


[error] 33-33: This hook does not specify all of its dependencies: _


[error] 107-107: This hook does not specify all of its dependencies: _


[error] 107-107: This hook does not specify all of its dependencies: onSubmit


[error] 107-107: This hook does not specify all of its dependencies: onStepChange


[error] 107-107: This hook does not specify all of its dependencies: setFormData

http-gateway/web/src/containers/DeviceProvisioning/ProvisioningRecords/DetailPage/Tabs/Tab3/Tab3.tsx

[error] 22-22: Unexpected any. Specify a different type.


[error] 29-29: Unexpected any. Specify a different type.


[error] 30-30: Do not access Object.prototype method 'hasOwnProperty' from target object.


[error] 35-45: This else clause can be omitted because previous branches break early.


[error] 35-35: Do not access Object.prototype method 'hasOwnProperty' from target object.


[error] 40-45: This else clause can be omitted because previous branches break early.


[error] 40-40: Do not access Object.prototype method 'hasOwnProperty' from target object.


[error] 51-51: Unexpected any. Specify a different type.


[error] 1-1: Some named imports are only used as types.


[error] 10-11: All these imports are only used as types.


[error] 14-15: All these imports are only used as types.


[error] 28-28: This hook does not specify all of its dependencies: _


[error] 56-56: This hook does not specify all of its dependencies: _


[error] 56-56: This hook does not specify all of its dependencies: data.enrollmentGroupData?.hubsData


[error] 56-56: This hook does not specify all of its dependencies: wellKnownConfig.id


[error] 56-56: This hook does not specify all of its dependencies: data.deviceId


[error] 56-56: This hook does not specify all of its dependencies: data.ownership.owner

http-gateway/web/src/containers/DeviceProvisioning/rest.ts

[error] 136-136: Unexpected any. Specify a different type.


[error] 151-151: Unexpected any. Specify a different type.


[error] 5-6: All these imports are only used as types.


[error] 7-8: All these imports are only used as types.

http-gateway/web/src/containers/Devices/hooks.ts

[error] 26-26: Unexpected any. Specify a different type.


[error] 91-109: Prefer for...of instead of forEach.


[error] 10-11: All these imports are only used as types.

http-gateway/web/src/containers/App/App.tsx

[error] 31-31: Unexpected any. Specify a different type.


[error] 33-33: Unexpected any. Specify a different type.


[error] 61-71: This else clause can be omitted because previous branches break early.


[error] 119-119: Unexpected any. Specify a different type.


[error] 25-26: All these imports are only used as types.

http-gateway/web/src/containers/RemoteClients/RemoteClientsPage/RemoteClientsPage.tsx

[error] 96-96: Forbidden non-null assertion.


[error] 151-163: This else clause can be omitted because previous branches break early.


[error] 184-191: This else clause can be omitted because previous branches break early.


[error] 1-1: Some named imports are only used as types.


[error] 5-6: Some named imports are only used as types.


[error] 14-15: All these imports are only used as types.


[error] 16-17: All these imports are only used as types.

http-gateway/web/src/containers/Devices/rest.ts

[error] 86-86: Unexpected any. Specify a different type.


[error] 88-88: Unexpected any. Specify a different type.


[error] 118-118: Unexpected any. Specify a different type.


[error] 120-120: Unexpected any. Specify a different type.


[error] 142-142: Unexpected any. Specify a different type.


[error] 199-199: Unexpected any. Specify a different type.


[error] 8-9: All these imports are only used as types.

http-gateway/web/src/containers/DeviceProvisioning/ProvisioningRecords/DetailPage/Tabs/Tab2/Tab2.tsx

[error] 25-25: Unexpected any. Specify a different type.


[error] 30-30: Unexpected any. Specify a different type.


[error] 31-31: Unexpected any. Specify a different type.


[error] 59-59: Unexpected any. Specify a different type.


[error] 81-81: Unexpected any. Specify a different type.


[error] 138-138: Unexpected any. Specify a different type.


[error] 1-1: Some named imports are only used as types.


[error] 11-12: All these imports are only used as types.


[error] 31-31: Don't use '{}' as a type.


[error] 44-44: This hook does not specify all of its dependencies: _


[error] 46-46: Don't use '{}' as a type.


[error] 53-53: This hook does not specify all of its dependencies: _


[error] 65-65: This hook does not specify all of its dependencies: _


[error] 94-94: This hook does not specify all of its dependencies: _


[error] 94-94: This hook does not specify all of its dependencies: handleViewCert


[error] 94-94: This hook specifies more dependencies than necessary: certData

http-gateway/web/src/containers/DeviceProvisioning/hooks.ts

[error] 15-15: Unexpected any. Specify a different type.


[error] 26-26: Unexpected any. Specify a different type.


[error] 52-52: Unexpected any. Specify a different type.


[error] 74-74: Unexpected any. Specify a different type.


[error] 101-101: Change to an optional chain.


[error] 132-132: Unexpected any. Specify a different type.


[error] 151-151: Do not use template literals if interpolation and special-character handling are not needed.


[error] 158-158: Unexpected any. Specify a different type.


[error] 160-160: Unexpected any. Specify a different type.


[error] 191-191: Change to an optional chain.


[error] 6-7: All these imports are only used as types.


[error] 215-215: This hook does not specify all of its dependencies: formatPSK

http-gateway/web/src/containers/App/AppLayout/AppLayout.tsx

[error] 113-113: Unexpected any. Specify a different type.


[error] 161-161: JSX elements without children should be marked as self-closing. In JSX, it is valid for any element to be self-closing.


[error] 170-170: Unexpected any. Specify a different type.


[error] 244-244: The computed expression can be simplified without the use of a string literal.


[error] 244-244: Do not use template literals if interpolation and special-character handling are not needed.


[error] 1-1: Some named imports are only used as types.


[error] 14-15: All these imports are only used as types.


[error] 21-22: All these imports are only used as types.


[error] 23-24: Some named imports are only used as types.


[error] 27-28: All these imports are only used as types.


[error] 33-34: All these imports are only used as types.


[error] 99-99: This hook does not specify all of its dependencies: _


[error] 115-115: This hook does not specify all of its dependencies: dispatch


[error] 115-115: This hook does not specify all of its dependencies: storedRemoteStore.remoteClients.length


[error] 115-115: This hook does not specify all of its dependencies: mockApp


[error] 115-115: This hook does not specify all of its dependencies: storedRemoteStore.remoteClients.map

http-gateway/web/src/containers/Devices/Detail/DevicesDetailsPage/DevicesDetailsPage.tsx

[error] 168-168: Forbidden non-null assertion.


[error] 1-1: Some named imports are only used as types.


[error] 6-7: Some named imports are only used as types.


[error] 14-15: All these imports are only used as types.


[error] 30-31: All these imports are only used as types.


[error] 71-71: This hook does not specify all of its dependencies: isTwinEnabled


[error] 71-71: This hook specifies more dependencies than necessary: loading


[error] 78-78: This hook does not specify all of its dependencies: refresh


[error] 87-87: This hook does not specify all of its dependencies: navigate


[error] 87-87: This hook does not specify all of its dependencies: refreshPendingCommands


[error] 87-87: This hook does not specify all of its dependencies: refreshSoftwareUpdate

http-gateway/web/src/containers/Devices/Detail/DevicesDetailsPage/Tabs/Tab2/Tab2.tsx

[error] 239-239: Unexpected any. Specify a different type.


[error] 1-1: Some named imports are only used as types.


[error] 5-6: Some named imports are only used as types.


[error] 10-14: All these imports are only used as types.


[error] 17-18: All these imports are only used as types.


[error] 19-20: All these imports are only used as types.

Additional comments not posted (20)
http-gateway/web/src/containers/Certificates/rest.ts (1)

11-11: Corrected function name typo from getWellKnow to getWellKnown.

http-gateway/web/src/containers/PendingCommands/rest.ts (1)

14-14: Added unauthorizedCallback to enhance security handling in API calls.

Also applies to: 20-20, 27-27

http-gateway/web/src/containers/Certificates/hooks.ts (1)

14-14: Added unauthorizedCallback to enhance security handling in hook calls.

Also applies to: 20-20, 25-25, 31-31

http-gateway/web/src/containers/PendingCommands/hooks.ts (1)

15-15: Added unauthorizedCallback to enhance security handling in hook calls.

Also applies to: 22-22

http-gateway/web/src/containers/App/AppInner/AppInner.tsx (1)

30-36: Added and utilized unauthorizedCallback to enhance security handling in the application context.

Also applies to: 46-48, 65-69

http-gateway/web/src/containers/DeviceProvisioning/LinkedHubs/DetailHeader/DetailHeader.tsx (1)

72-72: Simplified the deleteInformation array in the DeleteModal component to streamline the deletion information presented to the user.

http-gateway/web/src/containers/Devices/List/ProvisionNewDevice/ProvisionNewDevice.tsx (1)

62-62: Correct usage of getWellKnownConfig function.

This change correctly updates the function call to use the proper function name, ensuring the correct configuration is retrieved.

http-gateway/web/src/containers/DeviceProvisioning/EnrollmentGroups/NewEnrollmentGroupsPage/NewEnrollmentGroupsPage.tsx (1)

55-55: Correct usage of getWellKnownConfig function.

This change correctly updates the function call to use the proper function name, ensuring the correct configuration is retrieved.

http-gateway/web/src/containers/DeviceProvisioning/ProvisioningRecords/DetailPage/Tabs/Tab3/Tab3.tsx (1)

24-24: Correct usage of getWellKnownConfig function.

This change correctly updates the function call to use the proper function name, ensuring the correct configuration is retrieved.

http-gateway/web/src/containers/DeviceProvisioning/rest.ts (1)

14-14: Addition of unauthorizedCallback to API calls.

This change enhances security by ensuring that unauthorized access is handled consistently across all API calls.

Also applies to: 24-24, 48-48, 56-56, 66-66, 76-76, 88-88, 98-98, 108-108, 115-115, 123-123, 130-130, 138-138, 145-145, 153-153, 160-160

http-gateway/web/src/containers/Devices/hooks.ts (1)

17-17: Addition of unauthorizedCallback to hooks.

This change enhances security by ensuring that unauthorized access is handled consistently across all hooks.

Also applies to: 22-22, 38-38, 43-43, 70-70, 75-75, 80-80, 83-83, 119-119, 123-123, 128-128, 133-133, 138-138, 146-146

http-gateway/web/src/containers/App/App.tsx (1)

67-67: Correct usage of setWellKnownConfig function.

This change correctly updates the function call to use the proper function name, ensuring the correct configuration is set.

http-gateway/web/src/containers/RemoteClients/RemoteClientsPage/RemoteClientsPage.tsx (2)

29-29: Corrected function name to getWellKnownConfig.

This change corrects the typo in the function name, ensuring the correct function is called.


152-152: Added unauthorizedCallback to the setWellKnownConfig call.

This addition enhances security by handling unauthorized access scenarios more robustly.

http-gateway/web/src/containers/Devices/rest.ts (1)

17-17: Added unauthorizedCallback to API calls.

This addition is consistent across multiple API functions, enhancing security by handling unauthorized scenarios uniformly.

Also applies to: 34-34, 59-59, 91-91, 123-123, 144-144, 165-165

http-gateway/web/src/containers/DeviceProvisioning/ProvisioningRecords/DetailPage/Tabs/Tab2/Tab2.tsx (1)

40-40: Corrected function name to getWellKnownConfig.

This change corrects the typo in the function name, ensuring the correct function is called.

http-gateway/web/src/containers/DeviceProvisioning/hooks.ts (1)

12-12: Added unauthorizedCallback to various hooks.

This addition enhances security by handling unauthorized scenarios uniformly across multiple hooks.

Also applies to: 23-23, 36-36, 46-46, 71-71, 85-85, 98-98, 110-110, 129-129, 142-142, 152-152, 175-175, 188-188, 200-200, 234-234, 240-240, 245-245, 254-254

http-gateway/web/src/containers/App/AppLayout/AppLayout.tsx (1)

50-50: Corrected function name to getWellKnownConfig.

This change corrects the typo in the function name, ensuring the correct function is called.

http-gateway/web/src/containers/Devices/Detail/DevicesDetailsPage/DevicesDetailsPage.tsx (1)

60-60: Correct the typo in the function call to enhance code accuracy.

This change corrects the previously incorrect function call from getWellKnowConfig to getWellKnownConfig, aligning with the correct function name and ensuring the proper functionality is invoked.

http-gateway/web/src/containers/Devices/Detail/DevicesDetailsPage/Tabs/Tab2/Tab2.tsx (1)

58-58: Corrected typo in function call to getWellKnownConfig.

This change ensures the correct function is invoked, aligning with the PR's objectives to fix recurring typos.

@@ -21,7 +21,7 @@ const Tab3: FC<Props> = (props) => {
const { formatMessage: _ } = useIntl()
const [displayData, setDisplayData] = useState<any>(undefined)
Copy link
Contributor

Choose a reason for hiding this comment

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

Specify explicit types instead of using any.

- const Tab3: FC<Props> = (props) => {
+ const Tab3: FC<PropsType> = (props) => {
- const getSubject = (item: any) => {
+ const getSubject = (item: SubjectType) => {
- const columns = useMemo(
+ const columns: ColumnType[] = useMemo(

Using explicit types instead of any improves type safety and code maintainability.

Also applies to: 29-29, 51-51

Tools
Biome

[error] 22-22: Unexpected any. Specify a different type.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 62fe9ad and 9f94d1b.

Files selected for processing (4)
  • pkg/security/openid/config.go (1 hunks)
  • test/oauth-server/service/getOpenIDConfiguration.go (1 hunks)
  • test/oauth-server/service/logOut.go (1 hunks)
  • test/oauth-server/uri/uri.go (1 hunks)
Files skipped from review due to trivial changes (2)
  • pkg/security/openid/config.go
  • test/oauth-server/uri/uri.go
Additional comments not posted (5)
test/oauth-server/service/logOut.go (4)

10-18: Handling of POST requests with form parsing and error management looks correct.


19-19: Proper handling of GET requests by retrieving the redirect URI from query parameters.


20-23: Correct implementation of default case by setting the 'Allow' header and returning a 405 status for unsupported methods.


24-28: Redirection logic correctly implemented to handle valid and empty redirect URIs.

test/oauth-server/service/getOpenIDConfiguration.go (1)

13-18: The OpenID configuration object is correctly constructed with all necessary URLs, including the newly added EndSessionEndpoint.

test/oauth-server/service/logOut.go Dismissed Show dismissed Hide dismissed
Copy link

sonarqubecloud bot commented Jun 3, 2024

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

@jkralik jkralik changed the title Added handling for error 401 (Unauthorized) by logging out the user for all requests http-gateway: Added handling for error 401 (Unauthorized) by logging out the user for all requests Jun 3, 2024
@jkralik jkralik changed the title http-gateway: Added handling for error 401 (Unauthorized) by logging out the user for all requests http-gateway/web: Added handling for error 401 (Unauthorized) Jun 3, 2024
@jkralik jkralik merged commit fd58dae into main Jun 3, 2024
33 checks passed
@jkralik jkralik deleted the pm/error-401-handling branch June 3, 2024 13:07
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.

2 participants