Commit Graph

54 Commits

Author SHA1 Message Date
Cody Jackson 468f2968fd Migrating easy to move functions out of the authenticated middleware 2024-05-23 06:43:25 -07:00
Cody Jackson 2f6d34832c Changing the way we handle redirects by two helper functions inside authenticated middleware
We didn't actually need to call redirect from the methods since the `loadingError` store action did the redirect for us.

We still need to exit early from the middleware so instead of having to check and execute a return value (that was a boolean so couldn't be executed anyway) we now just throw an exception.
2024-05-22 12:04:16 -07:00
Cody Jackson 6f7c29626c Removing the unauthenticated middleware 2024-04-30 13:36:40 -07:00
Richard Cox f5ab831f37 Changes after review 2024-03-22 15:36:55 +00:00
Richard Cox 58ee04cf23 Add e2e tests
- Test count of settings requests
  - during setup flow
  - login page
  - home page
  - login page --> home page

In addition
- Fix issue where now populated fromHeader can be `false`
- Don't mix up CATTLE_BOOTSTRAP_PASSWORD and TEST_PASSWORD, this causes issues in the setup flow when they're different
- Refactor setup test, re-enable check at end
2024-02-29 17:31:20 +00:00
Richard Cox 097a220225 Fix new, revealed issues. See PR for description 2024-02-29 17:30:26 +00:00
Richard Cox 582ba19ae4 Remove duplicate calls to mgmt settings on fresh load
- when findAll runs we cache running results with key `JSON.stringify(headers) + method + opt.url`
- if a request is made with a matching key we return the first result as the second result (avoiding duplicate requests)
- when mgmt settings were fetched with a hardcoded url ... url contains singular `setting`
- when mgmt settings are fetched without hardcoded url ... url contains plural `settings`
- therefore the second request was not using the cached first request

Also
- replaced findBy with .find
2024-02-29 17:30:26 +00:00
Richard Cox b464d15ee0
Integrate new schemaDefinitions endpoint (#10141)
* resource edit AS yaml

* fix cruresource (yaml from form)
- lazy load the schemaDefinitions when needed, avoids sync all to createYaml before we have an async chance to fetch schemaDefinitions

* Fix questions
- there are only four places we use questions, none of which use schema, this is just to be safe

* cluster scan, plugins/fieldsForDriver, defaultFor, validationErrors

* pathExistsInSchema
- used to optionally show conditions tab/list in resource detail view
- logs of things in ingress list/edit

* createPopulated / defaultFor
defaultFor requires resourceFields, it's only used by createPopulated in one place to support machine configs without components

* wip

* WIP MONITORING.SPOOFED
- these aren't spoofed types, but secondary schemas
- testing fix blocked, primary schema's have resourceFields

* Move steve specific (resourceField) code to steve models
- create models for steve schemas and apply to cluster and management stores
- move resoureField based validationto steve model
- move pathExistsInSchema to steve store getter
- don't fetch schemaDefinitions on start up when saving prefs (not needed and blocking)

* comments / improvements

* (untested) refactoring

* Fix alertmanager definitions, add retry definition fetch

* Fix pathExistsInSchema for path length > 2

* Fix questions that accept schemas
- tested by adding Questions to random page and the node schema

* Fix to saving configmap part 1
- the save works but doesn't show data. the yaml is the same as before. debug info added

* Validation by resourceFields is a norman specific thing, so make it such

* small refactor

* Tidying up

* Remove rebase junk

* fix linting and unit tests

* fix unit tests

* fix linting from fix for test....

* Tidying up, fix alertmanagerconfig

* Remove unit test todos

* add unit tests for resource fields

* sdssdf

* Add unit tests for pathExistsInSchema

* JS --> TS

* Store schemas in local singleton cache to avoid hitting store

* fix minor changes from review

* cruresource changes following review
- improvement - remove spurious canDiff
- createResourceYaml - pass in resource to use instead of calc in code

* WIP changes to parseType

* Fix generic cloud credential and node driver forms

* handle missing reactivity given schema definitions not in store

* fix and add unit tests for `parseType`

* Fix create-yaml test

* Changes following review
- improved comments
- SchemaDefinitionCache is now per store (and is reset as such)
- typeRef now uses parseType

* Fix dep loop by moving route based helps in auth out to utils file

* fix unit tests

* Changes following review
2024-02-28 17:08:35 +00:00
Cody Jackson 0cb47c5c97 Removal a small chunk of code that doesn't preform any authentication from the authenticated middleware 2024-02-21 14:53:23 -07:00
Alexandre Alves 6637583874
remove "process." mentions from Dashboard and adjust code (#10119)
* remove process.client and process.server mentions and adjust code

* fix a couple of missing conditions for process.server

* remove commented line

* remove process.static

* fix lint errors

* uncomment code

---------

Co-authored-by: Alexandre Alves <aalves@Alexandres-MacBook-Pro.local>
2023-12-13 08:41:26 +00:00
Richard Cox 8fdadee8e3 Allow extentions to redirect the user to another location if authentication fails
- if entering the product, loading cluster, etc fails extensions can now throw a `RedirectToError` error
- this avoids the user being redirect to the dashboard home or fail-whale page
- example - epinio auth fails and we want to return user to the epinio cluster list

In theory we should be able to to instanceof with something that extends error and has a `name`,
unfortunately this does not work, so gone for something more manual.

Also bump shell so we can publish a new version
2023-10-17 18:47:21 +01:00
Richard Cox c689588d31 Fix import 2023-08-22 18:36:05 +01:00
Richard Cox 4b8e30cdae Wire in canViewResourceto the check in authenticated 2023-08-22 17:16:44 +01:00
Nancy 456f7133c1
check mgmt store and norman store before throwing resource not found (#9380)
* check mgmt store and norman store before throwing resource not found

* Final attempt at fixing resource check in authentication middleware
- Some resource pages don't use the product's store. This happens when..
  - the product changes the store type of a resource via product config `typeStoreMap`
    - explorer project, cluster binding and project binding pages
  - the resource detail / list overrides the store directly with store-override
    - create api key (this isn't in the product / type / id world though)
    - cloud credential create / edit / view
- To fix this
  - ensure we use the correct getter to fetch the store a resource might be in
    - covers typeStoreMap case
  - avoid using `store-override` param for resouces in product/ type / id world
    - covers cloud cred world (use correct typeStoreMap) instead
    - also maake sure we use resourceoverride to get the correct store for a resource
- I'm trying to make sure we support the generic case to avoid breaking extensions which would use the generic inStore toolset
- If this fix doesn't work, we should remove all checks for resources from authentication and instead return to checking for the resource type in resource list & detail components


Tested user with project role in downstream cluster
- cluster instance create / view
- cluster project list & view (saves will fail due to permissions, but screens are ok)
- cluster membership tab (and add page), project membership tab
- cloud creds list, create (and cancel), edit
- places that use resource-override
  - create api key, auth config, monitoring resources
- refresh on all of above

---------

Co-authored-by: Richard Cox <richard.cox@suse.com>
2023-07-20 13:29:55 -07:00
Richard Cox 40eb8d5d93 Fix lint 2023-07-17 15:03:57 +01:00
Richard Cox 97b07e9760 Improve fix
- We don't need to check management and rancher stores, just the current store
- We need to ensure that the product has been correctly set to get it's current store
- Also check that schemaFor exists, to cover exension cases
- replace workaround for workload type with a check for virtual types
  - note - spoofed types have schemas
- add additional e2e tests for other troublesome areas
2023-07-17 13:51:53 +01:00
Nancy Butler 24483f911f check for schema in relevant cluster store in auth middleware before reporting that the schema was not found 2023-07-14 14:55:12 -07:00
Alexandre Alves 01ae80cd88
working on making sure we show a 404 page with a proper error (#8927)
* working on making sure we show a 404 page with a proper error

* code cleanup + add logic to capture 404s for resource instance details

* add e2e tests

* address PR comments + adjust e2e tests

* cover 404 on cluster for dynamic plugins

* address PR comments

* catching bogus resources on authenticated middleware with redirect to 404 page

* fix lint issue

* address PR comments + fix issue with e2e tests

* Fix l10n
- Ensure error messages doesn't reference 'list' when not on a list page
- The new way the feature works means going to a list with an unknown resource results in the generic message, but this is preferably over the above

* fix e2e tests

---------

Co-authored-by: Alexandre Alves <aalves@Alexandres-MacBook-Pro.local>
Co-authored-by: Alexandre Alves <aalves@Alexandres-MBP.lan>
Co-authored-by: Richard Cox <richard.cox@suse.com>
2023-07-13 15:01:14 +01:00
Giuseppe Leo 01eeb0548f
Add recommended lint rules globally (#8997)
* Update configuration

* Create default config for eslint

* Restore plugin:vue/recommended

* Add exceptions and overrides

* Correct manually remaining issues

* Adding further picked exceptions groupped up

* Fix or disable specific cases manually and singularly

* Add naming linting exception

* Remove unused variable in component

* Move rules to default

* Autocorrect rancher/components linting issues

* Configure VSCode to use multiple files, to display linting for rancher components

* Disable jest lint hook restriction for string list component

* Autofix
2023-06-23 17:02:55 +02:00
wujun 717a2b2c14
HARVESTER: add bare-metal container and mcm support (#8754)
* HARVESTER: add bare-metal container and mcm support

* Harvester: Fix re-render old route component

* HARVESTER: fix services and hide repositories

* HARVESTER: add svg icon

* HARVESTER: add harvester version in explorer page

* HARVESTER: change openRancherManagerSupport => isRancherInHarvester

* HARVESTER: move method to models type

* HARVESTER: enhancement TopLevelMenu when use embedded rancher

* HARVESTER: polish harvester mode judgment

* HARVESTER: Add namespace resource quota help text

* HARVESTER: remove service filter

* HARVESTER: set harvester-baremetal-container-workload to false

* HARVESTER: fix svg & namespace component

---------

Co-authored-by: n313893254 <n313893254@126.com>
2023-06-15 13:28:08 -07:00
Shavindra 1c88aa9f8c
Handle Stringified Error Messages. (#9036)
* Update error handler to handle stringified JSON.
2023-06-05 19:31:09 +02:00
Neil MacDougall 7768dabc4d
[2.7] Forward port: Fix route collisions (#8486)
* Fix route collisions with /:product routes

* Use productName

* Remove cluster id

* Fix lint
2023-03-22 16:50:36 +00:00
Richard Cox 694310352b Garbage Collect Stale Resources
Remove resources from the store if they meet certain criteria. This will reduce the memory footprint of the dashboard and load on the backend (less watchers for large collections)

- GC is disabled by default and can be enabled via the Global Settings --> Performance tab
  - User can configure
    - The age in milliseconds in which a resource has to exceed in order to be gc'd
    - The count which a resource has to exceed in order to be gc'd
- GC occures in stores that have it enabled
  - ATM this is just the `cluster` store... but could be enabled for dashboard-store's such as the harvester one (one liner plus optional `gcIgnoreTypes` override for ignoring types)
- GC will be kicked off in two cases
  - Route Change for a logged in state
  - At a given interval

- Resource type _not_ GC'd if
  - The store is ignoring the type
    - For example the `cluster` store doesn't want to gc things like `schema` and `count`
  - We're going to a page for that resource (list, detail, etc)
    - For example don't GC pods if we're going to a pods page
  - The last time the resource was accessed was recently
    - We store the resource accessed time via hooking into actions and getters
    - Setting the last accessed time will cause watchers of that type to trigger (only an issue for duplicate watchers)... but importantly not watchers of other types
  - The resource is being used in the current page/context
    - We store the route changed time and compare it to the resource accessed time
  - There's too few resources
    - We might as well keep them to avoid a network request to re-populate

// TODO:
- Should additional features be added to preferences
  - if GC on route change is enabled
  - if GC on interval is enabled, and how often it runs
- Sensible default preferences
- Remove some logging
2022-10-10 17:08:43 +01:00
Richard Cox 18b6eac18e Re-instate simpler route change handler
- my custom way no longer worked
  - for some reason checkClusterChanging wasn't firing quick enough anymore
  - the order of things looked correct (it should have disabled the outlets via clusterChanging before the auth middleware runs)
  - however the old explorer page errored when navigating to something outside of the explorer product
- beef up the simpler route change handler
  - add something to try to catch the change of product as well
  - uses similar approach, don't show anything until the store is up to date with the route
2022-09-02 17:06:02 +01:00
Richard Cox 02d9709652 Post merge fixes 2022-09-01 14:31:19 +01:00
Richard Cox b3f13843dd Merge remote-tracking branch 'origin/harvester-plugin-rebased' into test-pluginize-rc-2 2022-09-01 13:57:18 +01:00
Richard Cox 3f6df623e0 Move harvester core store to plugin, remove harvester code from authenticated flow
- harvester store is a steve store that now lives in the plugin
- harvester `loadVirtual` replaced with a shortened `loadCluster` in it's own store
- Also fix xterm css import
2022-08-25 12:26:39 +01:00
Richard Cox 4b1e0b427f Tidying up 2022-08-24 18:16:34 +01:00
Nancy Butler c1616eb3c5 fix harvester route in authenticated 2022-08-19 16:24:27 -07:00
Nancy Butler c2497df37b Revert "remove nested edit views"
This reverts commit e835835943d63e74c50942884fec3706f8703047.
2022-08-19 12:25:28 -07:00
Nancy Butler 39dbb6ef1e fix harvester pkg routing 2022-08-19 12:21:24 -07:00
Nancy Butler e10cccaf8a harvester custom routes 2022-08-19 12:20:53 -07:00
Nancy Butler a88ea801c9 routing maybe 2022-08-19 12:18:48 -07:00
Richard Cox e16ade9569 Revert changes to authentication
- previously combined request for user and principal together, instead of making them sequentially
- this should have been safe (both calls will fail or succeed given auth state)...
- ... might not be given ways requests are handled (i chickened out)
2022-08-04 16:42:20 +01:00
Richard Cox 168f809798 Improve initial load of Home and Cluster Dashboard pages
Home Page
- Don't block whole page on loading of mgmt and prov clusters
- Use table `loading` indicator when clusters are loading
- Use correct cluster count (with harv cluster filter) - To confirm

Cluster Dashboard
- EventsTable - use standard table loading indicator
- Don't block on fetch at all (or show page loading indicator)
  - Remove fetch for nodeTemplates and rke1NodePools. I went through a lot of code and don't think these are needed
  - Reminaing calls for Node and Metrics can happen at the same time
- Forget additional resource types when leaving page
- Optimise fetch of management nodes

Pre-Page optimisations
- Authentication Mixin
  - if applicable, fetch `principal` 'me' same time as `user` 'me'

Other tweaks
- Don't show AwsComplianceBanner or AzureWarning until management store ready
2022-08-04 16:42:20 +01:00
Alexandre Alves 0c1bc1ca3d
fix issue when on first login we were setting an empty value to state.workspace because user doesnt have an prefs set (#6586)
Co-authored-by: Alexandre Alves <aalves@Alexandres-MBP.lan>
2022-08-03 12:00:03 +01:00
Richard Cox ef613493f3
Merge pull request #6524 from richard-cox/fix-workspace-filtering
Fix workspace filtering
2022-07-29 15:42:25 +01:00
Qingyang Nong 3bc48b38a6
HARVESTER: Fix namespace filter wrong on Harvester page (#6523) 2022-07-29 10:41:45 +01:00
Richard Cox 0fdfd1e7f6 Fix workspace filtering
- This was broken by https://github.com/rancher/dashboard/pull/6261
- The `activeNamespaceCache` depends on the product (fleet requires workspaces, everything else namespaces)
- This needs updating when going to or from fleet

NOTE - On `head` (but not `ui-dashboard-index` `latest`) refreshing on the explorer pods page does not show the correct namespace filtered pods

Small tidyup for `activeNamespaceCache` and `activeNamespaceFilters` getters
2022-07-27 16:14:49 +01:00
Richard Cox 535e7406a0 Resolve auth middleware running multiple times on reload - caused by plugin-routes using addRoute directly on vue router - this was normally skipped as we were making changes - changes applied to a new router, vue router matcher then replaced 2022-07-13 18:32:36 +01:00
Richard Cox a819cf28f4 Fixed routing issue See description in default layout - If the cluster changes hide page content until we've reach the new page location - This resolves issues where the old page's content were showing (and in harv case throwing errors) when the cluster is changed and we haven't reached the new page yet Also - Fixed some error messages in home page given `Header` requirements - Fixed bad routes (like junk resource) when viewing plugin pages 2022-07-13 18:30:44 +01:00
Richard Cox 3e3568e1ca Fix refresh in strange cases. Redirect correctly 2022-07-13 18:30:39 +01:00
Richard Cox fe2cf50677 Multiple fixes - bring back click to go to cluster (covers case where cluster A pkg is loaded when going to cluster B pkg) - fix refresh - improve routing for cluster and virt cluster managers - improve loading of virt cluster list - add code to determine pkg version and url 2022-07-13 18:30:32 +01:00
Richard Cox 48b93be60a Allow plugin managers to claim routes that are associated with plugins yet to be loaded 2022-07-13 18:30:28 +01:00
Jordon Leach 1dc5925742
Plugin in explorer scoped (#6338)
* Add check for explorer scoped products

* Add inExplorer to type-map product

* Add info about inExplorer prop
2022-07-13 08:20:32 -04:00
Nancy Butler 11edae7b67 fix harvester pkg routing 2022-07-12 10:59:33 -07:00
Nancy Butler 3d966cd198 harvester custom routes 2022-07-12 10:59:33 -07:00
Nancy Butler 4dfeb7c291 routing maybe 2022-07-12 10:59:32 -07:00
Neil MacDougall 13e4564eec
Fixes for setting custom favicon (#6185) 2022-06-17 07:40:03 +01:00
Neil MacDougall 7a6c278318 Allow favicon to be customized via setting 2022-06-08 07:34:19 +01:00