Compare commits

...

1508 Commits

Author SHA1 Message Date
Cesar N.
adfc96074f Release v1.7.0 (#3418) 2024-08-02 15:20:47 -07:00
jinapurapu
7cc7b874d1 Fix MinIO videos link (#3417) 2024-08-02 13:48:54 -07:00
Ramon de Klein
4d12a5061d Remove obsolete KES functionality (#3414) 2024-08-02 11:50:33 -06:00
Prakash Senthil Vel
b274add4da fix nested directory object display (#3415) 2024-08-02 10:06:10 -07:00
Alex
fd51c9dc4c Updated UI dependencies (#3411)
- Fixed an issue with servers list not closing correctly in certain circumstances
- Updated internal UI dependencies

Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2024-07-22 10:44:46 -06:00
Alex
51f8794aa6 Release v1.6.3 (#3408) 2024-07-12 16:07:49 -06:00
Alex
3db998f9c4 Release v1.6.2 (#3407)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2024-07-12 12:43:59 -07:00
Alex
0a2a7087a7 Updated UI Project Dependencies (#3406)
Updated Project Dependencies

Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2024-07-12 13:08:30 -06:00
Alex
8f0eb11ced Updated License page with new design (#3405) 2024-07-12 10:18:17 -06:00
Anis Eleuch
e3e3599095 ws: Calculate the client IP from the WS request headers as well (#3403)
Currently, the websocket code adds an IP to X-Forwarded-For where the IP is
calculated from the TCP connection established to Console, however the established
TCP connection can be coming from the load balancer as well, hence the
necesssity to evaluate the client IP based on X-Forwarded-For or
X-Real-IP headers

Look for client IPs in the websocket request connection.

Co-authored-by: Anis Eleuch <anis@min.io>
2024-07-10 08:04:50 -07:00
dependabot[bot]
aa74e31453 Bump google.golang.org/grpc from 1.64.0 to 1.64.1 (#3404)
Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.64.0 to 1.64.1.
- [Release notes](https://github.com/grpc/grpc-go/releases)
- [Commits](https://github.com/grpc/grpc-go/compare/v1.64.0...v1.64.1)

---
updated-dependencies:
- dependency-name: google.golang.org/grpc
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-07-10 09:15:51 +02:00
jiuker
e1f6e729fd format to loginfo (#3400) 2024-07-08 09:08:27 -06:00
Ramon de Klein
13d83a6d1c User session fixes (#3397) 2024-07-04 18:22:36 -07:00
Ramon de Klein
6075387654 Upgrade Go to v1.22.5 and upgrade Github actions (#3398) 2024-07-04 07:28:24 -07:00
Victor Bayas
69fad3f55f Improvements to Drives list UI (#3395) 2024-07-01 17:27:33 -06:00
Alex
e3864b62a4 Release v1.6.1 (#3393) 2024-06-25 10:26:58 -07:00
Harshavardhana
22176f4e0f fix: objectManager implementation avoid racy goroutines (#3392)
fixes #3391
2024-06-25 08:50:31 -07:00
dependabot[bot]
a89d7ec0ea Bump ws from 7.5.9 to 7.5.10 in /web-app (#3390) 2024-06-18 15:22:19 -07:00
Ramon de Klein
8262049e20 Fix showing object-name in legal hold dialog (#3389) 2024-06-18 15:20:03 -07:00
Alex
c61e1e0a2a Added debounce to Share file fields (#3388)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2024-06-17 16:02:13 -06:00
Alex
b376cf6c65 Improvements to Share Link component behavior (#3387)
Improvements to Share Link component to avoid multiple re-renders during common actions

Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2024-06-17 11:40:27 -06:00
Cesar N
16bae25ce6 Release v1.6.0 (#3386) 2024-06-13 14:26:03 -07:00
Alex
57ba17a12e Changed License plans validation to not allow AGPL as a registered plan (#3385)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2024-06-13 14:36:08 -06:00
Ramon de Klein
f4d98a4910 Fix share link issue (#3382) (#3384) 2024-06-13 13:30:33 -06:00
Cesar N
fa32d78ff1 Add Tiers improvements for Bucket Lifecycle management (#3380) 2024-06-13 13:17:49 -06:00
jinapurapu
56f22a4479 Fix storageClass on EditLifecycleModal (#3379) 2024-06-13 11:06:30 -07:00
Alex
7b88d3a1bc Updated UI package dependencies (#3381)
Updated package dependencies

- Updated react-pdf to fix security vulnerability
- Removed ignored security alerts

Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2024-06-13 11:23:50 -06:00
Prakash Senthil Vel
c8a39f9544 update logo as per mineos plans (#3383) 2024-06-13 08:01:25 -07:00
Cesar N
e77d1be53e Release v1.5.0 (#3373)
update assets with latest fix

Co-authored-by: cesnietor <cesar.nieto@min.io>
2024-06-07 19:00:37 -07:00
jinapurapu
6765bd0624 Fix remove tier error handling (#3375) 2024-06-07 16:39:18 -06:00
jinapurapu
5f7b563a01 Add Remove Tier feature (#3371) 2024-06-07 10:01:10 -07:00
jinapurapu
3885875149 Add ILM rule tags generated by mc to getBucketLifecycle response (#3369) 2024-06-06 15:22:18 -07:00
Cesar N
cf05d5026f Use sync.Map for websocket cancelContext map (#3368) 2024-06-06 11:38:55 -07:00
Harshavardhana
3e83a30739 go1.22.4 upgrade for vulncheck (#3370) 2024-06-06 10:23:43 -07:00
Ramon de Klein
49c5f5a8f0 Use automatic URI encoding (#3352) 2024-06-05 14:48:27 -07:00
Ramon de Klein
72939e0cd7 Provide workaround for circular dependency (#3361) 2024-06-05 11:36:58 -07:00
Javier Adriel
271560894a Fix mapping over null reference for KMS endpoints (#3367) 2024-06-03 14:03:35 -07:00
Javier Adriel
6a591c1bcd Fix wrong comparisons (#3365) 2024-05-29 15:50:23 -07:00
Victor Bayas
3fdcfef1b4 Set Yarn checksumBehavior to reset (#3366)
* Set Yarn checksumBehavior to reset

* Update .gitignore according to Yarn docs
See https://yarnpkg.com/getting-started/qa#which-files-should-be-gitignored

* Update yarn.lock

---------

Co-authored-by: Harshavardhana <harsha@minio.io>
2024-05-29 15:50:12 -07:00
Ramon de Klein
7b8cfa2062 Attempt to fix resolution issues (#3364) 2024-05-29 15:12:02 -07:00
Harshavardhana
cc5921fd74 chore: update all deps (#3363) 2024-05-28 22:19:47 -06:00
Daniel Valdivia
d027b7f759 Release v1.4.1 (#3360)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2024-05-24 12:35:06 -07:00
Aditya Manthramurthy
f1524b0120 Bump up minio/pkg to v3 (#3349) 2024-05-24 10:44:55 -07:00
Kaan Kabalak
9985892751 Update default issue message note (#3358) 2024-05-22 23:16:05 -07:00
Ramon de Klein
cfd60bdd91 Upgrade to Yarn 4 and fix vulnerability check (#3353) 2024-05-22 18:19:32 -07:00
Shireesh Anjal
779f2a86e5 Fix empty version in health report download (#3341) 2024-05-17 14:42:39 -06:00
Pedro Juarez
f47c4445bd Return header with error idp logout (#3346) 2024-05-12 09:30:46 -07:00
Kaan Kabalak
1aeb4cc3d5 Fix SUBNET capitalization in issue template (#3345) 2024-05-10 17:47:38 -06:00
Alex
9e0a0205cc Updated react-pdf dependency (#3342) 2024-05-10 09:11:09 -06:00
Harshavardhana
1058efb17a Remove all unnecessary Dockerfiles from repo (#3340) 2024-05-08 21:53:47 -06:00
Anis Eleuch
d0f744ebef svc: Assume access key creation permission to be available by default (#3306)
Allow SVC creation when CreateServiceAccount is denied with a condition

Adding this policy will make the user not able to create a service account anymore:

```
    {
      "Effect": "Deny",
      "Action": [
              "admin:CreateServiceAccount"
      ],
      "Condition": {
              "NumericGreaterThanIfExists": {"svc:DurationSeconds": "1500"}
      }
    },

```

The reason is that policy.IsAllowedActions() is called with conditions from the user login.

Assume svc account creation to be possible for now until we come up with a better fix

Co-authored-by: Anis Eleuch <anis@min.io>
Co-authored-by: Prakash Senthil Vel <23444145+prakashsvmx@users.noreply.github.com>
2024-05-08 09:47:57 -07:00
Cesar N
a8c043cb16 Use redirect URL in share link if env variable set (#3334) 2024-05-08 09:46:41 -07:00
dependabot[bot]
978e02b5dc Bump react-pdf from 7.7.1 to 7.7.3 in /web-app (#3337)
Bumps [react-pdf](https://github.com/wojtekmaj/react-pdf/tree/HEAD/packages/react-pdf) from 7.7.1 to 7.7.3.
- [Release notes](https://github.com/wojtekmaj/react-pdf/releases)
- [Commits](https://github.com/wojtekmaj/react-pdf/commits/v7.7.3/packages/react-pdf)

---
updated-dependencies:
- dependency-name: react-pdf
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-05-08 09:46:13 -07:00
dependabot[bot]
b39dbfff96 Bump pdfjs-dist from 3.11.174 to 4.2.67 in /web-app (#3335)
Bumps [pdfjs-dist](https://github.com/mozilla/pdfjs-dist) from 3.11.174 to 4.2.67.
- [Commits](https://github.com/mozilla/pdfjs-dist/commits)

---
updated-dependencies:
- dependency-name: pdfjs-dist
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-05-08 09:46:03 -07:00
Alex
bd89cfde79 Release v1.4.0 (#3333) 2024-05-06 17:58:31 -06:00
Anis Eleuch
0bd563b2e5 Fix a leak in WS object browser (#3325)
```
goroutine 7399330769 [chan send, 70126 minutes]:
github.com/minio/console/api.(*wsMinioClient).objectManager.func2.1()
        github.com/minio/console@v0.46.0/api/ws_objects.go:135 +0x6f0
created by github.com/minio/console/api.(*wsMinioClient).objectManager.func2 in goroutine 7354918912
        github.com/minio/console@v0.46.0/api/ws_objects.go:95 +0x45e
```
2024-05-06 15:12:31 -07:00
Alex
22fe915629 Changed default Replicate Existing Objects behavior in MinIO UI (#3271)
Changed default Replicate Existing Objects behavior in UI

- Fixed replicate existing objects configuration saving
- Displayed full error message if error case ocurrs.
- Changed wording for this feature & enabled by default this setting

Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2024-05-06 16:02:27 -06:00
Alex
aa161a5365 Added VersionID support to Metadata Details (#3332)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2024-05-06 14:38:53 -07:00
kcao
0557514cb4 fix: correct metric endpoint from minio_cluster_drive_free_inodes (#3296)
Fixes minio/console#3295
2024-05-06 03:56:08 -07:00
Alex
298203253c Updated UI dependencies (#3329)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2024-05-03 17:32:11 -06:00
Cesar N
cbeef2b248 Fix URL safe string decoding for DownloadPublicObject API (#3328)
Co-authored-by: cesnietor <cesar.nieto@min.io>
2024-05-03 15:33:46 -07:00
Harshavardhana
e68a74ba48 fix: passing correct httpClient, do not use DefaultClients (#3319)
most of our deployments use custom certificates, using DefaultClient
makes it virtually impossible to make share URL feature work.

this PR fixes this behavior in the implementation.

Bonus: re-use transports inside console, will add more changes to
take custom transport inputs in subsequent PR.
2024-05-01 09:46:35 -07:00
Ramon de Klein
02a0db1408 Use React hook to better deal with websockets (#3299) 2024-05-01 03:42:49 -07:00
dependabot[bot]
348376c672 Bump ejs from 3.1.9 to 3.1.10 in /web-app (#3324)
Bumps [ejs](https://github.com/mde/ejs) from 3.1.9 to 3.1.10.
- [Release notes](https://github.com/mde/ejs/releases)
- [Commits](https://github.com/mde/ejs/compare/v3.1.9...v3.1.10)

---
updated-dependencies:
- dependency-name: ejs
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-05-01 02:53:56 -07:00
Kaan Kabalak
037b02e268 Make permission tests compatible with minio-js v8 (#3323)
Fixes #3322
2024-05-01 02:45:09 -07:00
Kaan Kabalak
fe534ab4e6 Temporarily fix permission tests failing due to minio-js version bump (#3321)
Fix permission tests failing due to minio-js version bump

Permission tests were failing due to function signature changes
introduced with the latest minio-js release. This is a temporary
measure until a Console PR to update test files is sent.
2024-04-30 14:32:02 -06:00
Cesar N
6625d54d67 Release v1.3.0 (#3313) 2024-04-24 18:15:13 -07:00
Cesar N
ee6d1ed586 Upgrade superagent package to fix vulnerability (#3314) 2024-04-24 17:27:42 -07:00
Cesar N
6de1d88e11 Use url-safe base64 encoding for download-shared-object api (#3305) 2024-04-23 08:36:30 -07:00
jinapurapu
de19b6f17b Make prefix field optional for adding tier (#3301) 2024-04-18 23:51:13 -06:00
jinapurapu
226a90be1d Adds ExpireDeleteMarker status to bucketLifecycleRule UI display (#3302) 2024-04-18 18:36:00 -06:00
Prakash Senthil Vel
6cfb6ff06a add user agent in admin client to display console in audit logs (#3297) 2024-04-17 10:49:15 -06:00
Alex
649c3d74b8 Release v1.2.0 (#3292)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2024-04-10 13:06:18 -06:00
Alex
662ce3b2f5 Update console dependencies to fix vulnerabilities (#3291)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2024-04-10 11:52:15 -06:00
dependabot[bot]
0292bc154d Bump express from 4.18.3 to 4.19.2 in /web-app (#3277)
Bumps [express](https://github.com/expressjs/express) from 4.18.3 to 4.19.2.
- [Release notes](https://github.com/expressjs/express/releases)
- [Changelog](https://github.com/expressjs/express/blob/master/History.md)
- [Commits](https://github.com/expressjs/express/compare/4.18.3...4.19.2)

---
updated-dependencies:
- dependency-name: express
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Alex <33497058+bexsoft@users.noreply.github.com>
2024-04-10 11:40:56 -06:00
Cesar N
ceee83f03a Use Console as proxy for share object logic (#3284) 2024-04-10 11:16:17 -06:00
Prakash Senthil Vel
144904f0f6 fix ux for keys permissions (#3280) 2024-04-05 10:14:29 -07:00
Alex
963c8f1221 Added missing permissions validation to rewind button (#3282)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2024-04-04 23:41:20 -06:00
Shireesh Anjal
6c50c38f83 fix health report upload error (#3275) 2024-04-04 13:50:22 -06:00
Shireesh Anjal
3aac62cc81 Reuse GetClusterRegInfo from mc (#3270) 2024-04-01 09:14:54 -07:00
Cesar N
78a05d39c4 Log error if it exists while serving APIs (#3276)
Co-authored-by: cesnietor <>
2024-03-27 13:06:42 -07:00
dependabot[bot]
79bec3880e Bump webpack-dev-middleware from 5.3.3 to 5.3.4 in /web-app (#3273) 2024-03-24 05:39:34 +01:00
Alex
bdf7bd6309 Changed Bucket Access Policy default value from n/a to private (#3267)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2024-03-19 18:28:18 -06:00
dependabot[bot]
4ce1ba999b Bump follow-redirects from 1.15.5 to 1.15.6 in /web-app (#3266) 2024-03-14 21:05:39 -06:00
Alex
d01501703b Release v1.1.1 (#3265)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2024-03-14 16:34:57 -07:00
Cesar N
6a38a09462 Fix folder download (#3264) 2024-03-14 15:07:15 -06:00
Alex
78990e354f Release v1.1.0 (#3261)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2024-03-12 11:22:55 -06:00
Harshavardhana
3189ebdfef Update all go-deps (#3259) 2024-03-12 01:47:35 -06:00
Shubhendu
39bf627b0a Enable console to set expired-object-all-versions (#3226)
Signed-off-by: Shubhendu Ram Tripathi <shubhendu@minio.io>
2024-03-11 14:25:06 -06:00
Alex
a838c763ea Release v1.0.0 (#3252)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2024-02-29 13:45:03 -08:00
Aditya Manthramurthy
0afea63994 Fix: handling of no inline policy for service acc. (#3221) 2024-02-29 14:51:12 -06:00
Phillip Schichtel
0df9487527 Check the blob size instead of the progress reports (#3249) 2024-02-29 08:33:26 -08:00
Victor Bayas
9274ee72ad Fix URL of inspect object API (#3247) 2024-02-28 20:51:09 -06:00
Prakash Senthil Vel
2b6c3debb4 clean up text preview support which was removed earlier (#3251) 2024-02-28 09:00:41 -08:00
Victor Bayas
8dd6dd4e7f Use native WebSocket API (#3248) 2024-02-27 13:34:06 -08:00
dependabot[bot]
5e64c96497 Bump ip from 1.1.8 to 1.1.9 in /web-app (#3241)
Bumps [ip](https://github.com/indutny/node-ip) from 1.1.8 to 1.1.9.
- [Commits](https://github.com/indutny/node-ip/compare/v1.1.8...v1.1.9)

---
updated-dependencies:
- dependency-name: ip
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Alex <33497058+bexsoft@users.noreply.github.com>
2024-02-26 13:45:16 -08:00
jinapurapu
54c0b4b8a2 Add bucket replication screen (#3040) 2024-02-26 13:44:55 -08:00
Prakash Senthil Vel
31056e12ba No preview message UI (#3244) 2024-02-26 11:34:21 -06:00
Alex
151c8117a3 Release v0.46.0 (#3238) 2024-02-16 13:58:01 -08:00
Alex
9b5c17c2db Updated failing UI tests in console (#3236)
Updated failing tests in console

Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2024-02-14 17:48:41 -06:00
Alex
23e01b257e Updated mds to v0.18.1 (#3233)
- Updated other project dependencies
- Fixed an issue while pressing enter key in a page that contains a select box
- Fixed an issue while selecting an autocomplete option from an input box

Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2024-02-13 17:53:11 -06:00
jinapurapu
ecc8c7a86e Added latest blog content to help menu (#3223) 2024-02-13 00:28:05 -08:00
Harshavardhana
ee4d7b9b69 upgrade all dependencies for console (#3235)
Signed-off-by: Harshavardhana <harsha@minio.io>
2024-02-12 22:17:21 -08:00
Alex
80c03839a4 Fixed lint issues with files (#3234)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2024-02-12 21:55:17 -08:00
jinapurapu
f394cb69ce Fixed disabled Create User button if policy has no resource (#3231)
Co-authored-by: Jillian Inapurapu <jillii@Jillians-MBP.attlocal.net>
Co-authored-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2024-02-12 09:54:32 -08:00
Prakash Senthil Vel
52137ba9e5 Logout state clean up (#3219) 2024-02-09 15:36:56 -06:00
Prakash Senthil Vel
942b8101cc Fix lifecycle rule and edit modal to be consistent to display tier (#3227) 2024-02-07 11:35:25 -06:00
jinapurapu
a0a6b33ecd Add HelpTip to clarify Usage calculation (#3143) 2024-01-30 23:15:11 -06:00
Cesar N
d4c5e1b51c Fail request when error occurs during download (#3214) 2024-01-26 15:06:25 -06:00
jinapurapu
96923aed75 Changed DeleteAccessRule to use swagger api (#3213) 2024-01-26 14:59:34 -06:00
Shubhendu
a04f833e3f Query params replicate-ilm-expiry and disable-ilm-expiry-replication (#3065)
Signed-off-by: Shubhendu Ram Tripathi <shubhendu@minio.io>
2024-01-26 14:59:09 -06:00
dependabot[bot]
3b52cc9bd4 Bump github.com/lestrrat-go/jwx from 1.2.27 to 1.2.28 (#3215)
Bumps [github.com/lestrrat-go/jwx](https://github.com/lestrrat-go/jwx) from 1.2.27 to 1.2.28.
- [Release notes](https://github.com/lestrrat-go/jwx/releases)
- [Changelog](https://github.com/lestrrat-go/jwx/blob/v1.2.28/Changes)
- [Commits](https://github.com/lestrrat-go/jwx/compare/v1.2.27...v1.2.28)

---
updated-dependencies:
- dependency-name: github.com/lestrrat-go/jwx
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-01-26 12:01:41 -06:00
Cesar N
df2e92e451 Use swagger api for Site Replication Status (#3208) 2024-01-24 23:05:27 -06:00
Cesar N
8836fe043b Return proper progress on download error (#3211) 2024-01-23 10:55:41 -06:00
Cesar N
7ce6a58099 Use swagger api for Get API from Subnet (#3207) 2024-01-22 10:42:33 -06:00
Haruaki
57d6aca716 Fix BucketNamingRules button click (#3209) 2024-01-22 10:41:35 -06:00
Cesar N
8d99637455 Use swagger api for Add KMS key in Bucket Encryption (#3205) 2024-01-21 22:16:10 -08:00
Cesar N
abd66780f4 Use swagger api for AirGap Subnet Registration (#3206) 2024-01-19 14:17:23 -06:00
Cesar N
a5175a35ec Use swagger api for import KSM Key (#3204) 2024-01-19 11:07:05 -08:00
Cesar N
d9f945b5df Use swagger api for Add KMS Key (#3202) 2024-01-18 22:41:40 -08:00
Cesar N
0c55e39e8c Use swagger api for Add IDP Configuration (#3201) 2024-01-18 16:03:01 -08:00
Cesar N
b5443952da Use swagger api for IDP configuration details (#3200) 2024-01-18 15:02:11 -08:00
Cesar N
b9f0ccfaba Use swagger api for delete single and multiple Service Accounts (#3199) 2024-01-18 11:55:56 -05:00
Daniel Valdivia
24742325b7 Remove useAPI from DeleteUser and DeleteIDPConfigurationModal (#3191) 2024-01-17 15:37:28 -08:00
Cesar N
c87ebe447f Use swagger api for delete KMS key (#3197) 2024-01-17 15:31:19 -06:00
Cesar N
462cf16db9 Use swagger api for delete Policy (#3198) 2024-01-17 12:06:03 -08:00
Cesar N
edaa4e8754 Use swagger api for delete group (#3196) 2024-01-17 11:49:03 -08:00
Cesar N
76c596c574 Disable KMS Endpoints and Metrics Tabs if using KMS Secret Key (#3193) 2024-01-17 09:05:10 -08:00
Alex
b5554f6dcf Added Dark / Light Mode Status icons (#3194)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2024-01-16 19:06:58 -06:00
Daniel Valdivia
fc65f1afd1 Add Base URI to Inspect API calls (#3190)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2024-01-16 13:45:27 -08:00
Cesar N
b066b6a920 Kms status endpoints null validation (#3189) 2024-01-12 16:32:37 -06:00
Alex
bc0e63aac8 Release v0.45.0 (#3187)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2024-01-10 21:48:08 -08:00
Alex
343ff575e6 Removed heal backend (#3188)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2024-01-10 21:16:08 -08:00
Alex
08c922dca6 Deprecated Heal (Drives) functionality (#3186)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2024-01-10 22:33:18 -06:00
Alex
4dd6519cc6 Updated Section titles & labels (#3185)
Renamed Subscription to Subnet in menus
Renamed Settings to Configuration
Renamed Diagnostics to Heath

Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2024-01-10 22:16:24 -06:00
Prakash Senthil Vel
cdffdae289 Fix life cycle rule edit for transition (#3183) 2024-01-08 08:43:07 -06:00
Shireesh Anjal
27e3b82223 Use subnet package in pkg for license validation (#3156) 2023-12-29 12:12:27 -06:00
Daniel Valdivia
239b31748a Rename portal-ui to web-app (#3178)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2023-12-29 11:44:01 -06:00
Daniel Valdivia
b465b74326 Release v0.44.0 (#3177)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2023-12-27 00:11:15 -08:00
Daniel Valdivia
616f262d09 Rename restapi to api (#3176)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2023-12-26 15:07:30 -06:00
Harshavardhana
8aa0ec17c5 simplify the provider config init, loading and allow reachable IDPs (#3168)
fixes https://github.com/minio/console/issues/3018
2023-12-26 14:38:42 -06:00
Daniel Valdivia
a8c5b53a2c Pkg Subnet Utils Tests (#3173)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2023-12-26 14:29:11 -06:00
Cesar Celis Hernandez
e96dbd444e Add all possible tests under restapi (#3174) 2023-12-26 14:17:40 -06:00
Prakash Senthil Vel
939e2acb0b fix event dest icons not loading when subpath is configured (#3169)
Co-authored-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2023-12-26 14:03:25 -06:00
Daniel Valdivia
a04955dc70 Save all coverage files to play (#3170)
* Save all coverage files to play

Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>

* Save them to latest as well

Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>

---------

Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2023-12-26 13:52:18 -06:00
Cesar Celis Hernandez
ba04a22492 Adjusting the threshold of the coverage (#3172) 2023-12-26 13:52:03 -06:00
Cesar Celis Hernandez
a281fe129f To include pkg tests in the coverage (#3171)
Execute and include pkg tests in the coverage
2023-12-26 13:34:25 -06:00
Daniel Valdivia
a655cc8d3b Upgrade Go Dependencies (#3167) 2023-12-23 08:26:57 -06:00
Daniel Valdivia
63b584c83d Change Loading Logic for Metrics Page (#3166)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2023-12-22 10:25:54 -06:00
Alex
7dffd5f079 Release v0.43.1 (#3161) 2023-12-18 17:00:58 -06:00
Cesar N
044e5702df Update Share Object UI to reflect max expiration time (#3098) 2023-12-14 15:28:11 -06:00
Alex
3c3b9546d9 Release v0.43.0 (#3159)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-12-12 21:53:25 -06:00
jinapurapu
5bc0e74b53 Omit detailedMessage from login errors (#3136) 2023-12-12 18:09:56 -06:00
Alex
f0d4dddacd Changed PDF file preview behavior (#3144)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-12-12 14:20:06 -06:00
Prakash Senthil Vel
f4a3f46bcf Fix to prevent extra metadata call when listing at a bucket level (#3158) 2023-12-12 10:56:48 -06:00
Alex
38472e4cd2 Updated Console dependencies (#3157)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-12-11 18:29:07 -06:00
Daniel Valdivia
9db5d1e4f4 Tests for pkg/utils (#3155)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2023-12-11 09:57:02 -08:00
jinapurapu
4cadaf7d49 Cleaned up Tooltips and HelpTips on AddBucket screen (#3154) 2023-12-11 11:33:28 -06:00
Adrian Najera
748486160f FIX: Use STS env variable to increase the IDP token expiration (#3132)
Share link duration is based on the token expiration,
this increases the IDP token expiration so the share link
is able to last longer, by using an env variable called
MINIO_STS_DURATION
2023-12-08 09:58:46 -08:00
Alex
2c0a0b2bc4 Release v0.42.2 (#3153)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-12-07 15:37:44 -06:00
Daniel Valdivia
7e51d4bebb Don't attempt to show prometheus metrics if URL is empty (#3152)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2023-12-07 15:16:03 -06:00
Alex
c011e67122 Release v0.42.1 (#3150)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-12-06 19:10:28 -06:00
Alex
394b4c403d Rollback to go 1.19 (#3149)
Rollback go version to go 1.19, This is a requirement of MinIO server

Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-12-06 16:55:03 -08:00
Cesar N
74030aa067 Release 0.42.0 (#3148) 2023-12-06 16:04:01 -08:00
Cesar N
07b8c745e6 Remove prints from delete handlers (#3147) 2023-12-06 16:59:10 -06:00
Prakash Senthil Vel
6767bfa2d2 add encoded filename as part of delete api url (#3141) 2023-12-06 14:28:46 -08:00
Prakash Senthil Vel
607d94fef4 add encoded filename as part of upload url (#3140) 2023-12-06 14:14:25 -08:00
Alex
83b060ef94 Updated govuln check to use latest version (#3146)
Updated go vuln check to use latest version

Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-12-06 15:13:22 -06:00
dependabot[bot]
cb14cb94ce Bump @adobe/css-tools from 4.3.1 to 4.3.2 in /portal-ui (#3139) 2023-12-06 11:31:55 -06:00
Daniel Valdivia
2b9de49fbe Upgrade to Go 1.21 (#3142)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2023-12-01 18:23:24 -06:00
Alex
290f273bdf Updated mds version to v0.13.0 (#3138) 2023-11-28 17:11:54 -08:00
Prakash Senthil Vel
7b43779fb0 Fix share option should not be enabled for a prefix (#3135) 2023-11-28 18:45:24 -06:00
Prakash Senthil Vel
924c38faa6 Fix actions on a del marker in object list view (#3134) 2023-11-23 22:32:08 -06:00
Prakash Senthil Vel
e4d5f9610e access keys ui details improvement and edit (#3116) 2023-11-21 22:08:23 -06:00
jinapurapu
04e9cb0ac8 Enable Create Path button on BrowserBreadcrumbs if User can create subPath (#3131) 2023-11-17 13:21:07 -06:00
jinapurapu
da53daff37 Add UI to select number of non-current versions subject to ILM expiry rule (#3088) 2023-11-16 13:34:04 -06:00
Alex
8c26eff2c1 Added matchMedia mock function for Testing purposes (#3130)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-11-15 15:51:55 -06:00
Alex
044c265423 Enabled Dark Mode in Console (#3129)
- Dark mode will be tied to system settings if not set
- Dark mode will be stored in Application storage once set

Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-11-15 13:33:05 -06:00
jinapurapu
0053658d5d Added OIDC docs and blog to helpMenu (#3127) 2023-11-15 09:30:39 -06:00
Alex
99cf3b378f Removed MUI dependencies from console (#3126)
- Updated DateTime Selector
- Updated last dependency functions
- Removed mui theming tools

Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-11-14 10:22:47 -06:00
jinapurapu
78293eab62 Added new blog and video content to HelpMenu (#3124) 2023-11-13 12:11:55 -06:00
Cesar N
1a84be5782 Ignore server file from swagger-gen make command (#3123) 2023-11-06 14:01:02 -08:00
Alex
178f82b675 Release v0.41.0 (#3121)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-11-02 16:30:50 -07:00
Alex
ec5fbbcd1e Updated Login Error Callback page to mds (#3120)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-11-01 15:21:24 -06:00
Alex
78164054d4 Updated HelpMenu components to use only mds subcomponents (#3119)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-11-01 09:54:14 -06:00
Alex
6d5d11d5b4 Updated common bars (#3118)
- Updated common Loading Bars
- Updated Restart MinIO notification bar

Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-11-01 09:53:42 -06:00
nreisingercres
9e3b93d385 Fix days selector to ignore daylight savings (#3117) 2023-10-31 14:30:10 -06:00
jiuker
d77cf93193 update the madmin-go dep (#3115) 2023-10-31 11:03:26 -06:00
Alex
2cca3f3722 Updated Logs Page to use mds components (#3114)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-10-31 10:12:23 -06:00
Anis Eleuch
36d96a1791 Support resolving of listen addrs to multiple IPv4/IPv6 (#3100)
If you specify --console-address "myaddress:9001" while myaddress can be
resolved to one IPv4 address and another IPv6 address, Console ignores
the IPv6 address. This commit fixes that.

Authored-by: Anis Elleuch <anis@min.io>
2023-10-30 17:47:16 -07:00
Alex
82e34a5df2 Replaced MenuDropdown components with mds variables (#3113)
- Replaced menu dropdown in Files Button
- Input Unit Menu dropdown replacement
- Migrated Download Widget dropdown

Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-10-30 16:46:22 -06:00
Alex
7b83f4b1dc Restored ENV var display support in Console Configuration pages. (#3112)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-10-30 14:38:33 -06:00
Andreas Auernhammer
7d9910d1ca update docker file to ubi9 base image (#3109)
This commit improves and updates the docker file
to the UBI 9 base image.

Signed-off-by: Andreas Auernhammer <github@aead.dev>
2023-10-30 13:20:43 -06:00
Alex
7a63f6da56 Migrated Object Manager components to mds (#3108) 2023-10-27 06:36:01 -07:00
Alex
0043833f36 Migrated Date Selectors & Chart Tooltips styles (#3107)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-10-26 22:41:40 -06:00
Alex
3ad3bccadb Autocomplete component replacement (#3104)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-10-26 11:54:34 -06:00
Alex
39e94c890e Replaced Notification components with mds variants (#3103)
Replaced Notification components for mds variants

- Updated Warning Message components
- Replaced Snackbar component

Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-10-25 11:38:35 -06:00
Alex
701039454a MDS Console improvements (#3102)
- Removed mui badge component
- Updated icons screen
- Migrated Wizard Component
- Improved modals styles
- Updated KMS Status page

Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-10-24 14:09:22 -06:00
Alex
ec77a03d7c Replace missing icons from mui (#3101)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-10-24 09:28:33 -07:00
Alex
8dbad84a58 Improved error handling in Object Browser (#3097)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-10-23 10:17:44 -06:00
Cesar N
1767a37162 Add share link exp api (#3095) 2023-10-19 16:03:14 -05:00
Javier Adriel
622c3a067a Add global params for limit and offset (#3096) 2023-10-19 15:38:31 -05:00
Cesar N
4389548b64 Update swagger generated files with latest swagger version (#3094) 2023-10-19 12:49:38 -07:00
Alex
8cb0f1e558 Replaced mui accordion with mds component (#3089)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-10-17 10:32:23 -05:00
Alex
faafb77c73 Updated mds version to v0.9.6 (#3090)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-10-16 18:17:05 -05:00
Alex
0ecd1c73c1 Updated styling methods to remove mui and replace it with mds (#3085)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-10-13 12:02:29 -05:00
Shubhendu
88bf40f9a6 Use the new golang version 1.21.3 (#3087)
Signed-off-by: Shubhendu Ram Tripathi <shubhendu@minio.io>
2023-10-12 11:50:15 -05:00
dependabot[bot]
a025163b34 Bump golang.org/x/net from 0.15.0 to 0.17.0 (#3086) 2023-10-12 11:50:00 -05:00
Alex
07c80462b7 mui Grid component replacement (#3084)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-10-11 13:59:04 -07:00
Alex
79ac2277d4 Migrated mui Box to use mds component (#3082)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-10-11 13:58:33 -07:00
Alex
1c27bee9d0 Removed FormSwitchWrapper component (#3081)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-10-10 12:29:24 -05:00
Alex
56dc58b0b8 Components cleanup (#3079)
Removed old component wrappers and replaced them with their mds equivalent components:

- InputBoxWrapper
- CommentBoxWrapper
- CheckboxWrapper
- PredefinedList

Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-10-09 14:41:23 -05:00
Adrian Najera
4018addd79 Fix: cache clientIP in GetConsoleHTTPClient (#3056) 2023-10-09 14:40:54 -05:00
jinapurapu
429dfb4314 Add HelpTips to Console (#3054) 2023-10-06 15:38:55 -05:00
Alex
1d7bb0bb2b Removed mui support from PasswordSelector component (#3078)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-10-06 14:09:44 -05:00
Alex
476eb673bb Updated FileSelector and removed old component (#3076)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-10-06 09:12:13 -07:00
Alex
71681b710c Removed deprecated components and replaced them with mds ones (#3077)
- SectionTitle
- AButton
- ScreenTitle

Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-10-06 09:11:48 -07:00
Alex
fb02a7da06 Updated README file (#3074)
Updated README file

Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-10-05 12:31:06 -05:00
MinIO Bot
5fdc341138 mds-released-v0.9.3 (#3073) 2023-10-04 19:17:16 -05:00
Alex
15de6caf75 Fixed Failing integration test (#3071)
Added a wait time after bucket creation to list the new buckets list
2023-10-04 09:09:55 -07:00
Alex
77bc2d5006 Updated Playwright tests (#3070)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-10-03 20:09:33 -05:00
Alex
972f5fca9d Release v0.40.0 (#3069) 2023-10-03 12:17:05 -07:00
Alex
083314ee2d Object Browser Refactor (#3066)
- Refactored navigation to be handled only with URL
- Refactored & simplified websocket
- Updated components to use mds
- Fixed an issue with Anonymous access and file selection
- Fixed an issue with anonymous access and download selection click
- Fixed an issue with object details selection on root path from a bucket
- Simplified reducer

Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-10-02 18:02:03 -05:00
Alex
078ce0e546 Updated console dependencies (#3068)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-10-02 15:52:34 -05:00
MinIO Bot
9beca2c226 mds-released-v0.9.2 (#3060) 2023-09-25 11:49:51 -06:00
Prakash Senthil Vel
451f23ae24 Improve change password user experience (#3058) 2023-09-22 13:51:03 -06:00
Alex
300ebfa19f Updated OpenID UX (#3050)
- Display ENV variables set in configuration
- Removed Password empty placeholders
- Added notification to re-enter password when modifying OpenID configuration

Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-09-22 13:50:41 -06:00
Alex
1ce2846c95 AuditLogs page fixes (#3059)
- Added support to endDate
- Converted dates to UTC as required by AuditLogs API

Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-09-22 09:49:36 -06:00
Alex
7fb8c11a9d Added support for Scanner event type (#3055)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-09-21 13:14:54 -06:00
Prakash Senthil Vel
e7993c2d1b Fix: handle crash in error handling of access keys page (#3051) 2023-09-20 20:45:51 -06:00
Alex
3e93f7ff88 Release v0.39.0 (#3049)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-09-14 23:43:58 -07:00
Alex
f0580956db Improvements to LDAP Configuration page (#3047)
- Fixed LDAP Enabled / Disabled calculation
- Removed Password Label from main page to avoid confusion
- Display LDAP ENV variables in case of configured

Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-09-14 17:54:59 -06:00
Pedro Juarez
65b0bab26d Load the available CA in logout API (#3044) 2023-09-13 15:26:48 -06:00
Harshavardhana
a559421293 migrate and upgrade all dependencies (#3046) 2023-09-13 13:55:47 -06:00
Cesar N
6ef35c26a4 Remove unused check-version api (#3045) 2023-09-13 13:55:06 -06:00
Alex
8a918324aa Added CONSOLE_PROMETHEUS_AUTH_TOKEN flag support (#3043)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-09-13 12:02:13 -06:00
Alex
d30c0c8cbb Migrated Metrics pages and components to mds (#3042)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-09-13 12:01:43 -06:00
Alex
1697c826c0 Fixed an issue while deleting objects with similar prefixes (#3035)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-09-12 10:05:41 -06:00
Cesar N
b378b8c8ef Fix regression on login path when using redirect url (#3038) 2023-09-11 14:25:34 -07:00
MinIO Bot
2c42d7ff81 mds-released-v0.9.1 (#3041) 2023-09-11 09:58:23 -06:00
Cesar N
e1f36ee54a Upgrade go version in git workflows to 1.21.1 (#3039) 2023-09-07 17:29:22 -06:00
Alex
698f72f828 Migrated Register page components to mds (#3034)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-09-07 11:48:29 -06:00
jinapurapu
8dd94f5336 Moved EditBucketReplication to screen (#3037) 2023-09-06 17:24:07 -06:00
Alex
1dc21b9a21 Removed TableWrapper (#3032)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-09-05 11:06:33 -06:00
Alex
248215cc77 Updated Changelog for v0.38.0 (#3031)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-09-04 11:44:50 -07:00
Alex
a6eee73c11 Release v0.38.0 (#3029)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-09-02 09:10:10 -07:00
Anis Eleuch
50d6a39312 idp: Use 900 seconds as minimum expiry without returning an error (#3022)
Do not bother the user with an error if the IDP expiry is less than
900 seconds, since the S3 spec sets a minimum of 900 seconds for STS
expiration, use that minimum duration instead of returning an error

Co-authored-by: Anis Elleuch <anis@min.io>
Co-authored-by: Alex <33497058+bexsoft@users.noreply.github.com>
2023-09-02 07:50:45 -07:00
Aditya Manthramurthy
467b6b9bcb Use github.com/minio/pkg/v2 (#3027) 2023-09-01 17:29:07 -06:00
Alex
6e6246797c Renamed Subnet strings to SUBNET (#3026)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-09-01 15:10:12 -07:00
Alex
f8e4f747f5 Migrated Components loader to mds (#3025)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-09-01 12:06:33 -06:00
Alex
9acd49fcc6 Updated console dependencies (#3024)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-08-31 09:27:48 -06:00
Alex
636d12d43f Replaced LinearProgress as loader in favor of ProgressBar from mds (#3020)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-08-31 09:27:29 -06:00
MinIO Bot
5e9383de95 mds-released-v0.9.0 (#3021) 2023-08-30 12:38:11 -06:00
Kaan Kabalak
4863af863e Update minimum Standard plan capacity on License page (#3023) 2023-08-30 11:28:42 -06:00
Martin
b6d4c62edd Fix oauth2Config.Exchange error reporting (#3003) 2023-08-28 15:35:53 -07:00
Alex
bf733f3822 Migrated Heal and Watch pages to mds (#3016)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-08-25 09:53:02 -06:00
Alex
bbf4027418 Migrated Speedtest components to mds (#3015)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-08-24 17:08:16 -06:00
Alex
dbffc5fc22 Migrated Site Replication Pages (#3011)
- Improved & Simplified UI elements

Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-08-24 17:07:58 -06:00
Cesar Celis Hernandez
f4a9420002 To properly show error in AddAccessRule.tsx (#3008)
Fixing the shown errors
2023-08-24 06:53:32 -06:00
Alex
657854bd29 Updated generated stylesheet (#3013) 2023-08-23 15:31:22 -06:00
MinIO Bot
cdc9e7d921 mds-released-v0.8.6 (#3012) 2023-08-23 15:21:36 -06:00
Alex
b125121ac8 Migrated available mds components in Tiers Page (#3007)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-08-21 22:30:04 -06:00
Daniel Valdivia
0c480dd5ec Handle errors for Set Policy for Access keys (#3005)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2023-08-21 12:00:45 -06:00
MinIO Bot
c07b8dcf73 mds-released-v0.8.4 (#3002)
Co-authored-by: MinIO Bot <minio.bot@minio.io>
2023-08-21 09:25:24 -06:00
Daniel Valdivia
912a4b216f Rename Error to ApiError to avoid ambiguity (#2954)
Rename Error to ApiError to avoide ambiguity and remove redundant status code

Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2023-08-16 14:18:08 -07:00
Prakash Senthil Vel
e7fb205c31 show service account status and expiry in ui (#2992) 2023-08-16 11:55:07 -06:00
Alex
a2ba20e12f Release v0.37.0 (#3000) 2023-08-16 10:03:02 -07:00
Alex
f515dd82fe Migrated Trace page to mds (#2996)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-08-16 10:23:01 -06:00
Alex
61d3193c41 Migrated available mds components in Logs Page (#2998)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-08-16 09:42:15 -06:00
Harshavardhana
430ae66955 update disk -> drive change in prometheus metrics in minio master (#2999)
refer to https://github.com/minio/minio/pull/17854
2023-08-15 19:49:53 -07:00
MinIO Bot
3abbbc82b2 mds-released-v0.8.3 (#2995) 2023-08-15 10:09:50 -06:00
Alex
854181f63e Disabled input fields and changed Register label in Subscription features (#2994)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-08-14 17:07:31 -06:00
Kaan Kabalak
df996794ed Remove duplicate ref=con in License page buttons (#2993) 2023-08-14 10:12:10 -06:00
Cesar N
2d94018e3c Release v0.36.0 (#2988) 2023-08-10 11:59:15 -07:00
Alex
72bb9d0ca1 Update Settings Page components (#2986)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-08-09 18:30:42 -06:00
Javier Adriel
93bd0d65e2 Show LDAP configuration (#2985) 2023-08-09 12:06:17 -06:00
Prakash Senthil Vel
495b0f0068 truncate prefixes above the selected level to make the download layout flat (#2987) 2023-08-09 10:29:41 -07:00
Cesar Celis Hernandez
3275b6a6d8 Removing unneeded password (#2983) 2023-08-04 13:45:41 -06:00
Harshavardhana
fed5aa1599 fix: dateTime usage only available in go1.20 (#2982)
instead use a simpler normalizer for timestamp
to be user friendly without spaces.

For example

```
selected_files_20091110T230000Z.zip
```
2023-08-03 20:21:44 -07:00
Alex
6bc4efbac1 Release v0.35.0 (#2981) 2023-08-03 14:54:29 -07:00
Alex
cc0164a67b Initial Tools Pages Migrations (#2978)
Tools Pages Migrations

- Call Home
- Inspect
- Profile
- Health

Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-08-03 15:26:17 -06:00
Prakash Senthil Vel
b968cc25ad feat: download multiple object selection as zip ignoring any deleted objects selected (#2965) 2023-08-02 18:28:25 -06:00
jinapurapu
d116a35a6d Fix subpath button (#2977)
Added bucketName to permissions check for subpath
2023-08-02 15:26:39 -07:00
Alex
49f856bdd5 Added Exclude Folders & Exclude Prefixes support (#2973)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-08-02 13:35:00 -06:00
Cesar Celis Hernandez
0d628f589a Removing white spaces from provided values (#2922) 2023-07-31 22:29:11 -06:00
Cesar N
4387b2149f Update Github jobs to use hardcoded testcafe version (#2972) 2023-07-31 16:11:28 -07:00
Alex
8cc602434e Release v0.34.0 (#2969)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-07-28 16:31:50 -07:00
Anis Eleuch
6411dc9504 auth: Avoid forcing one hour expiration for IDP sts creds (#2966) 2023-07-27 22:25:47 -06:00
Alex
32c34b0a11 Migrated Buckets Pages to mds (#2960) 2023-07-27 19:27:43 -07:00
jinapurapu
6e8f5e0fc2 Fixed subnet Health report upload (#2927)
Fixed subnet file upload to allow upload of different report types
2023-07-27 15:29:30 -07:00
Alex
3ce377dbd1 Changed Download Handler Behavior (#2964)
- Updated Handler for files with size of 49GB or less
- Used Browser Handler tor size of more than 50GB

Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-07-26 21:08:35 -07:00
Alex
ad502b9f18 Fixed issue with folders named as the bucket in rewind mode (#2963)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-07-26 13:53:04 -07:00
Alex
fde186a5a3 Release v0.33.0 (#2956)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-07-20 22:26:32 -07:00
Prakash Senthil Vel
0823f623c8 fix configuration page to include configs based on supported config subsystems (#2946) 2023-07-20 14:43:17 -06:00
Prakash Senthil Vel
6cec113304 fix: add new dashboard metrics (#2952) 2023-07-20 07:57:41 -07:00
dependabot[bot]
cd42d77a46 Bump word-wrap from 1.2.3 to 1.2.4 in /portal-ui (#2953) 2023-07-19 11:40:03 -06:00
Alex
35907beaca Updated Prettier to v3.0.0 (#2949)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-07-18 09:58:21 -06:00
MinIO Bot
a062a59288 mds-released-v0.7.0 (#2948) 2023-07-18 09:53:53 +05:30
Prakash Senthil Vel
842c2decd0 fix console dashboard node io prometheus metric WChar and RChar (#2947) 2023-07-17 10:51:59 -07:00
Prakash Senthil Vel
d1069ed359 fix loading of objects at a path when url is shared opened elsewhere (#2944)
- fix loading of objects at a path when url is shared and opened elsewhere
- fix bug when a path is created and objects are uploaded it is not refreshed
2023-07-17 09:03:31 -07:00
Prakash Senthil Vel
6d81a1b1f8 add support for preview based on content type (#2930) 2023-07-13 18:29:56 -06:00
Alex
b2fe478dae Updated vulnerabilities checks & workflows (#2941) 2023-07-12 22:05:54 -06:00
Prakash Senthil Vel
02ed6a6e8b Fix delete share download options permission check in sidebar (#2935) 2023-07-12 11:07:18 -06:00
jinapurapu
1b271ab467 Removed extra 'Event Destination' text (#2938) 2023-07-12 10:35:39 -06:00
Prakash Senthil Vel
bacb5f8901 Preserve white space in breadcrumb disply and navigation (#2932) 2023-07-11 22:32:03 -06:00
MinIO Bot
ae7371da95 mds-released-v0.6.9 (#2934) 2023-07-10 22:56:44 -06:00
Prakash Senthil Vel
60f5eb603b remove warning message in delete bucket replication rule (#2931) 2023-07-10 14:29:23 -06:00
Prakash Senthil Vel
420ed00f55 Fix object metadata section crash due to un escaped characters (#2928) 2023-07-07 12:21:06 -06:00
Alex
b975871e9d Migrated remaining LDAP subcomponents to mds (#2926)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-07-06 22:21:19 -06:00
Alex
803ffe2960 Migrated OpenID module components to mds (#2925)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-07-06 14:14:10 -06:00
Cesar N
c96c95924c Release v0.32.0 (#2924) 2023-07-06 10:32:39 -07:00
Alex
f02786001c Migrated Groups Module components to mds (#2923)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-07-05 22:29:17 -06:00
Alex
542b7192c3 Migrated Users Module components to mds (#2920)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-07-05 17:21:07 -07:00
Javier Adriel
b31aa10b52 Refactor to swagger TS API (#2903) 2023-07-05 17:27:46 -06:00
jiuker
1eba59954d fix: websockets goroutine leak for object list UI (#2805)
listen on the done channel to ensure that we can clean up 
the WebSocket go-routine, once the caller is done with
writing the response.
2023-07-05 12:17:54 -07:00
jinapurapu
b71d9f05c5 Updated placeholderimage for offline HelpMenu items (#2916) 2023-06-30 18:35:04 -06:00
Daniel Valdivia
fc5e94d55f Remove Cross compile jobs (#2915) 2023-06-29 18:57:14 -06:00
Alex
3875fb3eaa Release v0.31.0 (#2912)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
Co-authored-by: Benjamin Perez <benjamin@bexsoft.net>
2023-06-29 12:21:34 -07:00
Aditya Manthramurthy
b3d4132fe6 Remove goreleaser (#2914)
Not needed any more as standalone console deploys are not supported any more.
2023-06-29 11:15:58 -06:00
Alex
21f20bb9ea Migrated Policies module to mds (#2911)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-06-28 18:23:58 -06:00
Alex
df937467a0 Fixed Bucket Events Notifications Page (#2906)
- Added missing ilm & replica supported types
- Fixed add screen crash when no arn is selected
- Migrated components to mds

Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-06-28 15:39:02 -06:00
Alex
d1ae271111 Replaced CodeMirrorWrapper internal components (#2910)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-06-28 12:05:18 -07:00
Alex
e7fb3e0e45 Updated console dependencies (#2909)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-06-26 14:12:09 -06:00
dependabot[bot]
b7b0271ec7 Bump fast-xml-parser from 4.2.4 to 4.2.5 in /portal-ui (#2904)
Signed-off-by: dependabot[bot] <support@github.com>
2023-06-22 21:41:22 -06:00
jinapurapu
9935b839b7 Help menu cleanup (#2905) 2023-06-22 20:25:06 -06:00
Cesar N
0e11098c31 Upgrade semver version to address vulnerability (#2902) 2023-06-22 17:54:14 -04:00
Daniel Valdivia
c55e0a069b Format number of objects (#2901) 2023-06-22 12:59:16 -07:00
jinapurapu
c3da876b04 Added placeholder image to HelpMenu if links unavailable (#2899) 2023-06-22 12:12:13 -07:00
Alex
643a9c6c7c Updated Audit Logs page to use mds (#2897)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-06-21 14:32:19 -06:00
Aditya Manthramurthy
0c3a94172d Bump up madmin-go to v3.0.2 (#2896) 2023-06-21 10:51:12 -07:00
Javier Adriel
527eb16700 Refactor to swagger TS API (#2888)
Co-authored-by: Prakash Senthil Vel <23444145+prakashsvmx@users.noreply.github.com>
Co-authored-by: Alex <33497058+bexsoft@users.noreply.github.com>
2023-06-20 12:46:20 -07:00
Alex
e3aec3f094 Updated mds to v0.6.4 (#2895) 2023-06-20 11:49:58 -07:00
Alex
eac2734df4 Update mds to v0.6.2 (#2894) 2023-06-20 11:37:09 -06:00
Allan Roger Reid
a411e7c977 Create bug_report.md (#2893) 2023-06-19 19:58:26 -07:00
Prakash Senthil Vel
28c4abe2d0 audit only the dependencies and exclude dev dependencies in ci for ui (#2892) 2023-06-19 10:55:20 -06:00
Javier Adriel
a9ef6ebf5f Fix download of folders (#2891) 2023-06-19 10:54:18 -06:00
Ali Garajian
c12415c12d Virtualize download/upload object list (#2889) 2023-06-16 13:31:39 -06:00
Cesar N
1f481e690b Add CHANGELOG file for Releases (#2887) 2023-06-15 14:21:27 -07:00
Alex
58aad859e1 Release v0.30.0 (#2886) 2023-06-15 13:13:53 -07:00
jinapurapu
b9ebfe09ee Removed console.log (#2885) 2023-06-15 12:52:24 -06:00
Prakash Senthil Vel
864cf7af99 Apply policy resource restrictions for file extensions (#2842) 2023-06-15 11:33:52 -07:00
Javier Adriel
b76f460979 Remove dead code and add job in CI to find it (#2882) 2023-06-15 10:24:24 -06:00
Cesar N
cbd2c4682d Raise error on upload artifact if no files (#2884)
Raise error on artifact upload if no files to upload

Co-authored-by: cesnietor <>
2023-06-15 09:00:51 -07:00
Javier Adriel
d49bdf7d49 Add staticcheck to console API (#2883) 2023-06-14 21:35:00 -06:00
dependabot[bot]
559a7278a0 Bump github.com/lestrrat-go/jwx from 1.2.25 to 1.2.26 (#2879) 2023-06-14 17:16:17 -06:00
Daniel Valdivia
4a172fae97 Pass Client IP address to MinIO on x-forwarded-for header (#2864) 2023-06-14 12:36:48 -07:00
Cesar N
fc4263e2f9 Define action version to Git action (#2875) 2023-06-13 18:16:46 -06:00
Cesar N
c1b9b4c81b Add Git job to add new issues to project (#2873) 2023-06-13 17:36:21 -06:00
Javier Adriel
aa9b73522e Refactor to swagger ts API (#2860) 2023-06-13 15:00:56 -07:00
Alex
0904f83627 Fix playwright (#2867)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-06-13 14:43:28 -07:00
Cesar N
253053cc23 Refactor session to avoid duplicate calls to apis (#2868)
Co-authored-by: cesnietor <>
2023-06-13 14:27:48 -07:00
Alex
08a3ff65c7 Updated menu component to use mds (#2866)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-06-13 15:16:46 -06:00
jinapurapu
ee8fac8be8 Removed debugging line (#2870)
Co-authored-by: Jillian Inapurapu <jillii@Jillians-MacBook-Pro.local>
2023-06-13 11:48:25 -07:00
jinapurapu
9fa49b40b3 Console help menu (#2804)
Authored-by: Jillian Inapurapu <jillii@Jillians-MBP.attlocal.net>
2023-06-12 14:50:25 -07:00
Javier Adriel
de13119e02 Use swagger autogenerated ts API for session endpoint (#2859) 2023-06-12 15:00:40 -06:00
Alex
bf9acd7691 Share File access key / secret key rollback (#2863)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-06-12 14:02:38 -06:00
Alex
a5066fecc8 Update mds to v0.6.0 (#2862)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-06-12 11:55:23 -07:00
jinapurapu
6432681440 Minor tooltip fixes (#2861) 2023-06-12 09:54:07 -06:00
jinapurapu
b3b6df9d82 Minor fixes to Config screen tooltips (#2857) 2023-06-08 23:28:28 -06:00
Alex
fe7be4ef62 Fixed an issue with subpaths in resources policies (#2856)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-06-08 17:37:45 -06:00
Javier Adriel
b4603547f6 Add tests for remote buckets handlers (#2843) 2023-06-08 13:06:49 -06:00
Javier Adriel
b33b9315ea Fix fast-xml-parser vulnerability (#2855) 2023-06-06 11:55:23 -07:00
BlockListed
6ae03fa028 Fix spelling in file sharing menu (#2853) 2023-06-04 12:23:25 -06:00
MinIO Bot
e1bb1e0472 mds-released-v0.5.1 (#2851) 2023-06-02 20:45:08 -06:00
Alex
411670e4f5 Release v0.29.0 (#2850)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
Co-authored-by: Benjamin Perez <benjamin@bexsoft.net>
2023-06-02 13:51:48 -07:00
Alex
1c55932f84 Updated console dependencies (#2849) 2023-06-02 12:58:07 -06:00
Kaan Kabalak
5a77054d6b Update Service Acct fns based on new ListServiceAccounts type (#2824)
* Update Service Acct fns based on new ListServiceAccounts type
2023-05-30 10:30:02 -07:00
Alex
84c5fd58f9 Display error snack bar on raw policy edit error (#2841)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-05-29 18:05:42 -06:00
Daniel Valdivia
98979911ee Move Login to Typescript Swagger API (#2839)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2023-05-29 13:52:29 -07:00
Alex
c0cf7358c7 Removed hardcoded background in access keys table (#2837)
## What does this do?

Removed non required classes from access keys table

Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-05-28 18:47:10 -07:00
Alex
9053e64dff Fixed multiselection of items after deleting one service account (#2836) 2023-05-26 16:58:01 -06:00
Alex
57bfe97d08 Release v0.28.0 (#2831) 2023-05-26 13:42:42 -07:00
Alex
028570279c Migrated Access Keys page components to mds (#2834)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-05-26 11:24:34 -06:00
MinIO Bot
bda1cd1f25 mds-released-V0.4.3 (#2830)
Co-authored-by: MinIO Bot <minio.bot@minio.io>
2023-05-24 11:37:48 -07:00
Alex
7a9b775b09 Changed Share Object logic to use Access Keys (#2827)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-05-24 10:52:40 -07:00
Daniel Valdivia
17e791afb9 Replace RIGHT-TO-LEFT OVERRIDE unicode (#2828)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2023-05-23 09:47:12 -06:00
Daniel Valdivia
920fc7d937 Fix Subpath behavior (#2818)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2023-05-22 12:30:59 -07:00
GeekTR
6e314a2fa5 Fix crash when backend has no rrSCParity property (#2826) 2023-05-22 13:14:41 -06:00
Alex
dc90db6591 Changed SSO Login screen to hide login form by default (#2807)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-05-22 11:20:45 -06:00
Prakash Senthil Vel
beed4895c1 Apply permission check for create accesskey button (#2822) 2023-05-22 09:26:31 -07:00
Prakash Senthil Vel
629dd669c4 Fix anonymous access rule not displayed due to style (#2820) 2023-05-18 10:54:21 -06:00
Alex
fc9319e55b Added identifier field to Event destinations page & migrated to mds (#2816) 2023-05-16 20:21:31 -06:00
Alex
58b64a5739 Fixed an issue with allowResources & KeyBar (#2817) 2023-05-16 16:53:32 -06:00
Javier Adriel
d93537261e Fix download of large files in Console (#2773) 2023-05-15 11:31:43 -07:00
Prakash Senthil Vel
22ec87d00e improve playwright tests with refactoring and clean up (#2809) 2023-05-15 10:02:40 -06:00
MinIO Bot
b87b4156e7 mds-released-v0.4.2 (#2815)
Co-authored-by: MinIO Bot <minio.bot@minio.io>
2023-05-12 18:55:23 -06:00
Alex
93f010b880 Release v0.27.0 (#2813)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
Co-authored-by: Benjamin Perez <benjamin@bexsoft.net>
2023-05-10 21:33:38 -07:00
Prakash Senthil Vel
c5d4cdf1bc fix to show or hide show deleted objects option based on versioning status (#2780) 2023-05-10 11:36:49 -06:00
Anis Eleuch
c117601e53 Update madmin-go to 2.1.1 (#2810)
Update madmin-go library + github.com/minio/mc

Also update the code to work with the library update

Co-authored-by: Anis Elleuch <anis@min.io>
2023-05-09 10:49:51 -07:00
MinIO Bot
f78f838ed9 mds-released-v0.4.1 (#2808)
Co-authored-by: MinIO Bot <minio.bot@minio.io>
2023-05-09 10:03:49 -06:00
Alex
1583b69fb7 Made Service Account creation consistent with mc (#2801) 2023-05-03 12:33:21 -06:00
Alex
cde6d1b0e0 Added Disable login animation with env variable (#2799)
Set CONSOLE_ANIMATED_LOGIN=off env variable before running Console binary

Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-05-03 11:36:41 -06:00
Alex
be60569a14 Changed Object Browser components to use new mds components (#2796) 2023-05-02 17:29:21 -07:00
Alex
51226a74d0 Release v0.26.4 (#2798)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-05-02 18:01:09 -06:00
Daniel Valdivia
e983473a54 Upgrade Go Dependencies (#2786)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2023-05-02 14:35:22 -06:00
Kaan Kabalak
211ab3fd9d Fix incorrect logo appearing for Standard License holders (#2797) 2023-05-01 14:50:01 -06:00
Javier Adriel
90c8ea7f09 Use PageLayout from mds (#2789) 2023-04-29 21:16:09 -06:00
Alex
fb5193d896 Updated mds to v0.4.0 (#2794) 2023-04-27 19:50:21 -06:00
Alex
f7a7f01d7d Fixed issue while getting locking status of a bucket (#2790)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-04-26 09:59:58 -06:00
Javier Adriel
2c84a52937 Use FormLayout from mds (#2788) 2023-04-25 14:22:49 -06:00
Cesar Celis Hernandez
6020590b2f Make playwright run faster (#2737) 2023-04-25 09:19:00 -07:00
Alex
1477def4fe Updated Console UI dependencies (#2787)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-04-24 23:19:22 -07:00
Javier Adriel
8882f1da0e Fix yaml vulnerability (#2785)
Bump yaml package version to 2.2.2 to address unhandled exception [CVE-2023-2251](https://nvd.nist.gov/vuln/detail/CVE-2023-2251)

More details on https://github.com/advisories/GHSA-f9xv-q969-pqx4
2023-04-24 16:40:17 -07:00
Cesar N
056d487f1c Show progress bar when loading Usage Info (#2784) 2023-04-19 22:06:16 -06:00
Cesar N
b8083215b3 Update Dev Docs with MinIO naming conventions (#2783) 2023-04-19 11:12:21 -07:00
Cesar N
61c864e748 Update Dev Documentation (#2781) 2023-04-19 10:47:15 -06:00
Javier Adriel
0e0f5030da Remove health diagnostic warning (#2779) 2023-04-17 17:00:03 -06:00
Alex
0dacc4d49e Changed breadcrumbs back button behavior (#2776)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-04-12 17:23:04 -06:00
Alex
4d783c5e42 Added Object Version read-only field in Edit Lifecycle Modal (#2772) 2023-04-11 17:33:16 -06:00
Alex
75b3a6bea4 Fixed Object Version selector visibility in Add Lifecycle Rule modal (#2769)
- Fixed Object Version selector visibility in Add Lifecycle Rule modal
- Changed definition in swagger file to match camelCase standard
- Added a playwright test case to avoid this issue in the future

Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-04-11 11:01:03 +02:00
Alex
29507cda7e Updated xml2js library (#2770)
## What does this do?

Updated xml2js library for tests in console. Will fix this in minio-js
as well in an upcoming PR

## How does it look?
<img width="391" alt="Screenshot 2023-04-10 at 21 58 04"
src="https://user-images.githubusercontent.com/33497058/231052457-dac4b376-d1b8-4fd2-80e2-10892f8a453d.png">

Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
Co-authored-by: Benjamin Perez <benjamin@bexsoft.net>
2023-04-11 10:36:03 +02:00
Alex
81e0c82fee Changed GitHub labels (#2768)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-04-10 14:05:08 -06:00
Alex
7519fad6dd Release v0.26.3 (#2764)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-04-06 09:45:15 -07:00
Prakash Senthil Vel
248a59ee8c compliance license faq updated (#2762) 2023-04-06 10:11:34 -06:00
Alex
cefb6d3c95 Release v0.26.2 (#2761)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
Co-authored-by: Benjamin Perez <benjamin@bexsoft.net>
2023-04-05 14:12:30 -07:00
Alex
543076eaac Release v0.26.1 (#2759)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
Co-authored-by: Benjamin Perez <benjamin@bexsoft.net>
2023-04-05 13:11:39 -07:00
Alex
cbf1ddeb4c Added support for root credentials login with LDAP enabled (#2758)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-04-04 15:38:32 -06:00
Daniel Valdivia
3746adcc13 Update Login Message (#2757) 2023-04-04 12:24:10 +02:00
Alex
854b984850 Display explicit errors if websocket connection cannot be stablished (#2756)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-04-03 18:10:59 -06:00
Alex
62fa0e2043 Updated Entities results panel styles (#2753)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-03-31 22:09:37 -06:00
Javier Adriel
4f5b1b0aa7 Show modal to restart minio after subnet register (#2752) 2023-03-31 17:31:54 -06:00
MinIO Bot
0e362c2106 mds-released-v0.3.3 (#2750)
Co-authored-by: MinIO Bot <minio.bot@minio.io>
2023-03-30 14:11:56 +09:00
Alex
6ac5be32b2 Release v0.26.0 (#2746)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-03-27 17:12:21 -07:00
Harshavardhana
6966183bc8 Update deps and fix build issues (#2745) 2023-03-27 15:30:52 -06:00
Alex
60d70e3668 Added anonymous access modal in folder selection (#2736)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-03-23 12:05:16 -06:00
jinapurapu
5e65f2aced Fixed Drives offline card UI (#2732) 2023-03-23 09:53:21 -06:00
jinapurapu
1e345364cf Fixed refresh button on ListObjects screen (#2728) 2023-03-22 15:39:44 -06:00
jinapurapu
502a6c462f Fixed snackMessage to display if error returned creating policy (#2726) 2023-03-22 15:39:08 -06:00
Javier Adriel
ceafdb9cb4 Fix revive lint issues (#2730) 2023-03-22 15:06:04 -06:00
Alex
a6d8f6beaa Added Audit Kafka configuration panel (#2724) 2023-03-21 10:07:56 -06:00
Alex
fa1f84bd0a Release v0.25.1 (#2723)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-03-17 17:34:30 -07:00
Alex
72a1e5eefb Changed response type for Add bucket (#2721)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-03-17 17:36:42 -06:00
Cesar Celis Hernandez
f20fa0b1c8 Condensing Successful responses (#2722) 2023-03-17 17:12:59 -06:00
Alex
07b7af59b6 Minor Adjustments (#2719)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-03-17 11:28:12 -06:00
jinapurapu
c9ac525358 Tenant health info upload (#2606)
For registered clusters, after generating the Health Info report, Health Info is uploaded to Subnet, and latest metrics are visible in Subnet.
Authored-by: Jillian Inapurapu <jillii@Jillians-MBP.attlocal.net>
2023-03-17 09:42:01 -07:00
Daniel Valdivia
8b1b2b1e2d Introducer swagger typescript api (#2704)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2023-03-17 09:57:45 -06:00
Alex
ad0591ec17 Updated yarn packages (#2718)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-03-17 08:30:58 -07:00
Alex
59c47d98dd Reactivated Enable / Disable LDAP functionality (#2714)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-03-16 15:18:47 -07:00
Alex
cb38a545ce Fixed navigation after bucket creation (#2713)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-03-16 14:11:03 -06:00
Alex
dd356b6ea9 LDAP Page improvements (#2708)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-03-16 11:48:59 -06:00
Alex
c1d39a910f Display Menu Headers (#2712)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-03-16 09:42:58 -06:00
Alex
eb3913ba48 Fixed issues in Embeddable Object Browser (#2711)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-03-16 09:42:35 -06:00
dependabot[bot]
f7efbc66f7 Bump webpack from 5.75.0 to 5.76.1 in /portal-ui (#2707) 2023-03-14 12:58:33 -07:00
Alex
f368d9936a Adjusted dropdown box styles in login page (#2706)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-03-14 11:24:46 -06:00
Cesar Celis Hernandez
5cb4e6f651 Adopting Playwright (#2702) 2023-03-14 09:26:06 -06:00
Daniel Valdivia
f7f7b087c4 Hide Header and Padding on iframed Metrics (#2703)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2023-03-13 22:42:19 -06:00
Alex
4cceee8936 Added LDAP Entities API (#2700) 2023-03-10 09:16:29 -06:00
Prakash Senthil Vel
5262c02a28 improve airgap license update user experience (#2697) 2023-03-08 23:25:49 -06:00
Daniel Valdivia
fd81529ddc Upgrade Go Dependencies (#2699)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2023-03-08 23:24:46 -06:00
Daniel Valdivia
383341ad61 Update UI Dependencies (#2698)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2023-03-08 18:21:05 -06:00
Daniel Valdivia
66d0182825 Release v0.25.0 (#2696)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2023-03-08 09:17:03 -08:00
Alex
1fc9a40273 Changed IDP login support in console (#2695)
- Allowed to use External IDP + Built-in IDP at the same time
- Added IDP type to IDP listing
- Added IDP name when no display name is configured
- Changed STS login link into new menu
- Cleanup of Operator login strategies

Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-03-07 14:10:21 -08:00
Daniel Valdivia
1953a98968 Ref Con for Login Page Links (#2694) 2023-03-06 16:12:25 -08:00
Cesar Celis Hernandez
3b5979d783 Compiling when cache is missing (#2688) 2023-03-03 09:11:00 -08:00
Harshavardhana
9aa1f43df7 move to UBI micro image (#2684)
Co-authored-by: Prakash Senthil Vel <23444145+prakashsvmx@users.noreply.github.com>
Co-authored-by: Alex <33497058+bexsoft@users.noreply.github.com>
2023-03-02 20:42:28 -08:00
Daniel Valdivia
bf89f09238 Removing Operator UI (#2692)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2023-03-02 21:35:08 -06:00
Prakash Senthil Vel
b8e14ee269 improve versioning status display and delete with versions when versioning is suspended (#2689) 2023-03-02 12:41:44 -06:00
Prakash Senthil Vel
c700ee491e fix luxon time parsing format to fix the invalid time in the logs screen (#2691) 2023-03-02 09:42:54 -08:00
Alex
65575751ff Release v0.24.0 (#2679)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>

Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
Co-authored-by: Benjamin Perez <benjamin@bexsoft.net>
2023-02-28 12:53:47 -08:00
Alex
cc28f88325 Update Operator version and fixed issue in operator console (#2686) 2023-02-27 23:53:41 -08:00
Harshavardhana
dd913decc6 Use global HTTP client whenever applicable (#2682) 2023-02-27 19:19:56 -06:00
jinapurapu
372852ee86 Fixed tooltip on Add Access Rule modal (#2683) 2023-02-27 09:42:04 -06:00
Alex
154974c24e Disabled Preview button for text files (#2680)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-02-23 15:25:04 -06:00
Daniel Valdivia
844041fc32 Upgrade Go Dependencies (#2676)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2023-02-23 09:55:40 -06:00
Alex
c23aff45c8 Hidden red notification in License menu when cluster is registered (#2678)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-02-21 19:12:03 -06:00
Daniel Valdivia
1b4eacb587 Remove Chartsjs and react-chartjs-2 (#2677)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2023-02-21 17:33:04 -06:00
Prakash Senthil Vel
f21434a971 Export import server config from settings page (#2664) 2023-02-21 11:50:04 -08:00
Alex
6c0e7baa87 Updated mds to v0.2.5 (#2675)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-02-21 09:41:09 -08:00
Alex
09fe3af6b7 Removed confirmation box in enable call home screen (#2674)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-02-21 10:28:09 -06:00
dependabot[bot]
50a6c61d0d Bump golang.org/x/net from 0.5.0 to 0.7.0 (#2672) 2023-02-20 19:38:35 -08:00
Daniel Valdivia
53b5fba532 Wordng updates on Call-Home (#2673)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2023-02-18 23:43:16 -08:00
Javier Adriel
a73b710313 Change updates service url (#2658) 2023-02-14 12:56:45 -06:00
Alex
404b1ef92e Restored ObjectManagerButton (#2665)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-02-14 11:36:49 -06:00
Alex
c3b7af9c89 Close Delete Object modal on Access Denied error. (#2661)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-02-14 09:56:09 -06:00
Alex
13d04b15de Fixed DateTime interaction with DateTimePickerWrapper & DateRangeSelector (#2657)
fixes #2655 
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-02-13 22:03:26 -08:00
Daniel Valdivia
88fdd3a456 Remove Unused Health Component (#2659)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2023-02-13 18:29:42 -06:00
Alex
de4ff1c1f0 Call Home Enabled in console (#2248)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-02-13 15:04:35 -08:00
Javier Adriel
a6637f18c8 Add fields to read json metadata (#2652) 2023-02-10 13:48:47 -06:00
Alex
d4031ee7b5 Display override settings with env variables (#2636)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-02-10 11:28:54 -08:00
Alex
7bf2b9601f Fixed RegisterCluster alignment (#2653)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-02-10 12:01:10 -06:00
Javier Adriel
6fbb4b568b Add handlers that will communicate with release service (#2651) 2023-02-09 12:49:07 -08:00
Alex
7a14f0c012 Release v0.23.1 (#2648)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>

Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
Co-authored-by: Benjamin Perez <benjamin@bexsoft.net>
2023-02-08 18:20:55 -08:00
Daniel Valdivia
e8f27228a2 Use latest Version of Operator for Testing (#2650) 2023-02-08 19:08:20 -06:00
jinapurapu
8346fe4bd6 Fixed permissions-2 inspect test (#2649)
Authored-by: Jillian Inapurapu <jillii@Jillians-MBP.attlocal.net>
2023-02-08 16:13:01 -08:00
Alex
d1b8d7240e Update mds version to v0.2.4 (#2647)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-02-08 14:11:52 -06:00
jinapurapu
274b16a1a6 Fixed text in AddEventDestination backlink for consistency (#2646) 2023-02-08 13:21:35 -06:00
Daniel Valdivia
b0d8c332e5 Rename Notification Endpoints (#2645)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2023-02-08 12:16:07 -06:00
Daniel Valdivia
ba1888b6c4 Remove unused components (#2641)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2023-02-08 11:17:16 -06:00
Daniel Valdivia
c0e47bafa4 Menu Tweaks and Rename Notifications to Events (#2639)
- Rename notifications to events.
- Add categories to event destinations
- Menu changes

Co-authored-by: jinapurapu <65002498+jinapurapu@users.noreply.github.com>
2023-02-07 21:19:17 -08:00
Alex
894f6ce131 Fixed Tenant License crash in tenant details (#2644)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-02-07 22:30:25 -06:00
Alex
f0b39a6b6b Updated copyright tags to 2023 (#2631)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-02-06 20:32:49 -08:00
Daniel Valdivia
24fdf3487b Move Register Component to Redux (#2630)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2023-02-06 13:51:39 -08:00
Shubhendu
900b8d9f06 Disable Audit Log and Monitoring by default (#2632)
While tenant creation, by default keep the Audit Log and Monitoring option disabled
2023-02-06 12:03:51 -08:00
Alex
58b45b8ebc Redesigned Logger Webhooks & Audit Webhooks pages (#2620)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-02-02 21:22:43 -08:00
Daniel Valdivia
606a69b92c Remove Unused Style code (#2629)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2023-02-02 22:42:15 -06:00
Allan Roger Reid
2c8b96c511 Expose error on Tenant if certificate is near expiration or expired (#2628) 2023-02-02 17:44:37 -08:00
Javier Adriel
38e6af1d09 Add tests for tenantEncryptionInfo (#2625) 2023-02-02 13:11:47 -06:00
Alex
32a289d563 Added runtime class name selector (#2626)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-02-01 20:58:19 -08:00
Daniel Valdivia
8d4d6eace0 Remove unused CSS Classes (#2623) 2023-02-01 18:37:18 -08:00
Alex
f337a8dce7 Updated Yarn dependencies (#2627) 2023-02-01 18:10:16 -08:00
jinapurapu
fba06cf651 Fix UI to access Support tools if registered (#2624) 2023-02-01 19:42:40 -06:00
Daniel Valdivia
fecf484eda Reformat imports (#2622)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2023-02-01 14:33:03 -08:00
Daniel Valdivia
34907856c5 Use MDS's BackLink (#2615)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2023-02-01 14:14:47 -06:00
Javier Adriel
4a2915a62b Use MDS's PageHeader (#2618) 2023-01-31 17:37:56 -06:00
Alex
8d51fe60f4 Update mds to v0.2.3 (#2617)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-01-31 13:53:58 -06:00
Daniel Valdivia
e96632a6b2 License Page Adjustments. Fix Object Browser double scroll. (#2616)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2023-01-31 13:15:28 -06:00
Daniel Valdivia
5ba7abaa79 Use MDS HelpBox (#2614)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2023-01-31 11:12:23 -06:00
Daniel Valdivia
451238d48b Disable Audit Logs by default on Tenant Creation (#2613)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2023-01-31 08:23:29 -08:00
Javier Adriel
8df91922ad Add test for tenantUpdateEncryption (#2611) 2023-01-30 16:34:33 -08:00
Anis Elleuch
34d62837fd Trust STS IDP connection when the url is localhost (#2603)
During SSO login, Console contacts MinIO server to generate new temporary credentials. When TLS is enabled, setting up a correct TLS certificate is something that needs to be done correctly by the user. However, recently, we started to skip the TLS verification when Console talks to MinIO server using a loopback address, but we missed the case of Console generating temporary credentials in case of IDP. This commit will get the configured MinIO server url to decide if the STS call needs to skip the TLS verification or not.

Co-authored-by: Anis Elleuch <anis@min.io>
2023-01-27 14:26:30 -08:00
Alex
ed281bbe4a Update mds to v0.2.1 (#2609)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-01-27 14:25:54 -08:00
Daniel Valdivia
b218cbf503 Anonymous Access (#2600)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2023-01-27 12:23:30 -08:00
Javier Adriel
c141b6d65e Add tests for setTenantMonitoring (#2608) 2023-01-26 18:35:49 -06:00
Alex
aacec617a8 Added bucket icons to object browser buckets listing (#2607)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-01-26 17:40:22 -06:00
Alex
ed19f3e1ad UI Fixes for License Plans page (#2605)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-01-26 14:45:39 -08:00
Javier Adriel
1374cf047e Add tests for updateTenantPools (#2602) 2023-01-26 10:30:52 -08:00
Daniel Valdivia
3a0e4c4f8c License Meta Tag (#2601)
Introduces a meta tag `minio-license` so that we can render the proper logo on login and menu
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2023-01-25 13:18:41 -08:00
Javier Adriel
b34b05f059 Tests for getTenantMonitoringResponse, getTenantUsage and getTenantPods (#2599) 2023-01-24 21:28:46 -06:00
Daniel Valdivia
579e8e05b7 Fix Login Warning (#2597)
Signed-off-by: Daniel Valdivia
<18384552+dvaldivia@users.noreply.github.com>
2023-01-24 11:17:00 -06:00
Daniel Valdivia
a0463f405d Github Action .nvmrc (#2596)
Signed-off-by: Daniel Valdivia
<18384552+dvaldivia@users.noreply.github.com>
2023-01-24 10:30:19 -06:00
Daniel Valdivia
ec344654db Release v0.23.0 (#2595)
Signed-off-by: Daniel Valdivia
<18384552+dvaldivia@users.noreply.github.com>
2023-01-23 20:32:40 -08:00
Daniel Valdivia
4aab5bc68f Fix Logout Warning (#2594)
Signed-off-by: Daniel Valdivia
<18384552+dvaldivia@users.noreply.github.com>
2023-01-23 21:56:37 -06:00
Alex
4c37afb446 Removed Force Delete from delete multiple objects request (#2592)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-01-23 19:53:20 -08:00
Daniel Valdivia
86115afc6b Upgrade Dependencies (#2589)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2023-01-23 19:51:29 -08:00
Alex
87399d1064 Fixed WS reconnection logic onError and onClose (#2591)
Removes duplicated reconnection request when error is reached on Object
Browser websocket, also removed the use of the connect call back as it
will contain references to the initial request and it is not necessary
as we already have information available.

Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-01-24 08:13:52 +05:30
Alex
a01b855d2f Fixed issues with ThemedLogo component implementation (#2588)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-01-23 14:17:50 -06:00
Harshavardhana
be39cb5af3 update gorilla/websocket to minio/websocket (#2587) 2023-01-23 13:48:21 -06:00
Javier Adriel
6930fd198c Add tests for setImageRegistry tenantAdministrators and tenantConfiguration (#2584) 2023-01-23 10:56:54 -08:00
Daniel Valdivia
62e822df4e License FAQ (#2581)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2023-01-23 10:33:15 -08:00
Daniel Valdivia
6466687a27 Update superagent dependency (#2586)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2023-01-23 10:15:23 -08:00
Javier Adriel
ccaaa21f16 Move adminClientMock methods to single file (#2583) 2023-01-23 10:10:51 -06:00
Javier Adriel
0595ec166d Add tests to update tenant security and identity provider (#2580) 2023-01-20 14:26:59 -08:00
Daniel Valdivia
72d1698242 Upgrade Go Dependencies and mds (#2582)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2023-01-20 14:26:22 -08:00
Alex
9321e00d0a Made Improvements to Console System (#2579)
- Removed Lato font references in code making Inter font as default
- Rejected direct requests to static assets folders

Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-01-19 11:15:28 -08:00
Javier Adriel
b03a49e4e1 Add tests for getTenantSecurity and getTenantIdentityProvider (#2578) 2023-01-19 11:44:55 -06:00
Javier Adriel
aa9f6f02ca Refactor and tests for adding tenant (#2577) 2023-01-13 11:11:40 -08:00
Allan Roger Reid
6a88d26054 Add tenant runtimeclass (#2565) 2023-01-12 14:27:53 -08:00
Daniel Valdivia
37db97dba9 Tests for User Objects (#2574)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2023-01-12 11:56:26 -08:00
Daniel Valdivia
0ccce2b2bc Update README.md screenshots (#2575)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2023-01-12 10:36:27 -08:00
Daniel Valdivia
58813eb4e0 Re-use MinIO latest binary (#2572)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2023-01-12 10:04:07 -08:00
Javier Adriel
5992edb3ba Refactor of tenant creation to make it more testable and readable (Phase 1) (#2571) 2023-01-12 09:17:57 -08:00
Daniel Valdivia
808e0ce3d5 Make remote buckets tests local (#2570)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2023-01-11 15:48:13 -08:00
Alex
534f3ec627 Release v0.22.5 (#2568) 2023-01-11 17:20:05 -06:00
Javier Adriel
9d37c9f743 Move mock k8s functions to one files (#2569) 2023-01-11 13:58:34 -08:00
Javier Adriel
1bad4c3da6 Add KMS UI (#2377)
Adds components to interact with KMS server connected to minio
2023-01-11 10:57:53 -08:00
Alex
9edb579156 Updated vulnerable dependencies (#2567)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-01-11 12:08:31 -06:00
Javier Adriel
d1aee5d431 Add tenants tests phase 1 (#2566) 2023-01-10 16:11:34 -08:00
Prakash Senthil Vel
dc8d4b4ca1 fix prometheus dashboard values for luxon migration (#2564) 2023-01-10 12:22:45 -06:00
Alex
35ab508109 Updated mds to v0.1.0 (#2563)
- Removed icons from console
- Replaced all icons & loaders in console with mds ones
- Renamed caret  icons
- Removed unused icons
- Replaced colored icons in object browser
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-01-09 14:35:46 -08:00
Javier Adriel
e01030820c Add tests for tenant logs (#2561) 2023-01-09 11:55:33 -08:00
dependabot[bot]
fab041b364 Bump luxon from 3.2.0 to 3.2.1 in /portal-ui (#2560) 2023-01-09 10:27:05 -08:00
Kaan Kabalak
e5da67d1bc Allow s3:Get* actions in Console (#2559) 2023-01-09 10:42:19 -06:00
Harshavardhana
bbc61930f9 always tidy-up go.mod (#2557) 2023-01-06 09:19:09 -08:00
Daniel Valdivia
40c789e7cb Github Actions v3 (#2556)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2023-01-05 21:54:55 -06:00
Alex
6084212bf6 Release v0.22.4 (#2542)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-01-05 16:23:34 -08:00
Daniel Valdivia
944b56751d Remove GKE Integration (#2552)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2023-01-05 17:54:12 -06:00
Pedro Juarez
c9e53542e0 Show the DNS helpbox on tenant edit, as is shown in tenant create (#2545) 2023-01-05 17:37:15 -06:00
Javier Adriel
7001067baa Increase threshold (#2555) 2023-01-05 17:31:32 -06:00
Alex
aece2251cf Migrated moment.js to Luxon (#2540)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-01-05 15:16:21 -08:00
Javier Adriel
756f0048f0 Add tests for admin info (#2553) 2023-01-05 14:54:00 -08:00
Daniel Valdivia
1cb2fca7a5 Increase coverage (#2551)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2023-01-05 14:36:21 -08:00
Kaan Kabalak
287af260b7 Fix Copy URL snackbar styling in Share File modal (#2549) 2023-01-05 14:27:36 -06:00
Daniel Valdivia
9fd76362dc Upgrade Go Dependencies (#2546)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2023-01-04 16:44:08 -08:00
Javier Adriel
733517fa76 Fix replication test (#2547)
Before the test was expecting an error while making the request but now the request is successful but it returns a 500 instead, this change will fix it
2023-01-04 15:07:03 -08:00
Daniel Valdivia
d8b3d0715f Change Go version to 1.19 (#2543)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2023-01-04 13:43:13 -08:00
Javier Adriel
1d951b28aa Allow Put* actions in console (#2544) 2023-01-04 12:51:46 -06:00
Alex
65ab6870e6 Updated mds to v0.0.9 (#2541)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-01-03 12:46:16 -06:00
Alex
255e3d14d0 Added delete governance bypass option when deleting file versions (#2536)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2023-01-03 10:35:37 -08:00
Javier Adriel
25e486ef18 Fix Operator login when openID provider is configured (#2533) 2023-01-03 10:35:15 -08:00
Alex
92123bd243 Changed selected styles for deleted rows (#2537)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-12-29 19:57:40 -06:00
Alex
6d5026d17e Update json5 & testcafe (#2538)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-12-29 17:11:17 -06:00
Prakash Senthil Vel
1e6ca131d9 update route path for idp screens as per menu placement (#2529) 2022-12-27 15:42:44 -06:00
Javier Adriel
21c6a441aa Upgrade jsonwebtoken - vulnerabilities found in current version (#2530) 2022-12-27 12:59:09 -06:00
Pedro Juarez
e23c110057 Run test with ubi 8.7 (#2532) 2022-12-22 14:26:18 -06:00
Kaan Kabalak
de16b73ce8 Capitalize Kubernetes in Login page text (#2526) 2022-12-22 09:49:02 -06:00
Alex
f269d67ec6 Release v0.22.3 (#2525)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-12-21 15:41:25 -08:00
Alex
7f3490974b First Phase of Luxon migration (#2521)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-12-21 11:56:05 -06:00
Javier Adriel
a42eef376d Support wildcard list actions (#2520) 2022-12-21 11:55:43 -06:00
Alex
bbf115dc71 Updated Login Front page for Console (#2522)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-12-21 10:33:05 -06:00
Prakash Senthil Vel
77bcdcfb08 fix crash on add user to group in user details (#2523) 2022-12-20 11:24:54 -06:00
jinapurapu
d713dc4933 Add Helpbox to Tier Type selector screen and adjust formatting (#2519) 2022-12-17 00:03:19 -06:00
Daniel Valdivia
0c9a6bf76b Tidy go.mod file (#2518) 2022-12-16 14:38:15 -06:00
Cesar Celis Hernandez
4c4094420b Ignoring message from MinIO (#2515)
As discussed with @harshavardhana , we should ignore the message on delete in the API. After @poornas changed in PR https://github.com/minio/minio/pull/16221 this message is expected and cannot be considered as an error.
2022-12-16 12:16:19 -08:00
Javier Adriel
96e55ca79b UI changes to IDP screen and remove old sections from settings screen (#2513) 2022-12-16 11:46:35 -08:00
jinapurapu
c61c5024d0 Add hover effect to Tier Type buttons (#2509) 2022-12-16 13:41:39 -06:00
Alex
f61d0a68d5 Implements CONSOLE_DEV_MODE env var (#2517)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-12-16 13:32:52 -06:00
Javier Adriel
f917f7d167 Remove commented jobs (#2514) 2022-12-16 09:33:12 -08:00
Alex
35541ef323 Fixed Delete all object versions selector functionality (#2516)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-12-16 11:07:40 -06:00
Daniel Valdivia
1f60d4a808 Tweaks to Menu and Bucket Details (#2512) 2022-12-15 18:45:31 -06:00
Alex
adc199b315 Made improvements to title bar & break points (#2508)
Removed extra margin & changed breakpoints for console / operator pages title bar
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-12-14 18:13:18 -08:00
Daniel Valdivia
f557c4c550 Split Object Browser and Buckets Admin (#2500)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-12-14 16:20:13 -08:00
Javier Adriel
0c4a73ff10 Do not regenerate assets for permissions-* tests (#2501) 2022-12-14 13:26:04 -08:00
jinapurapu
203e019e82 Add hover effect to Notification type selector buttons (#2502) 2022-12-14 14:38:34 -06:00
jinapurapu
4d2a39bad2 Added HelpBox to Notification Type Selector screen (#2503) 2022-12-12 22:08:20 -06:00
dependabot[bot]
db4fae3603 Bump d3-color from 2.0.0 to 3.1.0 in /portal-ui (#2504) 2022-12-12 17:51:10 -06:00
Daniel Valdivia
871789a236 Bump UI Dependencies (#2497)
Signed-off-by: Daniel Valdivia
<18384552+dvaldivia@users.noreply.github.com>
2022-12-12 14:44:51 -08:00
Javier Adriel
ba6fb53594 Increase test threshold (#2499) 2022-12-12 12:38:33 -08:00
Javier Adriel
5d74b21bc4 Reduce test execution times (#2498) 2022-12-12 12:37:53 -08:00
Javier Adriel
006490c753 Add admin subnet tests (#2490) 2022-12-11 23:16:30 -08:00
Daniel Valdivia
1614af0128 Upgrade Go Dependencies (#2496)
Upgraded all dependencies except for Kubernetes packages until we
validate 1.26

Signed-off-by: Daniel Valdivia
<18384552+dvaldivia@users.noreply.github.com>
2022-12-10 10:25:51 -08:00
Daniel Valdivia
27fd91ed37 Release v0.22.2 (#2495)
Signed-off-by: Daniel Valdivia
<18384552+dvaldivia@users.noreply.github.com>
2022-12-09 16:42:57 -08:00
Alex
7df0560104 Updated mds & fixed blank pages on login (#2494)
- Updates mds to v0.0.7
- Fixed an issue with blank pages during login
- Fixes an issue during logout where path was redirected to
'logout/login'

Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-12-09 14:24:58 -08:00
Javier Adriel
2368199e03 IDP management UI (#2487)
Adds UI to interact with IDP Configurations (CRUD)
2022-12-09 14:13:10 -08:00
Daniel Valdivia
bee98e1ba0 fix: race Condition on Object Browser via Websocket (#2492)
Signed-off-by: Daniel Valdivia
<18384552+dvaldivia@users.noreply.github.com>
2022-12-09 11:18:19 -08:00
Harshavardhana
8abbbb4625 avoid printing random logs (#2489) 2022-12-08 07:54:21 -08:00
Javier Adriel
ef182fe75e Increase threshold to 54.4 (Current coverage 54.5) (#2488) 2022-12-07 20:01:09 -06:00
Daniel Valdivia
613e93fdc6 Release v0.22.1 (#2486)
Signed-off-by: Daniel Valdivia <hola@danielvaldivia.com>
2022-12-06 14:41:25 -08:00
Javier Adriel
a5e3c89a54 Implement handlers for managing IDP (OpenID and LDAP) Configurations (#2485) 2022-12-06 14:33:17 -06:00
jinapurapu
7f55b71495 Add backend tier status checking to all tier types (#2420)
Moves Tier status check to backend for all Tier types.

![Screen Shot 2022-12-02 at 10 37 36
AM](https://user-images.githubusercontent.com/65002498/205370942-e20c0229-77b1-4a7c-9579-eebbd101c4ae.png)
![Screen Shot 2022-12-02 at 10 37 18
AM](https://user-images.githubusercontent.com/65002498/205370943-0d038206-b0e3-4597-9522-b21f94c36c0b.png)

Co-authored-by: Jillian Inapurapu <jillii@Jillians-MBP.attlocal.net>
Co-authored-by: Alex <33497058+bexsoft@users.noreply.github.com>
2022-12-06 12:13:14 -08:00
Alex
d95d59e454 Changed Object browser logic to work with websockets (#2419)
fixes https://github.com/minio/console/issues/943

## What does this do?

This allows us to start streaming results to the list instead of waiting
to retrieve all the objects list before sending it to the client

Included a couple of fixes:

- Removed metadata for deleted items
- Fixed multiple metadata requests
- Fixed height grow for parent wrapper
- Fixed object reload after restore version


Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-12-06 11:23:07 -08:00
Harshavardhana
08ea069ed4 change doc URL if UI is running in k8s (#2484)
Co-authored-by: Prakash Senthil Vel <23444145+prakashsvmx@users.noreply.github.com>
2022-12-06 09:53:01 -08:00
Javier Adriel
e7a41b4cd9 Call end_session_endpoint in IDP provider when login out from Console (#2476) 2022-12-05 18:14:41 -06:00
Alex
262a601d21 Release v0.22.0 (#2482)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-12-02 15:12:59 -08:00
dependabot[bot]
00af6b5179 Bump decode-uri-component from 0.2.0 to 0.2.2 in /portal-ui (#2481)
Bumps
[decode-uri-component](https://github.com/SamVerschueren/decode-uri-component)
from 0.2.0 to 0.2.2.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/SamVerschueren/decode-uri-component/releases">decode-uri-component's
releases</a>.</em></p>
<blockquote>
<h2>v0.2.2</h2>
<ul>
<li>Prevent overwriting previously decoded tokens  980e0bf</li>
</ul>
<p><a
href="https://github.com/SamVerschueren/decode-uri-component/compare/v0.2.1...v0.2.2">https://github.com/SamVerschueren/decode-uri-component/compare/v0.2.1...v0.2.2</a></p>
<h2>v0.2.1</h2>
<ul>
<li>Switch to GitHub workflows  76abc93</li>
<li>Fix issue where decode throws - fixes <a
href="https://github-redirect.dependabot.com/SamVerschueren/decode-uri-component/issues/6">#6</a>
746ca5d</li>
<li>Update license (<a
href="https://github-redirect.dependabot.com/SamVerschueren/decode-uri-component/issues/1">#1</a>)
486d7e2</li>
<li>Tidelift tasks  a650457</li>
<li>Meta tweaks  66e1c28</li>
</ul>
<p><a
href="https://github.com/SamVerschueren/decode-uri-component/compare/v0.2.0...v0.2.1">https://github.com/SamVerschueren/decode-uri-component/compare/v0.2.0...v0.2.1</a></p>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="a0eea469d2"><code>a0eea46</code></a>
0.2.2</li>
<li><a
href="980e0bf09b"><code>980e0bf</code></a>
Prevent overwriting previously decoded tokens</li>
<li><a
href="3c8a373dd4"><code>3c8a373</code></a>
0.2.1</li>
<li><a
href="76abc93978"><code>76abc93</code></a>
Switch to GitHub workflows</li>
<li><a
href="746ca5dcb6"><code>746ca5d</code></a>
Fix issue where decode throws - fixes <a
href="https://github-redirect.dependabot.com/SamVerschueren/decode-uri-component/issues/6">#6</a></li>
<li><a
href="486d7e26d3"><code>486d7e2</code></a>
Update license (<a
href="https://github-redirect.dependabot.com/SamVerschueren/decode-uri-component/issues/1">#1</a>)</li>
<li><a
href="a65045724e"><code>a650457</code></a>
Tidelift tasks</li>
<li><a
href="66e1c2834c"><code>66e1c28</code></a>
Meta tweaks</li>
<li>See full diff in <a
href="https://github.com/SamVerschueren/decode-uri-component/compare/v0.2.0...v0.2.2">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=decode-uri-component&package-manager=npm_and_yarn&previous-version=0.2.0&new-version=0.2.2)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)
- `@dependabot use these labels` will set the current labels as the
default for future PRs for this repo and language
- `@dependabot use these reviewers` will set the current reviewers as
the default for future PRs for this repo and language
- `@dependabot use these assignees` will set the current assignees as
the default for future PRs for this repo and language
- `@dependabot use this milestone` will set the current milestone as the
default for future PRs for this repo and language

You can disable automated security fix PRs for this repo from the
[Security Alerts page](https://github.com/minio/console/network/alerts).

</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-12-02 12:33:19 -06:00
Aditya Manthramurthy
5800d01406 Bump up madmin-go to v2 (#2479) 2022-12-01 20:55:21 -08:00
Aditya Manthramurthy
c803451920 Separate out dependency vulnerability checks in CI (#2480) 2022-12-01 14:17:46 -06:00
Lenin Alevski
95bdc70d1d Display warning for public access policy in bucket settings (#2473)
Signed-off-by: Lenin Alevski <alevsk.8772@gmail.com>
2022-11-23 09:10:14 -08:00
Prakash Senthil Vel
5d10197334 page header ux (#2475)
Closes [#1031](https://github.com/miniohq/engineering/issues/1031)
2022-11-23 09:09:47 -08:00
Prakash Senthil Vel
e7da6cd651 relax editing of endpoint in add site replication UI (#2474) 2022-11-22 09:07:16 -08:00
adfost
0f35369292 fix: incorrect IP and bucket regexes (#2469)
Fixes https://github.com/minio/console/issues/2453.
2022-11-21 13:30:32 -08:00
Daniel Valdivia
579845dfb1 Upgrade Go Dependencies (#2472)
Signed-off-by: Daniel Valdivia
<18384552+dvaldivia@users.noreply.github.com>
2022-11-21 11:58:14 -08:00
Alex
6ad5c16d3a Fixed logo visibility in Safari (#2470)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-11-18 14:09:00 -06:00
Alex
24176b5c7d Initial Changes to Login page styles (#2467)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-11-18 13:00:08 -06:00
jinapurapu
0b3b5979ba Local bucket creation time (#2464)
<img width="1327" alt="Screen Shot 2022-11-16 at 9 57 57 AM"
src="https://user-images.githubusercontent.com/65002498/202257455-ceb041b0-4db9-44f3-9fd3-cc73c89f4339.png">


Fixes https://github.com/minio/console/issues/2462

Authored-by: Jillian Inapurapu <jillii@Jillians-MBP.attlocal.net>
2022-11-16 15:40:22 -08:00
jinapurapu
dbec9fbb4a Fix UpdateTierCredentialsModal For MinIO tier (#2459) 2022-11-16 12:00:17 -06:00
Prakash Senthil Vel
7cd0bc7cac update airgap registration steps and instructions (#2463) 2022-11-16 11:36:21 -06:00
Javier Adriel
c12a931dbf Update madmin-go (#2460) 2022-11-15 20:29:36 -06:00
jinapurapu
f8af10dd26 Add permission guidance if User doesn't have permission to view Objects in bucket (#2448) 2022-11-15 19:18:37 -06:00
Alex
4c47b9c3e6 Updated loader utils to avoid ReDoS issue (#2461)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-11-15 18:22:37 -06:00
Alex
44f2fc67a3 Release v0.21.3 (#2458)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-11-15 12:16:09 -08:00
Anis Elleuch
ec1ba16ef7 prom: Fix leak when a call fails with the prometheus endpoint (#2456) 2022-11-15 12:09:58 -06:00
Prakash Senthil Vel
7a5724591a fix crash in ui for empty log entries (#2457) 2022-11-15 12:09:42 -06:00
Alex
9f433bc359 Release v0.21.3 (#2455)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-11-15 07:52:33 -08:00
Javier Adriel
1d45a174ac Add deprecated message in Audit logs section (#2437) 2022-11-14 13:06:55 -06:00
Alex
80cee32031 Fixed Table Action buttons roundness (#2451)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-11-14 12:58:01 -06:00
Prakash Senthil Vel
437cfd0b8e fix broken chart axis data for date time formatting (#2452) 2022-11-14 11:56:17 -06:00
jinapurapu
dc4dae6ddb Added formatting to required permssions in permissionTooltipHelper (#2447) 2022-11-14 09:48:06 -06:00
Alex
2f578010a0 New Menu Adjustments (#2450) 2022-11-13 10:23:55 -08:00
Prakash Senthil Vel
e7ec3fe61f fix sub path resource matching in list objects (#2444)
fixes #https://github.com/minio/console/issues/2400 

Used the policy to validate the fix.

```json

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "s3:ListBucket"
            ],
            "Resource": [
                "arn:aws:s3:::sam-card"
            ]
        },
        {
            "Effect": "Allow",
            "Action": [
                "s3:*"
            ],
            "Resource": [
                "arn:aws:s3:::sam-card/*"
            ]
        },
        {
            "Effect": "Deny",
            "Action": [
                "s3:*"
            ],
            "Resource": [
                "arn:aws:s3:::sam-card/aa/*"
            ]
        }
    ]
}

```
2022-11-10 11:27:40 -08:00
dilverse
7b389fc323 Add erasure info support (#2446)
Make it easier for user to see backend properties like backend-type,
Standard storage class Parity and Reduced Redundancy storage class
Parity
Co-authored-by: Prakash Senthil Vel <23444145+prakashsvmx@users.noreply.github.com>
2022-11-10 09:24:39 -08:00
Daniel Valdivia
86361b630e Tweak some icons to inherit color (#2445)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-11-09 11:05:39 -06:00
Lenin Alevski
c57df87bc3 Add yarn audit check on github actions (#2441)
Checks for known security issues with the installed packages

Signed-off-by: Lenin Alevski <alevsk.8772@gmail.com>

Signed-off-by: Lenin Alevski <alevsk.8772@gmail.com>
2022-11-08 19:20:47 -08:00
Lenin Alevski
cbbf3c5a53 selective version resolution for load-utils in react-scripts (#2442)
Signed-off-by: Lenin Alevski <alevsk.8772@gmail.com>

Signed-off-by: Lenin Alevski <alevsk.8772@gmail.com>
2022-11-08 13:03:50 -08:00
Daniel Valdivia
8a9fbb461c Release v0.21.2 (#2435)
Signed-off-by: Daniel Valdivia
<18384552+dvaldivia@users.noreply.github.com>
2022-11-07 21:03:03 -08:00
Alex
55b25cb003 Changed Styles & some routes for console menu (#2428)
Changed styles for menu
Changed Settings page title
Changed Service Account option to be Access Keys
Changed all Service Accounts labels to be Access keys in console

Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-11-07 15:32:10 -08:00
Thiago Bittencourt Gil
c929a71649 Removing slash at the end of GCS tier screen endpoint (#2430) 2022-11-07 14:23:50 -08:00
Harshavardhana
8af1bcd35c re-enable TestInspect() test (#2436) 2022-11-07 14:20:57 -08:00
Daniel Valdivia
ae2587dcad Increase STS Session duration to 12 hours (#2434)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-11-07 12:38:29 -08:00
Kaan Kabalak
cac8445aa1 Fix table row width not updating properly (#2433) 2022-11-07 12:13:54 -06:00
Javier Adriel
7eb98035e5 Move tenant logs logic to a new file (#2427)
Going to work and add new code on tenant logs so i make this small
refactor to keep things separated

Co-authored-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-11-04 10:14:56 -06:00
jinapurapu
7c75c87a0c Fixed ListBuckets screen tooltip logic, HelpBox fix (#2404) 2022-11-03 15:57:30 -06:00
jinapurapu
404efd2523 Fixed Users tab permissions to hide if CreateUser only User permission (#2426) 2022-11-03 11:43:19 -06:00
Quentin Dreyer
fc7d60e7ec Remove ADMIN_LIST_TIERS scope in BucketLifecyclePanel (#2384) 2022-11-03 11:35:21 -06:00
Alex
fbf3afd6fb Updated mds to v0.0.3 (#2423)
## What does this do?

Updated mds to v0.0.3

## How does it look?

<img width="1653" alt="Screenshot 2022-11-01 at 19 23 38"
src="https://user-images.githubusercontent.com/33497058/199374216-383023cc-83f7-4825-8b26-63135bd75fdb.png">


Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-11-03 09:58:11 -07:00
Kaan Kabalak
3f8f277841 Fix font size appearing smaller for links on AGPL consent modal (#2425) 2022-11-02 21:43:18 -06:00
Klaus Post
2ff44df636 Add inspection v2 (always encrypted) option. (#2386)
Depends on: https://github.com/minio/minio/pull/15474 for functionality
(which depends on this)

Blocks:  https://github.com/minio/minio/pull/15474

Keep v1 if non-encrypted and decrypt it.

Otherwise if encrypted, use a fixed public key.
2022-11-02 10:35:45 -07:00
Alex
83a612981e Made default EC:4 parity when available without restrictions (#2421)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-10-31 17:52:44 -06:00
jinapurapu
0ae1ace8fe Move tier status logic to backend (#2418) 2022-10-31 13:25:59 -06:00
Alex
a2745c687e Disabled support tools if cluster is not registered. (#2168)
- Redirect to register page when not register vars are set
- Added double column for register page

Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-10-28 13:04:30 -07:00
Paco Xu
e5e053a2ad stop using beta.kubernetes.io/os (#2416)
See https://github.com/kubernetes/kubernetes/issues/89477,
https://github.com/kubernetes/kubernetes/issues/89477#issuecomment-603911496.
2022-10-28 11:54:02 -05:00
jinapurapu
a5f89bb6d7 Improve Tier status accessibility (#2409) 2022-10-27 00:19:20 -07:00
jinapurapu
a53b569d0a Add "s3:*Bucket" permission to enable Delete, Create Bucket UI (#2401)
Co-authored-by: Jillian Inapurapu <jillii@Jillians-MBP.attlocal.net>
2022-10-26 13:29:55 -07:00
Kaan Kabalak
bcbebda39b Fix Filter box overlapping with header text (#2414) 2022-10-25 22:34:17 -07:00
Harshavardhana
a296850d58 remove cache from configurations tab (#2410)
'cache' is not supported in server deployments
and is not useful to be present in the configurations tab.
2022-10-24 14:16:55 -07:00
Kaan Kabalak
b609a4ee74 Remove extra Println statement (#2412) 2022-10-24 09:30:49 -05:00
Harshavardhana
5409a5eaa0 Release v0.21.1 (#2411)
Signed-off-by: Harshavardhana <harsha@minio.io>
2022-10-24 01:51:06 -07:00
Alex
6959bc5b02 Minimatch dependency update (#2408) 2022-10-21 13:10:06 -05:00
Prakash Senthil Vel
134700b432 fix preview modal title (#2406)
Issue: Long title is causing preview modal to scroll horizontally and
the close button is hidden.

post fix:


![image](https://user-images.githubusercontent.com/23444145/197127950-d6358a43-d795-461b-94da-0d698e987d98.png)
2022-10-21 10:37:38 -07:00
jinapurapu
483d25c3f3 Allow policy with "s3:*Object" to download using Console (#2396) 2022-10-20 20:40:23 -05:00
Alex
dab4eb7664 Fixes to Multiple IDP support in console (#2392)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-10-20 20:08:54 -05:00
Daniel Valdivia
139e90830f Upgrade go.mod dependencies (#2398)
Signed-off-by: Daniel Valdivia
<18384552+dvaldivia@users.noreply.github.com>
2022-10-20 17:26:23 -05:00
Harshavardhana
2e8ad9281d fix: typo in queue-dir and queue-limit for notification targets (#2403)
fixes #2402
2022-10-20 11:55:14 -07:00
Lenin Alevski
6b6cfd10f1 KMS certificates for Encryption configuration page (#2380)
- removed unused console certificate code in frontend
- fixed confirmation dialog not closing after submit form on encryption
page
- simplified kms mtls/ca certificates for tenant encryption
configuration

Signed-off-by: Lenin Alevski <alevsk.8772@gmail.com>

Signed-off-by: Lenin Alevski <alevsk.8772@gmail.com>
2022-10-19 12:32:08 -07:00
Cesar Celis Hernandez
5f07d45846 Moving away from Nancy (#2393)
`Nancy` test is failing and the issue is recent:
https://github.com/sonatype-nexus-community/nancy/issues/263

Move to more idiomatic https://pkg.go.dev/golang.org/x/vuln/vulncheck
2022-10-19 00:07:42 -07:00
Cesar Celis Hernandez
2dd92fd940 Removing old cache spot for permission test and incrementing the timeout. (#2395) 2022-10-18 21:28:43 -05:00
Anis Elleuch
40f64709a6 Skip TLS verif for local address (#2323)
Since the console is talking locally to MinIO, skip the TLS verification 
if any.

This will allow users to avoid defining the correct MINIO_SERVER_URL
domain address, when TLS is enabled, is useful in a bare-metal setup.
2022-10-17 12:34:05 -07:00
Alex
c31b311b4e Release v0.21.0 (#2389)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-10-14 21:30:21 -07:00
Aditya Manthramurthy
c316532fe9 fix: crosscompile windows build (#2391)
This is an attempt to fix the windows CI build issue.

The regression is appears to have been introduced in
d2d735c5c0
2022-10-14 21:29:36 -07:00
Aditya Manthramurthy
a65d6ba8f1 Add Role ARN as part of OIDC provider (#2382)
RoleARN needs to be used in the STS API call when present. 
Code to use this value needs to be added.
2022-10-14 15:46:25 -07:00
Kaan Kabalak
11f5d6aa0d Update Policy Summary once Raw Policy form is submitted (#2387) 2022-10-14 11:46:55 -05:00
jinapurapu
9532aa9500 Fixed handling of nil usage in getUsageWidgetsForDeployment (#2378) 2022-10-13 22:05:59 -05:00
Prakash Senthil Vel
ec3deed38e Site replication support for different accesskey and secretkey in different sites (#2350) 2022-10-13 17:11:29 -07:00
Alex
38015b4913 Updated golang.org/x/text dependency on console (#2381) 2022-10-13 16:10:16 -07:00
Cesar Celis Hernandez
e5508b5c5d Fix permission tests (#2379)
### Objective:

To fix Permission Tests

### Issue:

```
Cannot find module 'minio' or its corresponding type declarations.
```

### Solution:

To create the `assets` if there is no cache hit.

```sh
make assets
```

### Additional Information:

Update the version of the action.
2022-10-13 11:51:09 -07:00
Javier Adriel
9587e4105f Add missing KMS handlers for version, apis and metrics (#2376) 2022-10-12 12:00:48 -07:00
Harshavardhana
d2d735c5c0 upgrade all deps and keep go1.18 minimum (#2372) 2022-10-11 15:02:43 -07:00
Javier Adriel
915c10b4b8 Add kms to list of enable features if available (#2373) 2022-10-11 15:02:31 -07:00
Cesar Celis Hernandez
671530f5b4 Go back to Github runners while Datacenter is prepared (#2375) 2022-10-11 16:35:12 -05:00
Daniel Valdivia
0c778f57d3 Add Server Metrics Info Tab (#2340) 2022-10-07 21:19:40 -07:00
Cesar Celis Hernandez
43db7729c4 Splitting Operator UI Tests for faster execution (#2366) 2022-10-07 15:42:44 -05:00
jinapurapu
48b467a683 Added permission tooltips, UI and text improvements for Policies screens (#2368) 2022-10-07 12:58:08 -05:00
Javier Adriel
59b7406dd7 Implement KMS handlers (#2367) 2022-10-07 10:50:17 -07:00
Lenin Alevski
9e7a40abc8 Add support for manual edit of KES configuration file (#2354)
Signed-off-by: Lenin Alevski <alevsk.8772@gmail.com>
2022-10-07 10:15:56 -05:00
Cesar Celis Hernandez
189331f465 Set timeout in all permission tests (#2369) 2022-10-07 00:18:52 -07:00
jinapurapu
e6a2364209 Added tooltips, button permission UI, for Groups, GroupDetails screens (#2353) 2022-10-06 22:53:31 -05:00
Alex
2b17aa598f Added basename & location origin to logout button (#2370)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-10-06 22:48:13 -05:00
jinapurapu
f10fdf4610 Show Tiers status (#2291)
closes https://github.com/miniohq/engineering/issues/681

Authored-by: Jillian Inapurapu <jillii@Jillians-MBP.attlocal.net>
2022-10-06 18:11:28 -07:00
Alex
4156fe0666 Removed position fixed to tenant size preview (#2364)
## What does this do?

Removed position fixed to tenant size preview to avoid overlap of create
buttons

## How does it look?
<img width="1698" alt="Screen Shot 2022-10-05 at 22 15 12"
src="https://user-images.githubusercontent.com/33497058/194206392-62718458-7417-4a01-a2e0-219d22a25483.png">



Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-10-06 00:55:18 -05:00
Alex
89bef6027c Fixed edit yaml buttons position (#2363)
## What does this do?

Fixes the position of save buttons in edit tenant YAML screen

## How does it look?
<img width="1442" alt="Screen Shot 2022-10-05 at 21 48 08"
src="https://user-images.githubusercontent.com/33497058/194203074-cd363ff4-02fd-4f60-ab52-6daca1d0fab5.png">


Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-10-05 22:16:42 -05:00
jinapurapu
333ca0a827 Permissions Tooltip guidance for ListUsers and UserDetails screens (#2347) 2022-10-05 18:34:31 -05:00
Cesar Celis Hernandez
de82a056e6 Improve Permissions Tests Part 1 (#2359)
### Objective:

To fix `Permissions Tests Part 1 (1.18.x, ubuntu-latest)`

### Strategy:

To make test more reliable, it has been isolated in folder `A` and `B`,
letting other tests to properly pass. And if new failure is observed, it
will be either in folder `A` or `B` for `iamPolicies.ts` and
`bucketWritePrefixOnly.ts` respectively.

### Root cause:

`iamPolicies.ts` and `bucketWritePrefixOnly.ts` are not stable tests
when running together with other tests, some sort of racing condition
that can be improved by isolating them.

### All tests are passing, same code:

<img width="435" alt="Screen Shot 2022-10-05 at 5 48 54 PM"
src="https://user-images.githubusercontent.com/6667358/194170348-cdba42ca-08a0-4db4-9543-f2f682ba6603.png">
2022-10-05 18:33:43 -05:00
Daniel Valdivia
a01b1ffe8c Update Favicon (#2360)
Signed-off-by: Daniel Valdivia
<18384552+dvaldivia@users.noreply.github.com>

Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-10-05 14:31:55 -07:00
jinapurapu
61718a5915 Size handling for CounterCard long value (#2345)
Avoids overlap of counterValue text and Browse button.
![Screen Shot 2022-09-30 at 10 42 41
AM](https://user-images.githubusercontent.com/65002498/193326883-9379f6de-73c7-4fee-a5e5-0e50bd052359.png)

Co-authored-by: Jillian Inapurapu <jillii@Jillians-MBP.attlocal.net>
Co-authored-by: Alex <33497058+bexsoft@users.noreply.github.com>
2022-10-04 15:10:59 -07:00
Prakash Senthil Vel
2fed3572b2 License page updates (#2356)
How does it look:


![image](https://user-images.githubusercontent.com/23444145/193804863-3e3e7207-3284-4be9-bb49-de38a58f744c.png)

Fixes #https://github.com/miniohq/engineering/issues/983

Co-authored-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-10-04 14:57:20 -07:00
jinapurapu
af9e4fc150 Fixes for Permission tests (#2351)
Updates location of Policies screen, adds required policies to testing
profiles

Authored-by: Jillian Inapurapu <jillii@Jillians-MBP.attlocal.net>
2022-10-04 13:56:28 -07:00
Harshavardhana
f8475af5a6 do not log random errors using Go logger (#2355)
we need to make sure that we print in consistent
format for the logs, remove the unnecessary logs
everywhere used via `log.Print*`
2022-10-04 10:39:28 -07:00
Harshavardhana
413870e995 update madmin-go and mc deps for new changes (#2352) 2022-10-02 23:04:34 -07:00
Daniel Valdivia
cdd6f272ed Release v0.20.5 (#2349)
Signed-off-by: Daniel Valdivia
<18384552+dvaldivia@users.noreply.github.com>

Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-09-30 01:51:41 -07:00
jinapurapu
5eddd0cd8d Permission Error handling and Tooltips for upload file, object action buttons (#2338)
![Screen Shot 2022-09-26 at 11 51 34
AM](https://user-images.githubusercontent.com/65002498/192357633-2f551441-8c27-450e-873e-1766d388cdb0.png)

<img width="706" alt="Screen Shot 2022-09-23 at 11 38 59 AM"
src="https://user-images.githubusercontent.com/65002498/192035299-093f814e-4821-4610-8fc5-c20565ea7c38.png">
<img width="642" alt="Screen Shot 2022-09-23 at 11 47 15 AM"
src="https://user-images.githubusercontent.com/65002498/192036512-f8891625-e050-42fd-9c43-173dd61c4df3.png">
2022-09-30 00:17:42 -07:00
Harshavardhana
5cf2b736e1 ignore configs with no KVs and simplify config builder (#2342)
convert all \n to ','
2022-09-30 00:16:47 -07:00
Daniel Valdivia
55330960e9 Move Access to Policies under Identity (#2348)
Signed-off-by: Daniel Valdivia
2022-09-29 22:55:21 -05:00
Lenin Alevski
a3b88567cc Add support for edit/add/remove environment variables to MinIO tenant (#2331)
![image](https://user-images.githubusercontent.com/1795553/191574784-69d55ca6-0a8c-41f3-b7f5-8526854cc8d2.png)


Signed-off-by: Lenin Alevski <alevsk.8772@gmail.com>

Signed-off-by: Lenin Alevski <alevsk.8772@gmail.com>
2022-09-29 20:50:35 -07:00
Daniel Valdivia
73a687376a Fix IDP not having same salt/passphrase across pods (#2346)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-09-29 15:44:17 -07:00
jinapurapu
de4c08c2ff Fixed overhanging Browse button on Bucket card (#2343) 2022-09-29 14:14:31 -05:00
Harshavardhana
9396df2e20 remove unnecessary trace and threads profiling (#2341) 2022-09-28 14:32:14 -05:00
Alex
4143f50004 Release v0.20.4 (#2337)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-09-27 21:10:42 -07:00
Alex
d1511c5eb0 Limit concurrent downloads & uploads (#2313) 2022-09-23 10:35:55 -07:00
jinapurapu
c4c6d48abf Tooltips for Bucket Lifecycle, Delete bucket, Manage bucket (#2334) 2022-09-23 12:30:37 -05:00
Alex
43c5f9094a Tenant details navigation issues fix (#2336)
Fixes issues with Tenant details page navigation

- Back issue between tenant summary & tenants list page
- Not show the selected tab correctly on tenant details after clicking
back on browser's back button

Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-09-23 12:30:18 -05:00
Javier Adriel
51ab9c59ae Update minio/pkg v1.4.0 (#2335) 2022-09-23 12:08:24 -05:00
Aditya Manthramurthy
fc95ab8658 Fix oauth state generation for OIDC login (#2333)
This is a regression from 118cf97e1d when
env var support for passing console configuration from MinIO was
removed.

This change ensures that all MinIO nodes in a cluster are able to verify
state tokens generated by other nodes in the cluster. Without this, it
is necessary to use sticky sessions in a loadbalancer to ensure that
OIDC authorization code login flow steps for a client happens on the
same minio node.

Fixes https://github.com/minio/minio/issues/15527
2022-09-23 10:30:45 -05:00
Daryl White
bebe860903 Updating documentation links to new URLs (#2325)
The new doc site has launched, and all docs have new URLs.
This PR updates the documentation URLs in the Console to point to the
new locations.
2022-09-22 22:37:32 -07:00
Kaan Kabalak
df4679ea55 Fix styling for Create New Path button in Buckets page (#2330)
Fixes #2329
2022-09-21 19:11:58 -05:00
Alex
2263eada70 Release v0.20.3 (#2328)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-09-20 23:54:10 -07:00
Lenin Alevski
368c9ee3d7 InputBoxWrapper automatically add hide/show behavior for password fields (#2327)
Signed-off-by: Lenin Alevski <alevsk.8772@gmail.com>
2022-09-20 23:13:34 -05:00
jinapurapu
3513a01711 Add Bucket tooltip improvements (#2326) 2022-09-20 19:12:18 -07:00
Lenin Alevski
0af36a5757 Add: Allow to configure env variables during tenant creation (#2322)
Signed-off-by: Lenin Alevski <alevsk.8772@gmail.com>
2022-09-20 18:58:31 -05:00
Daniel Valdivia
fdd5a94074 Fix NPE on Operator Login with SSO (#2324)
Signed-off-by: Daniel Valdivia
2022-09-20 18:57:48 -05:00
Javier Adriel
17ad2cfd14 Add dummy endpoints for kms integration (#2301)
Add dummy endpoints for kms integration

Implementation will come in another PR
2022-09-20 16:09:30 -07:00
Daniel Valdivia
67f509e2bb Release v0.20.2 (#2321)
Signed-off-by: Daniel Valdivia <hola@danielvaldivia.com>
2022-09-16 16:02:12 -07:00
Benjamin Marte
6102094c9e Adds a logout view which enables minio to logout when using OIDC (#2281)
* added logout view
* Fixed issues that arose after merging with master
* removed unused navigate and merged with master
* changes based on review feedback
Co-authored-by: Alex <33497058+bexsoft@users.noreply.github.com>
Co-authored-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-09-16 14:21:58 -07:00
Lenin Alevski
d84062b1b2 Fix: Labels for Node Selector in Pod Placement (#2320)
Enabling/disabling buttons correctly in pod placement > labels to be
consistent with all other screens in the application

Signed-off-by: Lenin Alevski <alevsk.8772@gmail.com>
2022-09-16 13:24:45 -07:00
jinapurapu
a878440485 Added permissions guidance on ListBuckets and AddBuckets screens (#2319)
Added helpbox and tooltip guidance on ListBucketsand AddBuckets screens
Added bucketname to resource checking for bucket level config permissions
2022-09-16 13:22:20 -07:00
Kaan Kabalak
cd6e61e93b Don't show Bucket Name input error until field is touched (#2316) 2022-09-16 13:48:02 -05:00
jinapurapu
a77b56b522 Toggle Bucket Naming Rules display by clicking text (#2311) 2022-09-16 13:12:47 -05:00
Cesar Celis Hernandez
6ed5084691 To add missing file for coverage (#2318) 2022-09-15 19:36:00 -05:00
Daniel Valdivia
4ac6ecb558 Return 401 for Login Errors (#2312)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-09-15 15:33:53 -05:00
Alex
41671b4f25 Fixed crash in simple dashboard when one disk has failed (#2314)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-09-15 14:26:00 -05:00
jinapurapu
024ab1212b Add Minio tier type (#2302) 2022-09-15 14:00:39 -05:00
jinapurapu
77f62e11ef Tiers permission UI fix (#2310) 2022-09-15 11:36:30 -05:00
Cesar Celis Hernandez
0960835cd9 To migrate all testcafe (#2309) 2022-09-14 12:22:27 -07:00
Cesar Celis Hernandez
3746dd47f8 To migrate Permissions Tests Part 1 test (#2299)
migrate all-permissions-1
2022-09-12 20:59:33 -04:00
Cesar Celis Hernandez
ce255c5181 To migrate site replication test (#2276)
Migrate site replication test
2022-09-12 20:01:24 -04:00
Alex
7728cc734a Inherits error props to tooltip wrapper child buttons (#2307) 2022-09-11 23:29:30 -07:00
Lenin Alevski
cc581c6a9e fix: login function was returning fixed error (#2308) 2022-09-11 23:28:07 -07:00
Alex
f7b142e74a Replacing all buttons from console with mds (#2303)
Replaces buttons in console to start using MinIO Design System (mds)

Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-09-09 17:42:30 -05:00
Harshavardhana
1108cee626 do not add preceding '/' for putRequests (#2306) 2022-09-09 15:33:58 -05:00
Javier Adriel
94fdba5990 Run lint in missing files (#2300) 2022-09-08 11:13:22 -05:00
Cesar Celis Hernandez
524258a9ea To migrate react warning test (#2273) 2022-09-06 17:49:45 -05:00
Alex
c0cf7a6d6a Release v0.20.1 (#2298)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-09-06 14:15:33 -07:00
Daniel Valdivia
f9916d1cd6 Update Site Replication Documentation link (#2297)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-09-06 12:39:14 -05:00
Cesar Celis Hernandez
52512c0ccc To repair the Operator API Tests & Operator UI Tests (#2292) 2022-09-06 09:19:31 -07:00
Lenin Alevski
989f041658 Support for providing Tenant client certificates (#2294) 2022-09-06 10:20:16 -05:00
Cesar Celis Hernandez
2f81b750a3 To repair SSO test (#2295) 2022-09-06 00:12:16 -07:00
Kaan Kabalak
035a5b88c2 Add support for Multiple IDPs on Login screen (#2258) 2022-09-03 11:02:48 -05:00
Alex
7702149962 Added missing prefix for downloads (#2286)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-09-03 10:01:45 -05:00
Alex
f3e24d62ca Fixed Visual height for Sites Replication (#2293) 2022-09-03 01:27:33 -05:00
jinapurapu
d663b9f346 Display configured logger_webhook endpoints (#2279) 2022-09-01 15:23:55 -05:00
Harshavardhana
ae147358b1 upgrade minio-go/v7 v7.0.35 (#2288)
changes LDAP/SSO to send login via
form body instead of query params
2022-08-31 21:59:40 -07:00
Alex
20bc53119e Filtered prefixes in versions list (#2285)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-08-30 18:28:16 -05:00
jinapurapu
3a3a4b2fea Interactive Bucket Naming Rules component (#2262) 2022-08-30 13:02:10 -05:00
Alex
497437729b Select User & Groups Policy modal updates (#2284)
Select User Policy modal updates

Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-08-30 12:06:59 -05:00
Harshavardhana
1c37fcf398 update UBI base image to 8.6 2022-08-29 23:48:28 -07:00
Cesar Celis Hernandez
67af66fc55 Format all files after swagger-gen (#2283) 2022-08-29 22:53:50 -05:00
Cesar Celis Hernandez
288c843a17 Catch error in gofmt (#2266) 2022-08-29 19:28:39 -05:00
Cesar Celis Hernandez
9357c2db0e Formatting missing areas with gofmt (#2278)
Co-authored-by: Lenin Alevski <alevsk.8772@gmail.com>
2022-08-29 18:04:09 -04:00
Lenin Alevski
139771f4d4 Fixes and improvements for Tenant Security page (#2252)
- Tenant securityContext was only being applied to first pool
- Fixed style issues on tenant security page to be more consistent
- Added missing FsGroupChangePolicy in the SecurityContextSelector
  component

Signed-off-by: Lenin Alevski <alevsk.8772@gmail.com>
2022-08-29 15:35:23 -05:00
Alex
b7783aaa1c Removed double border in raw policy / yaml containers (#2277)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-08-26 18:41:28 -05:00
Ashish Kumar Sinha
9821beb1de read license from envt variable (#2259) 2022-08-26 18:09:15 -05:00
Cesar Celis Hernandez
d279f722f8 Migrate reuse golang dependencies (#2275) 2022-08-26 16:57:27 -05:00
Cesar Celis Hernandez
9539a8e18a Migrate semgrep to datacenter (#2271) 2022-08-26 15:30:33 -05:00
Alex
f11b9bff17 Improved policy create policy screen (#2268)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-08-26 13:07:42 -05:00
Aditya Manthramurthy
06c282dd9a Fix config parsing bug with updated madmin helper (#2264) 2022-08-25 10:45:07 -07:00
Cesar Celis Hernandez
3e9fb853d9 Correct gofmt version 1.19 (#2267) 2022-08-25 11:44:55 -05:00
Alex
cd21ad2085 Fixed erratic behavior in configuration pages (#2269)
- Issue with fields being cleared in forms with CSV component present
- Load configuration panels on section change

Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>

Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
Co-authored-by: Benjamin Perez <benjamin@bexsoft.net>
2022-08-25 09:22:05 -05:00
Cesar Celis Hernandez
729100ae16 Execute Lint Job with Self Hosted Runner (#2265) 2022-08-24 22:09:07 -05:00
Cesar Celis Hernandez
bcd29a4232 Migrate vulnerable-dependencies-checks to datacenter (#2263) 2022-08-24 19:34:16 -05:00
Minio Trusted
380a9d7faa update go mod tidy
Signed-off-by: Harshavardhana <harsha@minio.io>
2022-08-22 23:59:23 -07:00
Alex
9cd0033504 Release v0.20.0 (#2261)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-08-22 23:27:22 -07:00
Aditya Manthramurthy
483fe77a35 Fix config parsing using updated method (#2251)
Fix config parsing using madmin and mc bump up

- The config parsing client-side logic is updated in madmin-go

- This change also has fixes associated with breakage caused by bumping
up the mc dependency
2022-08-23 00:27:26 -05:00
jinapurapu
1742303ad7 Changed timestamp to date format in widgets CSV download (#2253) 2022-08-22 10:34:49 -05:00
jinapurapu
292fb3920f Created button to download Widget data as CSV or PNG file (#2241) 2022-08-19 12:48:15 -05:00
Javier Adriel
9ed8f11b22 Change register tabs (#2250)
Co-authored-by: Alex <33497058+bexsoft@users.noreply.github.com>
2022-08-17 18:32:10 -05:00
Prakash Senthil Vel
860d8c6b78 UI to delete configured notification targets (#2213) 2022-08-17 15:40:37 -05:00
Alex
99965805a6 Reimplemented DirectPV API in operator console (#2207)
- Updated API to use latest directpv library

Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-08-17 13:05:07 -05:00
Alex
7036d1328e Added Color customization to embedded object browser (#2246)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-08-17 11:06:10 -05:00
Lenin Alevski
697910c7b2 fix: buckets browse button was not clickable (#2249)
Signed-off-by: Lenin Alevski <alevsk.8772@gmail.com>
2022-08-16 18:23:48 -05:00
Kaan Kabalak
64dc605843 Fix inconsistencies in Health Diagnostics UI (#2239) 2022-08-12 22:45:08 -05:00
jinapurapu
75fa88e6e2 Added delay to Audit Log tests to reduce failure (#2245) 2022-08-12 22:44:27 -05:00
Alex
2857b8c586 Release v0.19.5 (#2243) 2022-08-10 20:43:36 -07:00
Alex
b1788c29db Disabled Object Locking button when permissions are not set (#2226)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>

Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
Co-authored-by: Benjamin Perez <benjamin@bexsoft.net>
2022-08-10 22:15:18 -05:00
jinapurapu
2e1401f013 Increased delay to reduce failure of Operator UI test (#2240) 2022-08-10 16:12:55 -05:00
Alex
1e1c11b13c Added FSGroupChangePolicy support to create tenant screen (#2233)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>

Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
Co-authored-by: Benjamin Perez <benjamin@bexsoft.net>
2022-08-10 13:28:15 -05:00
Javier Adriel
25c1c854b1 Add new section to register tenants with API key in operator (#2222) 2022-08-09 13:23:15 -05:00
Javier Adriel
5be2cc1965 Implement register handlers (#2219) 2022-08-09 13:22:53 -05:00
Alex
4aa3f40792 Removed permanent scrollbar in embedded object browser (#2237)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-08-09 12:02:09 -05:00
jinapurapu
3f41a82fd3 Image field fix (#2231) 2022-08-09 11:04:43 -05:00
Harshavardhana
1b641b4222 return bad request instead of 403's (#2229)
S3 API requests '403' as valid error
in some situations when client is probing
the server for valid S3 endpoint.

return '400 Bad Request' instead.
2022-08-08 15:37:01 -05:00
jinapurapu
85aabebbb4 Added text to AddBuckets Helpbox advising to enable versioning to enable retention (#2235)
Added hepbox guidance text to enable versioning in order to set retention on bucket creation
2022-08-08 14:08:08 -05:00
Pedro Juarez
919232261d switch to node version specified in .nvmrc file (#2225) 2022-08-05 17:54:47 -07:00
Harshavardhana
ddd25a20eb update CREDITS and enable builds for go1.19 (#2227) 2022-08-05 10:07:38 -05:00
Harshavardhana
84b8f9d6fa support P-384, P-512 constant time implementations (#2224)
fixes #2223
2022-08-04 15:36:38 -07:00
jinapurapu
46af0ff74c Protocol Logos for Add Tenant - Identity Provider (#2210) 2022-08-04 09:14:38 -07:00
Javier Adriel
b3651ed0a3 Auto register API key once it is retrieved from subnet (#2217) 2022-08-03 09:43:22 -07:00
Alex
78c4fa393a Changed x axis notation to display date indicator in zoom mode (#2221)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-08-02 22:23:27 -07:00
Kaan Kabalak
84c4159062 Fix anchors and update links for License page features (#2220) 2022-08-02 20:30:16 -05:00
Javier Adriel
ac2888fc4e Implement login and api key handlers (#2204) 2022-08-02 10:41:12 -05:00
Alex
c311847dcf Changed wrong button structure un buckets list page (#2218)
Also fixed issue with tests part 3 workflow

Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-08-01 22:04:51 -05:00
Harshavardhana
cb6cda7265 fix: crash in operator console for missing fsGroup (#2211)
Bonus: Add support for "fsGroupChangePolicy"
Bonus: keep only github actions in workflow folder
2022-08-01 19:04:00 -07:00
Cesar Celis Hernandez
16fd5470db Correcting response on invalid login attempt (#2216)
Verifying detailed message error from bad login in SSO Test
2022-08-01 18:12:39 -05:00
jiuker
ea0cac2a92 fix:Incorrect template (#2196)
The formatting template is incorrectly formatted.
2022-08-01 17:44:35 -05:00
Alex
33b041ef34 Fixed incompatibility with some base64 strings & React Router v6 (#2208)
* Fixed incompatibility with some base64 strings & React Router v6

This affected Object Browser & certain Cyrillic / Chinese names

Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-08-01 15:15:03 -05:00
Garen Chan
b692ea693f Fix error: setMultiBucketReplication healthCheckPeriod not work (#2212) 2022-08-01 13:12:54 -07:00
Cesar Celis Hernandez
fd39e50c08 Updating SSO Error Message on bad login (#2215)
Updating error message on bad sso login
2022-08-01 14:09:07 -05:00
Alex
ad4b9c050a Added DirectPV mode to Operator console (#2203)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-08-01 12:57:31 -05:00
Alex
1deb6371ed Release v0.19.4 (#2209)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-07-29 13:12:41 -07:00
Aditya Manthramurthy
3b11556f4b Fix build after swagger codegen (#2201) 2022-07-28 13:20:16 -07:00
Lenin Alevski
25f719b0e2 TLS Certificates help box and small bug fixes (#2206)
- Added TLSHelpBox component
- fix: Use the right `add` icon component in the security tab to be consistent
- fix: Add/Remove additional certificates button for custom certificates
- fix: Add/Remove additional users button for built-in IDP

Signed-off-by: Lenin Alevski <alevsk.8772@gmail.com>
2022-07-28 14:18:28 -05:00
Alex
231b63f1b0 Added duration param to speedtest (#2205) 2022-07-27 21:00:54 -05:00
Javier Adriel
e73370cc8c Add dummy subnet handlers (#2198) 2022-07-27 16:34:19 -07:00
Javier Adriel
5d25dd4c06 Improve marketplace test coverage (#2202)
* Improve marketplace test coverage

* gofumpt
2022-07-27 16:33:56 -07:00
Kaan Kabalak
51a8bacc18 Implement WebSockets for Profile download (#2190) 2022-07-26 18:40:24 -07:00
Harshavardhana
db07f546a4 Release v0.19.3
Signed-off-by: Harshavardhana <harsha@minio.io>
2022-07-24 09:51:03 -07:00
Harshavardhana
255cf0bc85 fix: hard regression in console login from v0.19.2 release
fixes #2197
2022-07-24 09:41:55 -07:00
Harshavardhana
733e0b18e2 make sure build works for now 2022-07-22 22:47:08 -07:00
Daniel Valdivia
8d90e03992 Release v0.19.2 (#2194)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-07-22 22:15:03 -07:00
Cesar Celis Hernandez
1a1fae9ce3 Use intended console code in compiled MinIO (#2193) 2022-07-22 22:14:46 -07:00
Alex
f26786c904 Fixed Tiers load when information from tierStats is not available (#2191)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-07-22 12:40:38 -07:00
Javier Adriel
e0b6bf5aa6 Register api key section (#2180)
Split register section in tabs
Add register API key section
2022-07-22 11:27:53 -07:00
Daniel Valdivia
9655fc4490 Fix operator login not showing error (#2185)
* Fix operator login not showing error

Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>

* Fix Test

Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-07-22 12:21:25 -05:00
dependabot[bot]
417ea4d481 Bump terser from 5.14.0 to 5.14.2 in /portal-ui (#2187)
Bumps [terser](https://github.com/terser/terser) from 5.14.0 to 5.14.2.
- [Release notes](https://github.com/terser/terser/releases)
- [Changelog](https://github.com/terser/terser/blob/master/CHANGELOG.md)
- [Commits](https://github.com/terser/terser/commits)

---
updated-dependencies:
- dependency-name: terser
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-07-22 11:57:54 -05:00
Daniel Valdivia
5a59f8e3f4 iFrame Header when embedding (#2189)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-07-22 00:03:52 -07:00
jinapurapu
48340d0010 Fixed jumpy switch for Proxy configuration on Register screen (#2186) 2022-07-21 19:12:01 -05:00
Lenin Alevski
251de9fe8a Add support for adding LDAP admins based on user/group DNs (#2178)
Signed-off-by: Lenin Alevski <alevsk.8772@gmail.com>
2022-07-20 18:27:11 -07:00
Javier Adriel
c501df927b Split register section in tabs (#2176) 2022-07-20 18:26:43 -07:00
Daniel Valdivia
cdb1659506 Fix redirect to login base url. (#2182)
No longer needed due to baseUrl in the react router
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-07-20 16:23:24 -07:00
Lenin Alevski
558afe36ad Various fixes for Tenant details page (#2181)
- fixed refresh tenant details page after changing Domains and updating
  image
- Relax tenant domains to allow including port number

Signed-off-by: Lenin Alevski <alevsk.8772@gmail.com>
2022-07-20 11:55:19 -05:00
Alex
712d3870eb Fixed storage class selectors for add & edit pool wizards (#2183)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-07-20 10:11:56 -05:00
NaccOll
c71f084531 feat: subpath support using reverse proxy (#2174) 2022-07-19 19:32:20 -07:00
jinapurapu
1c58a543b6 Monitoring and Audit Log config screen UI tests (#2179) 2022-07-19 19:10:21 -05:00
Alex
8e857dc563 Updated security issue with glob-parent dependency (#2177)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-07-18 19:00:48 -05:00
Javier Adriel
78d4d4c89e Add endpoint to get api key from subnet (#2175) 2022-07-18 17:51:07 -05:00
Alex
aea749d82f Added Loader in rewind enable function (#2172)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-07-18 15:39:14 -05:00
jinapurapu
ce3293b4e2 Added Testcafe test for Audit Logging text fields (#2173)
Added Testcafe test for Audit Logging text fields, fixed bug in setting serviceAccount
2022-07-15 17:06:33 -05:00
jinapurapu
0c12fbdd23 Tenant Monitoring Screen TestCafe UI tests (#2161) 2022-07-15 14:06:48 -05:00
Aditya Manthramurthy
118cf97e1d Allow multiple IDPs config to be passed via struct (#2167)
* Allow multiple IDPs config to be passed via struct

* This removes support for ENV based IDP configuration for console

* Ensure default scopes are used if none are given

* Add display name field for provider config
2022-07-14 07:27:45 -07:00
jinapurapu
abb668633b Added bucket naming rules to Add Bucket help text (#2171) 2022-07-13 14:05:37 -07:00
jinapurapu
dd2fffd3dc Tenant security context component (#2139)
Added edit Security Context component to Tenant Security screen, and updated API and backend to enable editing
2022-07-13 14:05:07 -07:00
Harshavardhana
64b13e9dc9 Remove pkg.MPSECRET unused value 2022-07-12 13:59:36 -07:00
Alex
58d7f1e8ae Release v0.19.1 (#2169)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-07-12 13:51:11 -07:00
dependabot[bot]
45e4a94416 Bump moment from 2.29.3 to 2.29.4 in /portal-ui (#2164)
Bumps [moment](https://github.com/moment/moment) from 2.29.3 to 2.29.4.
- [Release notes](https://github.com/moment/moment/releases)
- [Changelog](https://github.com/moment/moment/blob/develop/CHANGELOG.md)
- [Commits](https://github.com/moment/moment/compare/2.29.3...2.29.4)

---
updated-dependencies:
- dependency-name: moment
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-07-07 14:53:04 -05:00
jinapurapu
cce054bbe8 Create security context component and add to edit Prometheus Monitoring (#2115) 2022-07-07 14:52:30 -05:00
Alex
cf0e326b82 Object Browser only mode (#2157)
- Added flag CONSOLE_OBJECT_BROWSER_ONLY=on to trigger between console mode & Object Browser only
- Hidden not necessary buttons for object browse
- STS Login

Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-07-07 12:28:25 -07:00
Javier Adriel
e48958f5a0 Connect marketplace API to microservice (#2130) 2022-07-06 23:11:23 -05:00
Klaus Post
63e2793272 Update trace response and dependencies (#2141) 2022-07-05 13:36:12 -07:00
Prakash Senthil Vel
532e64b802 UI AGPL license consent (#2154) 2022-07-05 09:17:51 -07:00
Alex
64b3e965c6 Change Support menu positon (#2160)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-07-05 11:08:18 -05:00
Alex
9371c027f3 Added Prettier test to workflow (#2159)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-06-30 23:40:23 -05:00
jinapurapu
a8bc58a420 Add Audit Log and Log DB security context selector and split screen into tabs (#2156)
* Added security context selector for logging and log DB to Audit Log screen, split Audit Log screen into tabs
* Cleaned up tab titles, disabled Save button while loading
2022-06-30 14:28:08 -07:00
Javier Adriel
10c56a91da Check if user is in EU (#2143) 2022-06-30 14:27:36 -07:00
Javier Adriel
403972de39 Select not working without dispatch (#2152) 2022-06-29 19:02:38 -05:00
Paweł Kuffel
1c0632473a Add object-level error message display in Downloads/Uploads panel (#2150) 2022-06-29 08:26:22 -07:00
Harshavardhana
ff93109b57 simplify and optimize deleting multiple versions of object (#2153) 2022-06-28 20:25:50 -07:00
Cesar Celis Hernandez
b518810106 Avoid the crash in the test (#2147) 2022-06-24 18:51:52 -05:00
Prakash Senthil Vel
b4d2d65c5c UX Top bar height (#2146) 2022-06-24 10:25:30 -07:00
Alex
beeb188d7e Fixed issues in Replication rules screens (#2145) 2022-06-23 21:35:50 -07:00
jinapurapu
2830022ede Tenant log config screen (#2142)
* Created file for auditLogsScreen, connected to link in TenantDetails Audit Log tab
* Fixed input title formatting, confirmation modal logic
2022-06-23 16:43:23 -07:00
Javier Adriel
ba4103e03f Prompt email after login (#2108)
* Add new route to marketplace modal
* Add redux logic for showing and displaying marketplace modal
* Redirect to marketplace view if console is in operator and marketplace mode
* Add marketplace component
* Use navigate instead of redirect
2022-06-23 12:22:38 -07:00
Alex
f3d6638384 Added improvements to Rename modal in windows (#2140)
- Disabled button when filename is less than 200 characters long
- Selector to override & accept long name
- Added this behavior when one file is checked in objects list

Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-06-23 10:17:52 -05:00
Alex
2ad42d660b Added Rename modal for filenames longer than 200 characters in Windows (#2137)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-06-22 12:43:57 -05:00
Cesar Celis Hernandez
618a00d775 Improving our Operator Test in console (#2138) 2022-06-22 11:07:40 -05:00
jinapurapu
d0b65ce297 Single screen to display and edit Prometheus monitoring configuration (#2134)
* Created new screen to display and edit Prometheus monitoring configuration
* Updated image name validation to include slash and colon
* Removed unused files
2022-06-21 09:39:32 -07:00
Cesar Celis Hernandez
41f640077b Delete Tenant Test (#2098) 2022-06-20 15:24:44 -07:00
Cesar Celis Hernandez
bfa05616b1 Wait until resource exist to wait on it (#2136) 2022-06-20 14:48:54 -07:00
Javier Adriel
f792d7a476 Remove unused deps (#2133) 2022-06-16 19:32:27 -07:00
jinapurapu
9b13cfdbe9 User Assign Policy UI test (#2129) 2022-06-16 14:43:08 -05:00
Cesar Celis Hernandez
02c274e117 Relaxing tests when play is down (#2131) 2022-06-16 08:49:53 -07:00
Daniel Valdivia
8993b40730 Release v0.19.0 (#2125)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-06-15 18:18:36 -07:00
Prakash Senthil Vel
1311b171f9 UX menu toggle and license badge icon (#2127) 2022-06-15 16:54:13 -07:00
Alex
7ecc1022b2 Added decimal support to bucket quota selectors (#2126)
- Fixed an issue with calculateBytes function
- Fixed add bucket validation form

Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-06-15 16:35:47 -07:00
Javier Adriel
a5c14790b3 Fix describe test (#2128) 2022-06-15 14:58:35 -05:00
Javier Adriel
e5f7a03585 Remove unused code in marketplace API (#2124) 2022-06-15 09:21:59 -07:00
jinapurapu
a024a13f25 Policy selector fix (#2123) 2022-06-14 12:18:41 -05:00
Alex
4d876d0ce8 Remove of unused history props (#2122)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-06-13 16:40:58 -07:00
Javier Adriel
b02c37bf33 Remove history library (#2119)
* Use navigate instead of push
* Remove use navigate
* Remove import
* Remove history
2022-06-13 16:16:43 -07:00
Daniel Valdivia
1d17f11d2f Update AddUserScreen layout to fix padding (#2121)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-06-13 13:29:21 -05:00
Lenin Alevski
1dd9f7f363 Adding missing init container fields for Prometheus and Logsearch(Audit) UI (#2116)
Signed-off-by: Lenin Alevski <alevsk.8772@gmail.com>
2022-06-11 20:20:57 -07:00
Cesar Celis Hernandez
618d95b76e Reduce renders in password when adding a user (#2120) 2022-06-11 18:09:55 -07:00
Daniel Valdivia
e416abe19b Updates to License page and Menu (#2118)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-06-10 20:11:33 -07:00
Javier Adriel
296f58f43d Use appDispatch instead (#2114) 2022-06-10 14:33:17 -07:00
Daniel Valdivia
0b5e3d5a10 Metrics tweaks for free space (#2113)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-06-10 13:26:50 -07:00
Cesar Celis Hernandez
5d591b18d9 Reduce renders in User Name when adding a user (#2106) 2022-06-10 14:57:52 -05:00
Daniel Valdivia
e68bc08fed License Page adjustments (#2109)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-06-10 11:22:29 -07:00
Alex
df38c84075 Changed useDispatch implementation to comply with TS specification (#2110)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-06-10 11:05:21 -07:00
Javier Adriel
c509e5db70 API to receive an email address and set it (#2095)
* Generate swagger code for new endpoints
* Implemetn swagger APIs
* Add unit tests
2022-06-09 16:13:46 -07:00
Alex
5a8e029005 Added Initial Time support to Prometheus dashboard (#2099)
Incremented initial time for data usage growth chart
2022-06-09 15:52:12 -07:00
Alex
e3d96b5bb3 Updated React router to V6 (#2107)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-06-09 15:37:21 -07:00
Daniel Valdivia
51afc337ff Fix Bucket Audit Acess width problem (#2105)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-06-08 11:44:28 -05:00
Cesar Celis Hernandez
617d41584e Get Tenant Details (#2097) 2022-06-08 09:05:42 -07:00
Kaan Kabalak
7a8e2caa50 Fix Invalid DOM property error (#2101)
As it is defined in a .tsx file, the AGPL Console logo was causing an
error to be displayed because the DOM property in question was not in
camel case.
2022-06-08 08:49:18 -07:00
adfost
fed58ec29a Delete remote bucket test (#2096) 2022-06-07 14:42:14 -05:00
Cesar Celis Hernandez
427a7516a3 Isolating users test in Testcafe (#2094) 2022-06-07 11:01:42 -05:00
Cesar Celis Hernandez
969feb8efa Adding Tenant Log Test (#2093) 2022-06-07 00:14:45 -05:00
jinapurapu
d09d6e1e99 Filtered list of policies being applied to group to remove duplicates (#2091) 2022-06-06 16:11:36 -07:00
Cesar Celis Hernandez
2d80638090 Add Tenant Logging Tests (#2090) 2022-06-06 13:31:27 -07:00
Daniel Valdivia
2918d39ab7 Release v0.18.1 (#2088)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-06-04 10:12:11 -07:00
Cesar Celis Hernandez
fb2eb0ebf7 Test logout in Operator API (#2085) 2022-06-03 22:15:13 -07:00
jinapurapu
e7a36a1ff1 Assign policy for Multiple groups (#2086) 2022-06-03 21:54:06 -07:00
Daniel Valdivia
41e1b4a5d5 Add Bucket slice refactor to reduce re-renders (#2087)
* Add Bucket slice refactor to reduce re-renders
* Fix Button on object browser
* Update Logo

Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-06-03 21:39:12 -07:00
Daniel Valdivia
6e205fa8ae Change editor to react-textarea-code-editor. Tenant YAML a page. (#2084)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-06-03 21:24:18 -07:00
jinapurapu
5b3f6ad76e Fixed formatting of Site Replication Helpbox text (#2080) 2022-06-03 21:19:01 -05:00
Daniel Valdivia
8396c3023e Have TenantItem charts use capacity instead of raw capacity (#2083)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-06-03 17:53:58 -07:00
jinapurapu
161d56db36 Added View action to groups table in UserDetails (#2081) 2022-06-03 18:01:15 -05:00
Cesar Celis Hernandez
a49a4e5513 Add bucket replication test (#2082) 2022-06-03 17:43:24 -05:00
Cesar Celis Hernandez
9741462e7b Accommodate Login Function (#2078) 2022-06-02 22:54:33 -05:00
jinapurapu
73f09e1af6 Tooltip capitalization fixes (#2079) 2022-06-02 22:20:33 -05:00
Daniel Valdivia
d41f6e57d2 Release v0.18.0 (#2076)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-06-02 15:36:22 -07:00
Cesar Celis Hernandez
93d041e55b Add test to create namespace (#2075)
Co-authored-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-06-02 12:24:49 -07:00
Daniel Valdivia
94e419e09c Add Pool Slice and Tenants Slice simplification (#2074)
Add Pool Slice and Tenants Slice simplification
Flatten Slice
AddPool Thunk
Return HMR support for Redux
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-06-02 12:11:31 -07:00
Daniel Valdivia
6c5f6934e7 Tenant Details Thunk (#2072)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-06-02 11:18:16 -05:00
Daniel Valdivia
41155b3f97 Show error when there's no storge classes (#2070)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-06-01 22:52:28 -05:00
Cesar Celis Hernandez
e41c80449d Test list of claims (#2069) 2022-06-01 20:23:14 -07:00
Alex
6f7a46e528 Disabled Servers & drives fields in edit pool (#2068)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-06-01 17:10:50 -07:00
Daniel Valdivia
ba48e0c5b8 Move EditPool redux state to it's own slice (#2063)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-06-01 15:14:31 -07:00
Lenin Alevski
3da636170f Fix MinIO expose service label (#2067) 2022-06-01 16:51:28 -05:00
Daniel Valdivia
7687a9e588 Fix Login Box height while loading (#2061)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-05-31 20:16:21 -07:00
Alex
692dc1a29e Remove react-hot-loader dependency (#2062)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-05-31 20:02:33 -07:00
jinapurapu
bb55f9f331 Disabled Assign Policy button if multiple groups selected (#2058) 2022-05-31 19:55:16 -05:00
Daniel Valdivia
dec7b138e9 Move New Credentials to separate component for Add Tenant (#2056)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-05-31 19:28:50 -05:00
Cesar Celis Hernandez
d3b1be80eb adjust threshold (#2066) 2022-05-31 17:05:30 -07:00
Alex
0339925d15 Added plan name icons to license page (#2060)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-05-31 15:29:55 -07:00
Cesar Celis Hernandez
d956ec65a2 Cover errors in registerAdminArnsHandlers (#2059)
To cover errors in registerAdminArnsHandlers
2022-05-31 12:42:16 -07:00
Alex
b02e649405 Fixed dashboards capacity Widgets (#2055)
- Added new calculation for prometheus capacity
- Added indicator colors to capacity widgets
- Adjusted capacity in drives for common dashboard

Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-05-31 10:03:58 -05:00
Cesar Celis Hernandez
68e98be376 Add test for registerAdminArnsHandlers (#2053) 2022-05-30 21:39:55 -07:00
Cesar Celis Hernandez
c9d174df09 Wait for PVC to be bounded (#2054) 2022-05-30 21:15:03 -07:00
Daniel Valdivia
80391b867c Create Tenant Namespace Field move to Thunks (#2052)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-05-30 22:06:42 -05:00
Alex
45715293ea React 18 initial migration (#2044)
- Updated codemirror dependencies
- Updated react virtualized dependencies
- Fixed height of object actions buttons
- Fixed icon buttons styling
- Fixed boxIcon badge location
- Fixed actions panel buttons height
2022-05-28 15:08:22 -07:00
Cesar Celis Hernandez
dd4963e3aa Increment coverage & fix test on full disk (#2050) 2022-05-28 00:41:39 -05:00
jinapurapu
c7c7fe194c Added SA checking for DeleteUser button in UserDetails (#2049) 2022-05-27 18:51:16 -05:00
Prakash Senthil Vel
35fdaf1ddd UX license logo on sidebar (#2037) 2022-05-27 18:23:36 -05:00
Daniel Valdivia
2aa5081889 Release v0.17.3 (#2047)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-05-26 16:50:23 -07:00
Daniel Valdivia
9c5d4aaf11 Move Create Tenant to Thunk (#2043)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-05-26 16:47:39 -07:00
Cesar Celis Hernandez
04adf25e65 Add csr under tenant details (#1938) 2022-05-26 14:16:36 -07:00
adfost
8f77261872 Delete access rule test (#2018) 2022-05-26 13:34:52 -07:00
Javier Adriel
8b7505c466 Test pvc describe (#2042)
Delete test tenants after tests are done
Add test for new describe Pod section
2022-05-26 13:11:19 -07:00
Daniel Valdivia
b420ef3c1f Logs, Watch Slices to replace old reducers, Split Tenant Add slice (#2035)
Logs, Watch Slices to replace old reducers

Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-05-25 19:12:07 -05:00
Javier Adriel
e235863b94 Test pod describe (#2040) 2022-05-25 18:47:20 -05:00
adfost
6b7948b6cd Get access rules test and test for adding access rule to non existent bucket (#1998) 2022-05-25 18:04:01 -05:00
Alex
87c373b08c Solved long file names UI issues in object browser (#2036)
Solved long file names issues in object browser

- Fixed icon size & position in list
- Fixed object name overflow issue
- Fixed object details title icon size

Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-05-25 15:19:12 -07:00
Javier Adriel
9844269c1a Delete test tenants after tests are done (#2033) 2022-05-25 15:54:03 -05:00
Cesar Celis Hernandez
6866b84da8 To support multiple CSRs per tenant (#1997) 2022-05-25 15:07:56 -05:00
jinapurapu
5b19fb3d96 Removed unneeded encoding of credentials download (#2032) 2022-05-25 14:48:17 -05:00
jinapurapu
fce2a148b8 Populate AddUserServiceAccount policy restrictor with user permissions (#1987)
Created api to generate single JSON including all user permissions to populate AddUserServiceAccount policy restrictor
2022-05-25 11:34:26 -07:00
Cesar Celis Hernandez
69e1d653ce To update replication test accordingly (#2038) 2022-05-25 12:24:04 -05:00
Alex
9b88dd6348 Added missing types required for React 18 migration (#2034) 2022-05-25 00:10:22 -05:00
Javier Adriel
85c0e5eca2 Add new tab and section for displaying describe PVC output (#2008) 2022-05-23 21:43:29 -05:00
Alex
17684f37d9 Release v0.17.2 (#2030)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-05-23 11:18:47 -07:00
Harshavardhana
175b87c355 fix: getTimeFromTimestamp() incorrect padding for days (#2029)
use a simpler function to return localeString() instead.
2022-05-23 02:51:59 -05:00
jinapurapu
5fff9ebfd4 Warn if deleting user with associated Service Account (#2022)
Created api to check if users have service accounts before deleting, UI to display warning and users with associated accounts
2022-05-23 00:14:24 -05:00
Alex
795497a60d Added tenants list sort by selector (#2025)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-05-23 00:00:14 -05:00
Harshavardhana
48119acc72 fix: capacity reported usage value (#2028)
do not use unix-epoch to be displayed, instead
use the actual value at that epoch to be displayed.
2022-05-22 23:30:47 -05:00
Harshavardhana
ddb23ea1c8 Release v0.17.1 (#2027)
Signed-off-by: Harshavardhana <harsha@minio.io>
2022-05-21 20:24:43 -07:00
Alex
6ec7ec3c25 Fixed tenant details infinite load loop (#2026) 2022-05-20 22:19:03 -07:00
Cesar Celis Hernandez
39d3690ac0 Adding missing tests (#2024) 2022-05-20 21:50:55 -05:00
Alex
41e0fce068 Multiple fixes in resources browsing (#2019)
- Fixed subpaths search & browsing
- Fixed a regression in object browser for object details panel reset
- Added a test for these cases

Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-05-20 20:30:39 -05:00
Javier Adriel
d876bebf28 Run unit tests and coverage for operator api (#2010) 2022-05-20 19:01:27 -05:00
Javier Adriel
7cb04ce62b Add unit test to describe pvc (#2020) 2022-05-20 18:42:33 -05:00
Cesar Celis Hernandez
326d709bf9 Increase coverage threshold (#2023) 2022-05-20 18:21:43 -05:00
Cesar Celis Hernandez
40dcc9eb33 Update Operator API Test (#2017) 2022-05-19 21:43:07 -05:00
Harshavardhana
b8f024aa39 fix: go mod tidy -compat=1.17 2022-05-19 03:41:25 -07:00
Daniel Valdivia
fbed90224f Release v0.17.0 (#2014)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-05-19 01:07:54 -07:00
Prakash Senthil Vel
64fe3a1dae Store bucket path if it is redirected to restore on login (#2006) 2022-05-19 02:01:47 -05:00
Alex
a160b92529 Display temporal paths when a policy has prefixes to allow navigation (#2011)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>

Co-authored-by: Benjamin Perez <benjamin@bexsoft.net>
Co-authored-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-05-19 00:40:52 -05:00
Daniel Valdivia
dc3e7f5888 Fix Versions Browsing Clicking on Chrome (#2013)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-05-18 23:58:17 -05:00
Daniel Valdivia
30d23d8555 Tweaks to Preview Max Height (#2012)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-05-18 23:40:47 -05:00
Prakash Senthil Vel
42deb992e6 License page updates (#2009)
Address conflicts review comments
2022-05-18 23:18:32 -05:00
Daniel Valdivia
6e31a42886 Redux Toolkit Redux Rewrite (#2003)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-05-18 17:02:26 -05:00
Javier Adriel
f6cab5a65b Add PVC describe API (#2007) 2022-05-17 19:02:53 -05:00
jinapurapu
448a80af4a Users screen UI revision (#1961)
* Changed Users screen UI to selector based delete, table layout changes, updated testcafe permissions test to reflect new delete User sequence, fixed ListUsers checkbox permission issue
2022-05-16 13:28:57 -05:00
Javier Adriel
6e4b8884e6 Add describe pod section to console UI (#2001) 2022-05-15 19:33:05 -07:00
Lenin Alevski
076e44e39a implement semgrep in github worflow for project (#1979) 2022-05-15 18:54:22 -07:00
Harshavardhana
1d23bf3d04 update to latest mc (#2002) 2022-05-14 15:50:59 -07:00
Daniel Valdivia
85b7f8c5d7 Update Padding on Policy Details (#2000)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-05-13 17:02:29 -05:00
jinapurapu
e4bf6ffd18 Fixed spacing of Bucket Events helpbox (#1999) 2022-05-13 13:58:20 -07:00
Lenin Alevski
1532cc0e70 Support for special characters and remove buggy functions (#1977)
- remove the use of encodeURI and encodeURIComponent functions and
  instead use encodeFileName and decodeFileName functions
- support for users with special characters
- support for users with special characters
- support for users with special characters
- fixed incorrectly group list display for policies

Signed-off-by: Lenin Alevski <alevsk.8772@gmail.com>
2022-05-13 13:13:56 -07:00
Prakash Senthil Vel
bd63817e37 UX Policy Summary (#1996) 2022-05-13 12:48:48 -07:00
jinapurapu
e8ccfeafe1 Fixed disabled Change Password button and added clarifying text (#1973) 2022-05-13 12:10:00 -07:00
adfost
6c892f095d Add access rules test (#1995) 2022-05-13 10:58:50 -05:00
Alex
e192623c22 Simplified layout effect for closing the menu on resize (#1992)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-05-12 22:11:41 -07:00
Cesar Celis Hernandez
c20e9adaeb correcting sso token port for coverage (#1981) 2022-05-12 19:27:35 -05:00
Alex
fdb6d210d6 Added copy path button to breadcrumbs bar (#1990) 2022-05-12 16:01:54 -07:00
Alex
3473a10159 Changed styles of Object versions for small screens (#1988)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-05-12 12:23:49 -05:00
Daniel Valdivia
2d8551f0d0 Upload latest coverge to the latest prefix (#1989)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-05-12 11:06:25 -05:00
adfost
38c74bdfa7 Reset config test and verb change to POST (#1986) 2022-05-11 22:31:40 -07:00
adfost
117da114dc Integration Tests for Get config (#1966) 2022-05-11 22:06:19 -07:00
Daniel Valdivia
d1f67ea7ac Release v0.16.3 (#1985)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-05-11 17:29:49 -07:00
jinapurapu
6f6846ee2a Fixed disabled Assign Policy button for multiple group selection (#1984) 2022-05-11 15:14:03 -07:00
Alex
6409d36df0 Changed styles for object browser in small screens (#1974)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-05-11 14:57:43 -07:00
Prakash Senthil Vel
10f8aed021 Fix route navigation paths to match menus (#1978) 2022-05-11 13:02:01 -07:00
Daniel Valdivia
5ee9213ad0 Move Tiers, Notifications and Site Replication out of Settings Menu (#1975)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-05-11 12:41:56 -07:00
Daniel Valdivia
6be7527424 Upload Coverage as HTML to build bucket (#1982)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-05-11 12:03:23 -07:00
Harshavardhana
9edeafb0ec remove additional {} from prometheus query 2022-05-11 11:25:29 -07:00
Prakash Senthil Vel
09b0ea9a30 KBar buckets search (#1980) 2022-05-11 12:01:52 -05:00
Daniel Valdivia
f409049a51 Tests for delete bucket and config functions (#1976)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-05-11 09:39:43 -07:00
adfost
94b4725e24 adding set test (#1970) 2022-05-10 19:47:56 -07:00
Prakash Senthil Vel
2922a35fd2 Integration tests for inspect (#1968) 2022-05-10 19:33:24 -07:00
Cesar Celis Hernandez
d417874608 put the coverage file in play bucket (#1972) 2022-05-10 21:12:32 -05:00
Cesar Celis Hernandez
bc4abe100e increase coverage (#1971) 2022-05-10 17:03:23 -05:00
Daniel Valdivia
393f0cd2f4 Fix Icons Clipping (#1969)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-05-10 12:50:58 -05:00
Cesar Celis Hernandez
0c822ffa98 Add CSR end point (#1893) 2022-05-09 11:35:19 -07:00
Harshavardhana
624d9d9c4a start using xnet and simplify URL handling (#1960) 2022-05-09 11:24:43 -07:00
Alex
0d7fc0904e Removed error snack for versioning, quota & object locking in List Objects panel (#1964) 2022-05-07 23:08:50 -07:00
Alex
e5cc4a3d3a Fixed loader visibility in object details page (#1962) 2022-05-07 16:51:50 -07:00
Alex
f51763fc88 Added margin in date time picker to avoid jumpy effect (#1963)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-05-06 16:06:05 -07:00
jinapurapu
22390a6781 Groups UI revision (#1959)
Co-authored-by: Prakash Senthil Vel <23444145+prakashsvmx@users.noreply.github.com>
2022-05-06 11:48:04 -07:00
Alex
3854372f4d Fixed multiple issues on object browser upload (#1955)
- Fixed issue with double slashes on upload manager
- Fixed sub folders not uploading in the correct subpaths location
- Fixed an issue upload when a file is already selected
- Fixed an issue with create path button with paths finished on slash
- Simplified path handling  for object browser

Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-05-06 11:33:13 -07:00
Klaus Post
6d22aa9955 Add streaming zip downloads (#1956)
Do not keep either objects nor the intermediate zip file in memory, and stream both the final zip and the objects as they are read.

Existing code can easily OOM the server.
2022-05-06 11:14:05 -07:00
Cesar Celis Hernandez
9d052703ad Focus on testing Diag UI only, if BE fails, we skip that (#1958) 2022-05-06 09:27:54 -07:00
Harshavardhana
3bfdbb5ec7 add support for additional prometheus labels for query (#1936) 2022-05-05 13:44:10 -07:00
jinapurapu
9103ea9d70 Fixed Watch start button to show stop button once watch has started (#1957) 2022-05-05 12:45:26 -07:00
Cesar Celis Hernandez
4c99b0d1d9 Simplify SSO Integration Test (#1954) 2022-05-05 10:29:41 -07:00
Alex
16474cbd81 Disabled versioning button when site replication is enabled (#1951)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-05-04 19:09:47 -07:00
Alex
f0c123932d Fixed loader issue object versions page (#1953)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-05-04 17:05:27 -05:00
jinapurapu
0cdff7dc0e Add User Service Account screen (#1947) 2022-05-04 14:39:21 -07:00
Prakash Senthil Vel
3c659a29ae Table tests for site replication apis (#1944) 2022-05-04 14:40:44 -05:00
Alex
42beef408c Added versions multiselection & delete selected versions buttons (#1948) 2022-05-04 09:14:52 -07:00
jinapurapu
c43d84f14b Added clarifying text to AddGroupHelpBox (#1950) 2022-05-03 21:07:58 -07:00
Alex
394a728b98 Fixed issue with quota assignation in create bucket wizard (#1949)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-05-03 20:35:10 -07:00
Daniel Valdivia
c741e9ccae Release v0.16.2 (#1945)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-05-03 11:33:42 -07:00
jinapurapu
ab835286b0 Add Service Account Policy restriction improvement (#1921) 2022-05-03 11:03:57 -07:00
Alex
6485718a97 Changed Share modal styles (#1942)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-05-02 22:30:48 -05:00
adfost
00bcb54b67 Describe pod API (#1861) 2022-05-02 18:35:36 -07:00
Alex
fef7863810 Adjusted edit / delete tags modal styles (#1939) 2022-05-02 17:01:34 -07:00
jinapurapu
427b9b4892 Integration test for PolicyNameContainsSpace (#1940) 2022-05-02 17:35:01 -05:00
jinapurapu
34adc5451d Disabled Save button on Add Policy Screen if policy name contains space (#1937) 2022-05-02 15:08:11 -07:00
adfost
224e8d4bba More groups tests (#1923) 2022-05-02 11:25:21 -05:00
Prakash Senthil Vel
07d75e19d5 UX KBar Style (#1935) 2022-05-02 11:04:07 -05:00
Daniel Valdivia
31871f54d4 Update HelpBox for Create Bucket. Add spacing. (#1934) 2022-04-30 12:00:58 -07:00
Alex
6069991405 Improvements for download / upload manager (#1933)
- Changed styles on progress bars & items
- Fixed some issues in error state & handling
- Added cancel capability to objects
- Added visual indicators when new objects are added to pool

Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-04-29 20:54:12 -07:00
Daniel Valdivia
a017c71d20 Release v0.16.1 (#1928)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-04-29 18:55:43 -07:00
Harshavardhana
4001f14953 keep lookupMap for easy reading for relevant publicKey file (#1930)
Co-authored-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-04-29 15:14:04 -07:00
Cesar Celis Hernandez
130413cbef having idp configured via env variable only (#1931) 2022-04-29 14:48:21 -07:00
Lenin Alevski
0622cc658b fix: parseTenantCertificates was ignoring cert-manager secrets (#1929)
Signed-off-by: Lenin Alevski <alevsk.8772@gmail.com>

Co-authored-by: Cesar Celis Hernandez <celis.hernandez.cesar@gmail.com>
2022-04-29 11:55:07 -07:00
Alex
663a5b196d Remove of suspended traffic warning in profile page (#1926) 2022-04-29 01:45:42 -05:00
Prakash Senthil Vel
6f676f73a4 UX Prometheus dashboard (#1907) 2022-04-28 19:57:16 -07:00
Daniel Valdivia
26d7001ae1 Remove all un-used CSS classes (#1924)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-04-28 19:33:46 -05:00
Daniel Valdivia
f79a8e8177 FormLayout Component (#1922)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-04-28 15:13:20 -07:00
Daniel Valdivia
0e5147bb1d Constraint PageLayout to max 1220px on large resolutions (#1919)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-04-28 14:34:29 -07:00
Lenin Alevski
566fb27fc1 Error and Audit logger webhooks (#1855)
Similar to MinIO now it's possible to configure webhooks to log all
triggered errors and incomming requests via env variables:

```
CONSOLE_LOGGER_WEBHOOK_ENABLE_<ID>
CONSOLE_LOGGER_WEBHOOK_ENDPOINT_<ID>
CONSOLE_LOGGER_WEBHOOK_AUTH_TOKEN_<ID>
CONSOLE_LOGGER_WEBHOOK_CLIENT_CERT_<ID>
CONSOLE_LOGGER_WEBHOOK_CLIENT_KEY_<ID>
CONSOLE_LOGGER_WEBHOOK_QUEUE_SIZE_<ID>

CONSOLE_AUDIT_WEBHOOK_ENABLE_<ID>
CONSOLE_AUDIT_WEBHOOK_ENDPOINT_<ID>
CONSOLE_AUDIT_WEBHOOK_AUTH_TOKEN_<ID>
CONSOLE_AUDIT_WEBHOOK_CLIENT_CERT_<ID>
CONSOLE_AUDIT_WEBHOOK_QUEUE_SIZE_<ID>
```

Signed-off-by: Lenin Alevski <alevsk.8772@gmail.com>
2022-04-28 12:55:06 -07:00
Lenin Alevski
8c18829089 Update DNS Rebinding etcd vulnerable dependency (#1918)
Signed-off-by: Lenin Alevski <alevsk.8772@gmail.com>
2022-04-28 14:21:17 -05:00
adfost
c68c175827 committing new tests (#1879) 2022-04-28 11:52:37 -05:00
dependabot[bot]
415088ae2d Bump ejs from 3.1.6 to 3.1.7 in /portal-ui (#1915)
Bumps [ejs](https://github.com/mde/ejs) from 3.1.6 to 3.1.7.
- [Release notes](https://github.com/mde/ejs/releases)
- [Changelog](https://github.com/mde/ejs/blob/main/CHANGELOG.md)
- [Commits](https://github.com/mde/ejs/compare/v3.1.6...v3.1.7)

---
updated-dependencies:
- dependency-name: ejs
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-04-28 11:00:34 -05:00
adfost
158926f192 groups_test (#1916) 2022-04-28 08:09:06 -07:00
Lenin Alevski
f026ffffc8 Fix profiling endpoint and adding tests (#1917)
Signed-off-by: Lenin Alevski <alevsk.8772@gmail.com>
2022-04-27 20:07:32 -07:00
Cesar Celis Hernandez
bd0edea3df Increase coverage threshold (#1914) 2022-04-27 16:49:58 -05:00
Alex
07b4dad4d3 Fixed issues with Quota modal (#1911)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-04-27 14:08:19 -07:00
Cesar Celis Hernandez
0df796bc03 fixing integration tests to use proxy (#1912) 2022-04-27 12:33:10 -07:00
Daniel Valdivia
cf0212391e Console Swagger Module Reorganization (#1881)
Co-authored-by: Alex <33497058+bexsoft@users.noreply.github.com>
Co-authored-by: Prakash Senthil Vel <23444145+prakashsvmx@users.noreply.github.com>
2022-04-27 11:45:04 -07:00
Alex
cb3a695c25 Removed quota from versioning section & added inside summary page (#1910)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-04-27 09:36:39 -07:00
Daniel Valdivia
3040d468db Release v0.16.0 (#1904) 2022-04-25 15:41:06 -07:00
jinapurapu
9df300b241 Changed from modal to screen for Add Group link on empty Groups screen (#1905) 2022-04-25 15:51:19 -06:00
jinapurapu
870cef7b65 Added error handling for group already existing (#1902) 2022-04-25 15:42:50 -05:00
Daniel Valdivia
d9843d50cd Fix Subpath parsing (#1900) 2022-04-25 15:23:40 -05:00
Alex
9c64c5732b Removed spaces next to breadcrumbs slashes (#1903)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-04-25 13:12:26 -07:00
Harshavardhana
275d87f302 config set should always use on/off not true/false (#1899)
fixes https://github.com/minio/minio/issues/14516
2022-04-25 07:47:56 -07:00
Daniel Valdivia
509f4953bb update all dependencies (#1853)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-04-23 08:45:46 -07:00
Alex
63d1fb2abb Added UI for Domains edit (#1897)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-04-23 10:31:04 -05:00
Alex
b3afa34535 API for domains update (#1889)
* API for domains update

Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-04-23 02:19:14 -05:00
Daniel Valdivia
8203449d92 Format Add Users/Groups, Fix bug on Add Service Account (#1898)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-04-22 22:36:41 -07:00
Daniel Valdivia
8a96d8d8a5 Fix spacing on Add tenant forms (#1895)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-04-22 21:59:18 -07:00
jinapurapu
66df609d4a Moved AddUser from modal to screen (#1869)
Co-authored-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-04-22 21:40:20 -07:00
jinapurapu
fda090f7dd Created Add Policy screen (#1896) 2022-04-22 23:21:06 -05:00
jinapurapu
74d4c4a3e6 Create Add Group screen (#1890) 2022-04-22 20:50:31 -07:00
Kaan Kabalak
c6798a69d9 Remove duplicate Inspect page path (#1891) 2022-04-22 20:58:40 -05:00
Daniel Valdivia
5a484550fb New Login (#1894)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-04-22 20:40:57 -05:00
jinapurapu
b567e4855f Create service account screen (#1886) 2022-04-22 19:49:24 -05:00
Kaan Kabalak
c2303f78df Remove redundant Tools path (#1887) 2022-04-21 23:16:06 -05:00
Alex
bbe494f85c Fixed create path issue when object details is open (#1885)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-04-21 18:28:15 -05:00
Alex
715dbbb92c Fixed Objects list reload after file upload (#1888) 2022-04-21 16:56:18 -06:00
Cesar Celis Hernandez
c2455e3f06 Fixing Permissions Tests Part 2 (#1884) 2022-04-21 17:31:52 -05:00
Alex
997052a872 Fixed breadcrumbs container overflow in object browser (#1880)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-04-20 21:38:23 -07:00
Daniel Valdivia
3e13e6db98 Small Styling Adjustments. Lists style. (#1870)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-04-20 14:41:08 -05:00
Cesar Celis Hernandez
3291b3ca45 Test change password response (#1877) 2022-04-20 13:38:49 -05:00
Daniel Valdivia
74ba1c80a9 Fix the relative login redirects (#1872)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-04-20 12:57:28 -05:00
Alex
af76280f1d Added console & minio domains selector to add tenant wizard (#1863)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-04-20 12:29:06 -05:00
Cesar Celis Hernandez
9b7fdfd286 Removing unnecessary error check (#1876) 2022-04-20 11:07:16 -05:00
Daniel Valdivia
cefb95dc74 Revert "Create docker-publish.yml (#1789)" (#1875) 2022-04-20 00:31:18 -07:00
Alex
f15a7ff5f6 Added tenant domains to summary page (#1864)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-04-19 23:31:53 -05:00
Alex
6c123ce2b5 Prettier update to v2.6.2 (#1873)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-04-19 23:06:05 -05:00
adfost
d7588eaea1 Add policy test (#1874) 2022-04-19 20:39:19 -07:00
Prakash Senthil Vel
8cd756599f Top Bar UX back icon and link (#1860) 2022-04-19 20:56:40 -05:00
Cesar Celis Hernandez
5b25a6cb53 Recalibrating our coverage threshold (#1871) 2022-04-19 20:19:50 -05:00
Prakash Senthil Vel
82a0b67a26 Disable Bucket replication tab when site replication is enabled in Bucket Summary page (#1858) 2022-04-19 17:50:58 -05:00
Alex
1fa6b0a353 Updated insecure dependencies (#1865)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-04-19 10:34:01 -07:00
Prakash Senthil Vel
46151a5e55 UX basic dashboard (#1866) 2022-04-19 08:16:26 -07:00
adfost
f36c07aa68 Fixing SSO Operator mode showing CONSOLE (#1808) 2022-04-18 15:47:16 -07:00
Daniel Valdivia
86797cda20 Test for Get Object with Preview (#1848)
* Test for Get Object with Preview

Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-04-18 14:03:06 -05:00
Cesar Celis Hernandez
50bc755b44 Test invalid url in getWatchOptionsFromReq() (#1850) 2022-04-18 07:25:21 -07:00
Daniel Valdivia
f02461097b Release v0.15.14 (#1856)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-04-18 00:46:13 -07:00
Daniel Valdivia
b36aed8845 Adds support to proxy WS requests on Hop (#1857)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-04-17 23:16:12 -07:00
Daniel Valdivia
991cc0953e Make Login assets and redirects relative (#1854) 2022-04-16 22:05:53 -07:00
Daniel Valdivia
ef4587b596 Create docker-publish.yml (#1789) 2022-04-14 16:13:45 -07:00
Daniel Valdivia
75e2d1d9ce Release v0.15.13 (#1852)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-04-14 15:53:15 -07:00
Cesar Celis Hernandez
75fc68cd18 correcting error message to be same as our code (#1851) 2022-04-14 14:55:32 -07:00
Prakash Senthil Vel
ae34d886a9 Add site in a new page (#1845) 2022-04-14 13:19:45 -07:00
Daniel Valdivia
f2c187bf7c Fix early context cancellation when downloading/previewing object (#1846)
* Fix early context cancellation when downloading/previewing object
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-04-14 09:44:08 -07:00
Daniel Valdivia
243e51fe83 Release v0.15.12 (#1843)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-04-14 00:49:04 -07:00
Prakash Senthil Vel
d1d3d91fc1 Site replication status (#1834)
Site replication status UI
Site replication status ui-test
Address review comment by Alex
Add functional test for API
Add integration tests for status API
2022-04-14 00:21:43 -07:00
Alex
4541b4de03 Added domains item in create tenant & get tenant requests (#1841) 2022-04-14 00:42:38 -06:00
Alex
291e1fce55 Replaced Usage bar in tenant details to display tiers information (#1836)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-04-13 22:41:38 -07:00
Alex
bbb4090cd8 Remove of non-used console logs (#1842)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-04-13 21:51:11 -07:00
Alex
a30d29b437 Added URL support to object view (#1831)
- Added URL support to object view
- Refactored & simplified requests

Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-04-13 23:06:31 -05:00
jinapurapu
e6404be02f Added tooltip to prefix field of Add Access Rule modal (#1839) 2022-04-13 19:07:08 -05:00
Cesar Celis Hernandez
5e10719168 Adding test to cover registerAdminArnsHandlers() (#1835) 2022-04-13 07:13:19 -07:00
Lenin Alevski
68f9019d0e Fix: compress health diagnostics file when download (#1821) 2022-04-12 18:29:19 -07:00
Shireesh Anjal
d8e7d343ba Update madmin-go and mc to latest versions (#1832) 2022-04-12 18:41:11 -05:00
Cesar Celis Hernandez
0e5561032c Adding unittest for user_watch.go (#1833) 2022-04-12 16:28:48 -07:00
Daniel Valdivia
fc490a1ca8 Release v0.15.11 (#1830) 2022-04-11 20:32:10 -07:00
Daniel Valdivia
6e6aab580c Replace aws:username, jwt: and ldap: policy variables in session policies (#1828)
* Replace username variable in session policies

Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-04-11 20:01:49 -07:00
Alex
dc5b1963ae Fixed typo in create tenant screen (#1829)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-04-11 19:13:37 -07:00
Daniel Valdivia
564cfa2201 Remove ResponseHeaderTimeout from default http transport (#1827)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-04-11 17:18:22 -07:00
Lenin Alevski
398ab028a4 Removing hardcoded timeouts (#1826)
Signed-off-by: Lenin Alevski <alevsk.8772@gmail.com>
2022-04-11 16:20:30 -07:00
jinapurapu
1de712c099 Added titleIcon to UserAddServiceAccount modal (#1825) 2022-04-11 14:15:20 -07:00
jinapurapu
2d26eb4a70 Updated Tiers help text for consistency with button (#1824) 2022-04-11 12:54:53 -07:00
Cesar Celis Hernandez
e9cc567977 correcting the testing package (#1819) 2022-04-11 09:56:16 -07:00
Daniel Valdivia
ee82748aeb Release v0.15.10 (#1820)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-04-09 18:05:04 -07:00
Prakash Senthil Vel
ee3affd140 UI site replication (#1807) 2022-04-09 16:27:25 -07:00
dependabot[bot]
836090a0d5 Bump moment from 2.29.1 to 2.29.2 in /portal-ui (#1817)
Signed-off-by: dependabot[bot] <support@github.com>
2022-04-09 00:38:56 -07:00
Alex
e0e5e42af2 Remove duplicated versioned item in breadcrumbs (#1816) 2022-04-08 22:20:25 -06:00
Alex
49f340b5f8 Fixed assign policies screens (#1815) 2022-04-08 09:38:23 -07:00
Alex
404a10d3c7 Added fixed background color to pie chart (#1812)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-04-07 21:03:17 -07:00
Daniel Valdivia
62e270e95e Tenant Forms alignment. Components Page. (#1811)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-04-07 20:06:28 -07:00
Alex
bfbaaf12fb Add Edit pool capability (#1806)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-04-07 19:24:37 -07:00
Lenin Alevski
0aa9c7b36e Updating operator dependency to latest (#1810)
Signed-off-by: Lenin Alevski <alevsk.8772@gmail.com>
2022-04-07 19:08:35 -07:00
Lenin Alevski
8540168133 Identity Provider screen for TenantDetails (#1809)
- fixing encryption page styles
- removing extra fields on gemalto configuration
- backend endpoints for tenant identity provider details
- force restart tenant pods when identity provider configuration change
- force restart tenant pods when tls certificates change
- existing tls secrets are not deleted from tenant namespace, just removed from the tenant

Signed-off-by: Lenin Alevski <alevsk.8772@gmail.com>
2022-04-07 18:40:09 -07:00
Daniel Valdivia
02a35fb8d1 Operator UI Adjustments (#1805)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-04-06 19:08:24 -07:00
Prakash Senthil Vel
4647671f07 UX Basic Dashboard (#1799) 2022-04-05 22:48:35 -07:00
adfost
f30450c3c1 Adding usage objects and versions to tiers (#1796) 2022-04-05 22:31:09 -07:00
CommanderRoot
731501ba27 refactor: replace deprecated String.prototype.substr() (#1800)
.substr() is deprecated so we replace it with functions which work similarily but aren't deprecated

Signed-off-by: Tobias Speicher <rootcommander@gmail.com>
2022-04-05 17:42:20 -05:00
Daniel Valdivia
62a8bf05bb Release v0.15.9 (#1801)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-04-05 12:30:58 -07:00
Alex
d8754a2e3e Don't display "NaN B" in tenant capacity (#1802)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>

Co-authored-by: Benjamin Perez <benjamin@bexsoft.net>
2022-04-05 11:16:55 -07:00
Alex
64ffa039b4 Operator improvements (#1798)
Added new design to Tenants page list
Added Pool details initial page

Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-04-05 09:27:54 -07:00
Daniel Valdivia
822724a4f1 Fix Add Bucket Lifecycle Rule (#1797)
Fix Add Bucket Lifecycle Rule
Fix Edit ILM Rule
Update Bucket ILM Rules Listing

Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-04-04 19:13:59 -07:00
Prakash Senthil Vel
c18c843d03 UX code mirror button colors (#1792) 2022-04-04 14:18:02 -05:00
jinapurapu
1d362aceaf Added node and type selector UI to Error Logs screen (#1715) 2022-04-04 11:54:03 -07:00
Daniel Valdivia
6f5cb4d1a5 Make Bucket Icon Browse the bucket (#1795) 2022-04-04 10:25:46 -07:00
Harshavardhana
2cefa0860d update for go mod tidy 2022-04-03 13:05:57 -07:00
Cesar Celis Hernandez
ea0c83ea74 Node Labels Test (#1787) 2022-03-31 18:35:25 -06:00
Daniel Valdivia
90f64b685e Release v0.15.8 (#1786) 2022-03-31 17:06:27 -07:00
Daniel Valdivia
62f925d93c Remove Autocapitalizing CSS (#1785)
Remove Autocapitalizing CSS
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-03-31 15:58:40 -07:00
Alex
1985c110b1 Not show objects with the same path (#1784)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-03-31 13:49:55 -07:00
Prakash Senthil Vel
461bc94a0b UX Trace Screen (#1781) 2022-03-31 12:05:10 -07:00
Aditya Manthramurthy
aaa55a1f4a Fix authorization code flow handling (#1767)
Remove checking for unnecessary response types - this has been causing a regression since MinIO release RELEASE.2022-03-03T21-21-16Z
2022-03-31 11:21:32 -07:00
Prakash Senthil Vel
2eecabf5e6 Site replication API (#1773)
Site replication API
tests in CI/CL environment
2022-03-31 10:11:01 -07:00
Lenin Alevski
fba9bd87df TLS Certificate React component (#1780)
Add support to parse multiple blocks on pem certificate
Added react tls certificate component

Signed-off-by: Lenin Alevski <alevsk.8772@gmail.com>
2022-03-31 09:56:39 -07:00
Alex
bf461b8b27 Migrated AddPool modal to be a single page (#1782)
Also included extra fields configuration

Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-03-31 10:24:21 -06:00
Alex
301c4a83b5 Changed breadcrumbs bar position (#1783)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-03-30 21:27:08 -07:00
Alex
87468571ae Changed Size column width in object browser (#1779)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-03-30 09:30:35 -07:00
Alex
7ad2df3e7f Fixed loader for LinearGraphWidget (#1778)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-03-30 09:14:21 -07:00
Daniel Valdivia
baef7b5ec0 Release v0.15.7 (#1776)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-03-29 14:20:00 -07:00
Prakash Senthil Vel
fa8c59360a Fix sidebar navigation state (#1775)
Fix sidebar navigation state
2022-03-29 09:31:54 -07:00
Lenin Alevski
ceeacd2167 fix: pass original http response code to proxy response (#1772)
Signed-off-by: Lenin Alevski <alevsk.8772@gmail.com>

Co-authored-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-03-28 17:19:15 -07:00
Cesar Celis Hernandez
70214a6578 List Users With Access to a Given Bucket Integration Test (#1771)
List Users With Access to a Given Bucket Integration Test
Incrementing coverage threshold
2022-03-28 16:12:52 -07:00
adfost
d1a5e5ba57 Adding delete remote bucket functionality (#1762) 2022-03-28 15:36:23 -07:00
jinapurapu
fcd50257ee Updated BasicDashboard UI to expand drives initially if single server (#1768) 2022-03-26 15:25:14 -07:00
Cesar Celis Hernandez
2765fb0c97 Get objects in a bucket for a rewind date Test (#1766)
* Get objects in a bucket for a rewind date Test

* Incrementing the coverage
2022-03-25 11:34:29 -06:00
Cesar Celis Hernandez
d22f345d4a SSO Integration Test (#1742) 2022-03-24 20:11:42 -07:00
Daniel Valdivia
b658301725 Release v0.15.6 (#1763)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-03-24 17:14:41 -07:00
Lenin Alevski
1417375d99 Tests for Object delete button on SideBar (#1746)
Signed-off-by: Lenin Alevski <alevsk.8772@gmail.com>
2022-03-24 16:22:11 -07:00
Cesar Celis Hernandez
676420a2b3 List Policies With Given Bucket Test (#1765)
List Policies With Given Bucket Test
Incrementing the coverage
2022-03-24 15:25:38 -07:00
adfost
ffa9436276 Delete PVCs upon tenant deletion checkbox (#1752) 2022-03-24 13:17:04 -06:00
adfost
f6d92d50e4 disable legalhold if no locking (#1758) 2022-03-24 10:14:19 -07:00
Lenin Alevski
bc1cb820d1 Multiple files upload refactor (#1755)
- failed uploaded objects progress bar shows in red color
- fixed bug in where failed uploaded objects cannot be removed from
  listed objects in ObjectManager
- display delete button for failed upload objects
- display setErrorSnackMessage component after done uploading all
  objects with number of failed objects
- fixed race condition bug during multiple objects upload, now we are
  using Promise.allSettled to handle synchronization between uploads

Signed-off-by: Lenin Alevski <alevsk.8772@gmail.com>
2022-03-24 00:11:29 -07:00
Daniel Valdivia
8772c158c6 Github Actions Job Ordering - Longer jobs first (#1761)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-03-23 22:26:13 -07:00
Daniel Valdivia
d673473d5e Fix Delete Versions Tests Race condition (#1760)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-03-23 21:47:51 -07:00
Daniel Valdivia
bb22a1d62a Fix bug when selecting storage type for AWS (#1759)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-03-23 21:01:14 -07:00
Cesar Celis Hernandez
f582d83afc Splitting permission test (#1757) 2022-03-23 18:35:10 -07:00
Lenin Alevski
b12fa5edfd Enable/Disable Object details actions depending on user permissions (#1756)
Signed-off-by: Lenin Alevski <alevsk.8772@gmail.com>
2022-03-23 17:17:57 -07:00
Daniel Valdivia
65eee7c1d0 Updating Operator Dependency (#1753)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-03-23 17:44:48 -06:00
Alex
de4cf3b554 Updated dependencies for yarn audit issues (#1749)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-03-23 14:36:11 -07:00
Daniel Valdivia
cca04dca1c Small tweaks (#1754)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-03-23 14:28:13 -07:00
Alex
bef3897d0a Added tolerations selector to Add Tenant wizard (#1747)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-03-23 11:49:55 -06:00
adfost
842c3dee5f Bucket rollback if remote bucket creation failed (#1744) 2022-03-22 21:42:31 -06:00
Lenin Alevski
d1d39df71e Fix enable/disable delete button for object (#1745)
- Pass the right resource to SecureComponent wrapper for delete button,
  bucket/object-full-path-including-prefix

Signed-off-by: Lenin Alevski <alevsk.8772@gmail.com>
2022-03-22 14:36:20 -06:00
Daniel Valdivia
2321343d5e Release v0.15.5 (#1741)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-03-21 12:12:35 -07:00
Daniel Valdivia
ce4d9310aa AWS Marketplace Integration Updates (#1740)
Makes the create tenant for MK AWS updated with new recommendations
Fixes Back Link icon alignment and color
Adds a helpbox for MK AWS

Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-03-21 10:21:39 -07:00
Daniel Valdivia
58c53cbe0a Release v0.15.4 (#1739)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-03-20 02:11:09 -07:00
Cesar Celis Hernandez
144979b372 Delete Multiple Service Accounts (#1737)
Co-authored-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-03-19 17:30:20 -07:00
Alex
e29fa04051 Enabled Delete button for sub resources (#1738)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-03-19 15:29:27 -07:00
Alex
5ab5232474 Delete Non-current versions (#1735)
- Delete Non-current API
- Delete non current modal implementation
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-03-18 13:07:34 -07:00
Lenin Alevski
d7fef8d89e Profiling endpoint fixes (#1707)
- Added support to download all profile tests
- profile.zip file was corrupted after download
- Add suspension warning
- Add Checkbox support
- Support for running multiple profiling types at the same time
- fix profiling test

Signed-off-by: Lenin Alevski <alevsk.8772@gmail.com>
2022-03-18 13:52:42 -06:00
Cesar Celis Hernandez
3a09361899 List tenants by namespace test (#1736) 2022-03-18 10:18:37 -07:00
Prakash Senthil Vel
6ca17a3f9c Log text color styles and empty state (#1733)
Log text color styles and empty state
2022-03-17 22:19:45 -07:00
Alex
6d40ff7e1b Enabled Delete selected version functionality (#1731)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-03-17 19:21:21 -07:00
adfost
0b29eee9ed Adding bucket object tag tests (#1732)
adding bucket object tests
2022-03-17 19:09:04 -07:00
jinapurapu
c7fdfdd035 Added download all credentials button, added tooltips, removed Done button, Updated test to use corner X instead of Done button (#1704) 2022-03-17 13:30:30 -06:00
Daniel Valdivia
d7626e187c Integration Test: Create Service Account (#1725)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-03-17 13:15:06 -06:00
Cesar Celis Hernandez
39453de8fb To use DeleteMultipleObjects func and be able to debug via Browser (#1730) 2022-03-17 11:27:45 -07:00
Daniel Valdivia
0c38e93b83 Remove un-used code (#1729) 2022-03-16 22:29:43 -06:00
Prakash Senthil Vel
bf8db812b8 Address review comments (#1709) 2022-03-16 16:47:11 -07:00
Alex
0e35da8370 Added versions pill to versions page elements (#1728)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-03-16 16:36:53 -07:00
Cesar Celis Hernandez
b11fa26162 Adding test for creating tenant via API (#1727) 2022-03-16 15:57:30 -07:00
Prakash Senthil Vel
e3836538fc UX back button to be consistent in all screens (#1726) 2022-03-16 10:22:02 -07:00
Daniel Valdivia
9301e3b7de Release v0.15.3 (#1724) 2022-03-15 22:42:05 -07:00
jinapurapu
cf5e5a14b5 Updated tenant creation credentials download to allow mc alias import (#1683)
Removed underscore from credentials
Made credentials download output match mc alias import expected format
Added URL to createServiceAccountCreds return
2022-03-15 21:01:03 -07:00
Cesar Celis Hernandez
7f4546e879 Adding Access Rules Integration Test (#1719) 2022-03-15 20:49:17 -07:00
Alex
1a92c59e3f Added background color to selected version (#1723)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-03-15 20:42:12 -07:00
Alex
ade9731773 Reload main object information after restoring a version (#1720)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-03-15 21:26:57 -06:00
Cesar Celis Hernandez
cc43b3c743 Add list of tenants integration test (#1722) 2022-03-15 21:13:33 -06:00
Alex
b29f6a1640 Changed Sort by field to use only Date & Size (#1721)
Added size column
Changed Versions Sort by field to be only date & size
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-03-15 18:03:42 -07:00
Daniel Valdivia
62b8258989 Fix Get Latest MinIO Image on Tenant Create (#1703)
* Fix Get Latest MinIO Image on Tenant Create

Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>

* remove `operator_` prefix on files in operatorapi

Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-03-15 15:16:26 -07:00
adfost
75bc568e4b Adding delete versions test (#1701)
adding delete versions ui test
2022-03-15 14:40:48 -07:00
Alex
b0119a55df Reload versions list after clicking on Reload button (#1717) 2022-03-15 09:45:28 -07:00
Alex
78983ce76f Added (Default) label to EC Parity selector field & fixed automatic selection of EC Parity (#1716)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-03-14 23:47:38 -07:00
Cesar Celis Hernandez
e060e1d97e Add Bucket LifeCycle Integration Test (#1711) 2022-03-14 19:48:25 -06:00
Daniel Valdivia
82bdc228b2 Add preview icon to object versions (#1713)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-03-14 15:48:20 -07:00
adfost
1fa8311af7 adding distributed setup (#1712) 2022-03-14 15:34:21 -06:00
Daniel Valdivia
93243f2c77 Run Testcafe tests with Node 16 (#1714)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-03-14 12:11:07 -07:00
adfost
3b423826fd Removing delete all versions option from non versioned bucket (#1710) 2022-03-14 11:13:23 -07:00
Daniel Valdivia
e44a7c94c6 Bug Fix: Preview a specific Object Version ID (#1706) 2022-03-11 22:40:14 -08:00
Daniel Valdivia
63c0d260ca Release v0.15.2 (#1696)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-03-11 02:35:22 -08:00
Lenin Alevski
607ca5742b Adding missing lookup fields for LDAP configuration in UI (#1698)
Signed-off-by: Lenin Alevski <alevsk.8772@gmail.com>
2022-03-11 00:18:46 -08:00
Cesar Celis Hernandez
86a3072fa9 Increasing coverage threshold from 48% to 49.4% (#1697)
* Increasing coverage threshold

* correcting the comparison logic
2022-03-10 22:42:09 -08:00
Cesar Celis Hernandez
94c60e1837 add test to delete bucket encryption (#1695) 2022-03-10 15:05:19 -08:00
Alex
5e4ad55bbd Replaced CircularProgress component with new Loader (#1690)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-03-10 16:18:22 -06:00
Alex
e01d8bc10e Replaced main loader for index.html (#1694)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-03-10 13:53:32 -08:00
Alex
74605adbee Login Page Improvements (#1692)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-03-09 22:11:39 -08:00
Cesar Celis Hernandez
c6bd1a28d3 Adding Get bucket encryption information test (#1691) 2022-03-09 23:00:31 -06:00
Kaan Kabalak
b4ea4e7499 Fix whitespace appearing on Login scroll after height decrease (#1689)
Fixes #1688
2022-03-09 16:35:13 -08:00
Cesar Celis Hernandez
414db326bb Adding bucket encryption test (#1687) 2022-03-09 14:07:15 -08:00
Alex
3186c1a0d0 Added Loader to Console (#1686)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-03-09 09:28:37 -08:00
Harshavardhana
17c70d6c07 support admin:KMSCreateKey as part of IAM policy actions (#1685) 2022-03-08 15:05:43 -08:00
Alex
57ad200288 Fixed Invalid Date message in certificates page (#1684)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-03-08 14:45:16 -06:00
Harshavardhana
842c11f414 update all direct deps for console (#1655) 2022-03-08 12:13:05 -08:00
Daniel Valdivia
d20be7f836 Release v0.15.1 (#1680)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-03-07 22:45:20 -08:00
Alex
8008f226a8 Added Show deleted objects functionality in objects list (#1681)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-03-07 22:17:06 -08:00
Alex
fbfc1557c7 Removed Welcome to label from login screen (#1682) 2022-03-07 21:35:23 -08:00
adfost
dcf6a521a6 Inspect Object (#1663) 2022-03-07 19:52:36 -08:00
Cesar Celis Hernandez
25562bd55b re-using code by implementing add bucket verification only once (#1678) 2022-03-07 19:03:00 -08:00
Cesar Celis Hernandez
bff35bb13a Adding object-locking test (#1674) 2022-03-07 18:50:28 -08:00
Prakash Senthil Vel
b481b35419 Region list select in Add Tier screen (#1657)
Region list select in Add Tier screen
2022-03-07 18:35:21 -08:00
Daniel Valdivia
d96b2e5bd5 Update Swagger Header File Year (#1679)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>

Co-authored-by: Alex <33497058+bexsoft@users.noreply.github.com>
2022-03-07 18:24:09 -08:00
Daniel Valdivia
8e21039ef1 New Login Design (#1675)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-03-07 19:56:42 -06:00
Lenin Alevski
5e42f96eaf Validate basePath for console (#1677)
Signed-off-by: Lenin Alevski <alevsk.8772@gmail.com>
2022-03-07 17:30:36 -08:00
Lenin Alevski
7bc65031c4 Nancy vulnerability dependency scanner (#1676)
Signed-off-by: Lenin Alevski <alevsk.8772@gmail.com>
2022-03-07 14:47:07 -08:00
Cesar Celis Hernandez
fd09a4c815 Cleaning our logs for clarity (#1670)
Co-authored-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-03-07 14:08:27 -08:00
adfost
5977e9e82f adding access_key (#1652) 2022-03-07 13:54:42 -08:00
Cesar Celis Hernandez
f5edca5a31 Add Set Bucket Versioning Test (#1669)
Co-authored-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-03-07 13:37:55 -08:00
adfost
433868ddf5 cleaning up delete multiple (#1668)
Co-authored-by: Cesar Celis Hernandez <celis.hernandez.cesar@gmail.com>
2022-03-07 13:04:39 -08:00
Cesar Celis Hernandez
7c26d583a6 Allow manually executing integration tests (#1671) 2022-03-05 12:20:00 -08:00
Alex
9c63bad6ee Added select all buckets functionality (#1672) 2022-03-05 08:44:28 -07:00
Cesar Celis Hernandez
4d4a159d24 increase coverage threshold (#1667) 2022-03-04 12:21:41 -08:00
Cesar Celis Hernandez
4cb48b86aa Add get bucket versioning test on top of an existing test (#1666) 2022-03-04 10:26:15 -08:00
Cesar Celis Hernandez
2c548be5af reuse golang dependencies (#1662) 2022-03-04 11:40:46 -06:00
Daniel Valdivia
bfaea09c0b Logs Re-Design (#1656) 2022-03-03 15:18:19 -08:00
Prakash Senthil Vel
06bfe52e7a UX License page with registered state (#1650)
UX License page with registered state
2022-03-03 13:58:35 -08:00
Cesar Celis Hernandez
0de9ff38f4 removing operator repo (#1659) 2022-03-03 14:00:49 -06:00
Cesar Celis Hernandez
768181cf8b improving coverage limit check (#1647) 2022-03-02 22:26:32 -06:00
Cesar Celis Hernandez
eb3881fc74 Adding delete bucket replication test (#1654) 2022-03-02 16:55:26 -08:00
jinapurapu
2c55722e30 Removed mage (#1653) 2022-03-02 12:39:37 -08:00
Lenin Alevski
26d5972ab5 Whitelist for preview files from the backend (#1651)
This PR adds a whitelist of safe files to download with
`Content-Disposition: inline;` from the backend, all other files will be
force download via `Content-Disposition: attachment;` existing svg files
will still be rendered in a secure way via the html `image` tag.

reference: https://digi.ninja/blog/svg_xss.php

Signed-off-by: Lenin Alevski <alevsk.8772@gmail.com>
2022-03-02 14:18:43 -06:00
Prakash Senthil Vel
20ba19affc UX error alert banner (#1620) 2022-03-01 21:36:25 -06:00
Harshavardhana
c86f57862d remove continue and use break (#1649)
Co-authored-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-03-01 17:03:57 -08:00
Daniel Valdivia
f92f3e3382 Testcafe: Add tenant without audit log (#1644) 2022-03-01 16:39:42 -08:00
Harshavardhana
cd72c535d0 update go.sum with 'go mod tidy -compat=1.17' 2022-03-01 16:18:30 -08:00
Daniel Valdivia
439bc1a2a7 Release v0.15.0 (#1648)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-03-01 16:14:00 -08:00
Harshavardhana
fb99cf3805 reject IDPs without supported response_types (#1645)
Co-authored-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-03-01 15:20:27 -08:00
Alex
a0bf2b49db Fixed delete object behavior (#1646)
Also fixed an issue with multi-select & panel sizes

Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>

Co-authored-by: Benjamin Perez <benjamin@bexsoft.net>
2022-03-01 13:23:18 -08:00
Cesar Celis Hernandez
57e995fc71 Blocking PR to be merged if coverage is below the threshold (#1640) 2022-03-01 14:08:32 -06:00
Alex
36134f481e Reset File input value after file upload (#1642)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-03-01 10:50:46 -08:00
Daniel Valdivia
632c66539e Move Add Tenant Configure Audit Log and Monitoring to their own tabs (#1636)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-03-01 10:32:50 -08:00
Cesar Celis Hernandez
645f98284d Adding bucket replication test (#1635)
Co-authored-by: Prakash Senthil Vel <23444145+prakashsvmx@users.noreply.github.com>
Co-authored-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
Co-authored-by: Alex <33497058+bexsoft@users.noreply.github.com>
2022-03-01 09:08:22 -08:00
Daniel Valdivia
19dd7aad89 Fix Kbar in operator mode (#1638)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-03-01 09:50:46 -06:00
Prakash Senthil Vel
d82bd31bf1 Add Testcafe tests (#1625) 2022-03-01 00:21:51 -08:00
Lenin Alevski
4fa2f16e9a Update encryption configuration screen for tenant (#1611) 2022-02-28 23:56:38 -08:00
Daniel Valdivia
208afdfc3a Remove Operator UI Storage Page (#1639)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-03-01 00:58:20 -06:00
Alex
69a3ee6c1a Updated design of object details panel (#1637)
- Removed old references to object details
- Created new Tags edit module

Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>

Co-authored-by: Benjamin Perez <benjamin@bexsoft.net>
2022-02-28 22:30:13 -08:00
Cesar Celis Hernandez
96d59fb7cc Delete Bucket Event Test (#1633) 2022-02-28 14:53:14 -08:00
Alex
3395d1c853 Added navigation support to object versions (#1626)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-02-28 10:17:57 -06:00
Cesar Celis Hernandez
e52fb7d8b5 Speed up tests (#1630) 2022-02-27 21:57:33 -08:00
Cesar Celis Hernandez
be326c37d0 Correcting DB name (#1631) 2022-02-26 22:40:08 -08:00
Alex
1251232e30 Misc Changes (#1628)
- Changed placeholder for enter comment
- Removed fmt.Println with garbage text

Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>

Co-authored-by: Benjamin Perez <benjamin@bexsoft.net>
2022-02-26 19:00:09 -08:00
Harshavardhana
fa2a212607 do not add naked 'fmt.Print' (#1627) 2022-02-25 22:17:42 -08:00
Cesar Celis Hernandez
af3b0cd5f3 splitting admin tests from users tests (#1619) 2022-02-24 20:27:37 -06:00
Daniel Valdivia
86fa54d64a Release v0.14.8 (#1623)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-02-24 13:42:11 -08:00
Daniel Valdivia
576abdeec4 Fix Hop hiding menu (#1621)
* Fix Hop hiding menu

Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>

* Fix Menu

Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-02-24 13:24:29 -08:00
Harshavardhana
04da7ec364 update CREDITS for new deps 2022-02-24 13:00:38 -08:00
Cesar Celis Hernandez
815648fe32 Adding the restart API test (#1617) 2022-02-23 22:49:35 -06:00
Harshavardhana
5af76176cd update minio/pkg 2022-02-23 14:29:07 -08:00
Harshavardhana
b1ed8307dd update minio/pkg, minio/madmin-go, minio/minio-go/v7 2022-02-23 14:27:25 -08:00
adfost
b8122ec2bd Pods Summary UI improvements (#1449) 2022-02-23 11:37:26 -06:00
Daniel Valdivia
2b196b89e9 Updates to Add ILM Rule Modal (#1606)
* Updates to Add ILM Rule Modal
* Remove default 0 values for days inputs
2022-02-22 16:50:04 -08:00
Daniel Valdivia
5f1c830f47 Exclude some units from tenant size dropdown (#1615)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-02-22 15:55:49 -08:00
Cesar Celis Hernandez
83fc075bc9 Using Kustomize to get YAML files (#1616) 2022-02-22 17:20:24 -06:00
Daniel Valdivia
8dc000c13b Add contextual unit selector for tenant add. (#1614)
* Add contextual unit selector for tenant add.

Additionally Fix bug on Get Tenant Monitoring and Set tenant Monitoring

Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>

* Fix comment

Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-02-22 12:12:45 -08:00
Cesar Celis Hernandez
b130c89297 Get Operator files for testing (#1613) 2022-02-22 12:53:39 -06:00
Prakash Senthil Vel
4bc90588fb Add tier mandatory or optional fields and navigation post save (#1612) 2022-02-22 12:30:48 -06:00
Prakash Senthil Vel
006b3c7da8 UI for Inspect (#1583) 2022-02-22 12:05:31 -06:00
Cesar Celis Hernandez
1f97f39864 Add test for Put Objects legalhold status end point in Console API (#1577) 2022-02-22 11:39:58 -06:00
Alex
c15d75e619 Changed breadcrumbs styles (#1610)
- Added onKey press support to input boxes

- Added enter key support to create path modal

- Replaced bucket icon

Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-02-22 11:14:55 -06:00
Cesar Celis Hernandez
844162a7ab Add test to list the tenants in Operator UI (#1605)
Co-authored-by: Alex <33497058+bexsoft@users.noreply.github.com>
2022-02-21 21:57:09 -08:00
Daniel Valdivia
56c4311a6b Add feature hide-menu for embedded screens on Operator UI (#1604)
* Add feature hide-menu for embedded screens on Operator UI

Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-02-21 23:42:18 -06:00
Cesar Celis Hernandez
28dcd19dd9 Adding IDs for Operator tests (#1599) 2022-02-18 22:08:07 -06:00
Alex
78e4e3fd08 First set of redesign objects listing (#1602)
- Removed table action buttons & global actions

- Changed Upload Files label

- Added reload, new path & rewind buttons in top bars

- Added multi-select objects panel & table behaviors for single selection & multiselection

- Fixed disabled action button styles

Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>

Co-authored-by: Benjamin Perez <benjamin@bexsoft.net>
2022-02-18 10:18:09 -08:00
Daniel Valdivia
1cdc719405 Add Create Bucket action to kbar (#1600)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-02-17 15:34:56 -08:00
Cesar Celis Hernandez
3cc218b97e Add test for List Bucket Events end point (#1576) 2022-02-17 13:13:41 -06:00
Cesar Celis Hernandez
1f6e2e7f43 Put proper name to the tests (#1598) 2022-02-17 11:09:44 -06:00
Cesar Celis Hernandez
9f521bbfb4 Add Operator test (#1591) 2022-02-17 10:54:16 -06:00
Daniel Valdivia
9c19c639dd Release v0.14.7 (#1594)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-02-16 21:05:41 -08:00
Daniel Valdivia
e3a47d980c Events details component (#1596)
* Events details component

Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>

* lint

Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-02-16 19:33:05 -08:00
Alex
10539929e1 Added quota metric to buckets list & objects list (#1595)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>

Co-authored-by: Benjamin Perez <benjamin@bexsoft.net>
2022-02-16 18:58:08 -08:00
Alex
3606870565 Fixed field reset for memory & cpu fields in new tenant size screen (#1593)
Also fixed an issue with memory limit selection in create tenant

Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-02-16 17:28:56 -08:00
Cesar Celis Hernandez
3307d6f282 put id on create tenant button for testing purposes (#1588)
Co-authored-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-02-16 16:51:26 -08:00
adfost
5dc8d1808c Tenant events UI (#1590) 2022-02-16 18:29:41 -06:00
Daniel Valdivia
8d7cddc20a Fix create bucket and list bucket for wildcard statements in policies (#1589)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-02-16 15:58:34 -08:00
adfost
35f9743a10 tenant events (#1586)
Co-authored-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-02-16 14:22:54 -08:00
jinapurapu
f8c397e231 Update tenant creation credentials JSON (#1559) 2022-02-16 13:52:38 -08:00
Daniel Valdivia
24cf6a3ada Fix Browse Bucket for certain Policy (#1587)
fixes #1320 

Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-02-16 13:20:19 -08:00
Cesar Celis Hernandez
031ee35a00 Add PostgreSQL Notification Test (#1578)
Co-authored-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-02-16 10:23:14 -08:00
Cesar Celis Hernandez
4507ceb36d Allowing distributed mode in MinIO (#1585) 2022-02-16 09:53:34 -08:00
Daniel Valdivia
f6116c1624 Revert "Giving more stability to our testcafe (#1582)" (#1584) 2022-02-16 09:52:03 -07:00
Cesar Celis Hernandez
081df4b535 Add tests for bucket quota end points (#1575) 2022-02-16 09:33:38 -07:00
Cesar Celis Hernandez
e580af8205 Giving more stability to our testcafe (#1582) 2022-02-15 20:58:10 -08:00
Alex
226e8eeef2 Added delete all replication rules capability (#1579) 2022-02-15 17:14:23 -08:00
Cesar Celis Hernandez
00c4ba430d Add test for Delete Object retention from an object end point (#1574) 2022-02-15 18:28:13 -06:00
Prakash Senthil Vel
951d3bf6dc Inspect API (#1540)
* Inspect API

* Address review comments

Co-authored-by: Alex <33497058+bexsoft@users.noreply.github.com>
Co-authored-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-02-15 16:14:51 -08:00
Daniel Valdivia
3ae8e14156 Release v0.14.6 (#1581)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-02-15 15:38:16 -08:00
Prakash Senthil Vel
f170a6ad36 License table and registered status (#1571)
Co-authored-by: Alex <33497058+bexsoft@users.noreply.github.com>
Co-authored-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-02-15 13:45:31 -08:00
Daniel Valdivia
25ff4982a0 Fix Upload Button Logic (#1580)
* Fix Upload Button Logic

Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>

* Re-org function hasAccessToResource

Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>

* Fix Warnings

Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-02-15 13:29:09 -08:00
Cesar Celis Hernandez
0ac6ceca3f Adding 4 volumes to run MinIO Distributed on the tests (#1572)
Co-authored-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-02-15 10:01:10 -08:00
Alex
81714bbbed Added lifecycle rules to multiple buckets at once support (#1566)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>

Co-authored-by: Benjamin Perez <benjamin@bexsoft.net>
2022-02-15 09:47:28 -08:00
Alex
5b2715ccc0 Added support validation against subpaths to hasPermission & SecureComponent (#1570)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>

Co-authored-by: Benjamin Perez <benjamin@bexsoft.net>
2022-02-15 08:25:38 -08:00
dependabot[bot]
ab411577a2 Bump follow-redirects from 1.14.7 to 1.14.8 in /portal-ui (#1567)
Bumps [follow-redirects](https://github.com/follow-redirects/follow-redirects) from 1.14.7 to 1.14.8.
- [Release notes](https://github.com/follow-redirects/follow-redirects/releases)
- [Commits](https://github.com/follow-redirects/follow-redirects/compare/v1.14.7...v1.14.8)

---
updated-dependencies:
- dependency-name: follow-redirects
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-02-13 21:54:38 -08:00
adfost
dce96ecc4b adding user service account policy edit (#1565)
Co-authored-by: Alex <33497058+bexsoft@users.noreply.github.com>
2022-02-12 10:25:27 -06:00
Cesar Celis Hernandez
a232d73cb1 Add test for Bucket Set Policy end point (#1562) 2022-02-11 21:55:26 -08:00
Cesar Celis Hernandez
c986baf2ae Add test for Restore Object to a selected version end point (#1558) 2022-02-11 11:49:01 -08:00
Harshavardhana
df55d5dcde simplify policy document in tests use Go verbatim strings (#1549) 2022-02-11 13:26:11 -06:00
Cesar Celis Hernandez
ed5cf89776 Add test for Put Buckets tags end point (#1556) 2022-02-11 10:17:04 -08:00
Cesar Celis Hernandez
fa3f2283cf Add test for Gets the metadata of an object end point (#1555) 2022-02-10 20:09:30 -06:00
adfost
2988de4025 adding edit service account api/ui (#1545)
Co-authored-by: Alex <33497058+bexsoft@users.noreply.github.com>
2022-02-10 17:18:57 -08:00
Daniel Valdivia
c6f2ddfd7e Release v0.14.5 (#1550)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-02-10 17:06:43 -08:00
Alex
6a7f042d6c Fixed logic for add lifecycle rules (#1553)
- Removed support to fixed date lifecycle rules according resolution of https://github.com/minio/console/issues/1527

Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>

Co-authored-by: Benjamin Perez <benjamin@bexsoft.net>
Co-authored-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-02-10 16:50:27 -08:00
Alex
5fd82ca6e9 Added delete bucket lifecycle rule capability (#1547)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>

Co-authored-by: Benjamin Perez <benjamin@bexsoft.net>
2022-02-10 16:25:59 -08:00
Lenin Alevski
829404b33c Fix session.permission npe (#1551)
Signed-off-by: Lenin Alevski <alevsk.8772@gmail.com>
2022-02-10 15:45:28 -08:00
Daniel Valdivia
610ec0bed4 Fix NPE on permissions (#1548)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-02-10 13:45:18 -08:00
Daniel Valdivia
822f063be3 Release v0.14.4 (#1546)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-02-10 11:25:31 -08:00
Alex
32a3094386 Added lifecycle rule edit capability (#1539)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>

Co-authored-by: Benjamin Perez <benjamin@bexsoft.net>
2022-02-10 09:34:56 -08:00
Cesar Celis Hernandez
07ef32bee3 Add test for Put Objects retention status end point (#1542) 2022-02-10 11:24:09 -06:00
Kaan Kabalak
df17d31721 Add Permission tests for policies that only allow specific Buckets (#1538) 2022-02-09 23:21:56 -06:00
Lenin Alevski
302c0dd8f1 Add support for matching multiple resources in SecureComponent (#1536)
Signed-off-by: Lenin Alevski <alevsk.8772@gmail.com>
2022-02-09 17:52:17 -08:00
Cesar Celis Hernandez
3d70427e2b Add test for Shares an Object on a url end point (#1535) 2022-02-09 17:42:52 -06:00
Daniel Valdivia
c29ac61ff4 Update Logos colors (#1534)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-02-09 14:50:10 -06:00
Alex
c8fdadde39 Implemented edit lifecycle API (#1533)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-02-09 14:30:22 -06:00
Daniel Valdivia
2ffc28a834 Console K Bar (#1532)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-02-09 11:44:49 -06:00
adfost
75b3082172 Service account policy UI (#1519)
* saving

* service account policy UI

* fixing warning

* Update portal-ui/src/screens/Console/Account/ServiceAccountPolicy.tsx

Co-authored-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>

* fixing comment

Co-authored-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
Co-authored-by: Lenin Alevski <alevsk.8772@gmail.com>
2022-02-08 22:52:55 -08:00
Lenin Alevski
7e8441264f Removing date based actions for Lifecycle expiration and transition (#1531) 2022-02-08 16:07:55 -06:00
Kaan Kabalak
b077f2ec22 Handle pluralization for TableWrapper selected text (#1530) 2022-02-08 13:35:31 -06:00
Cesar Celis Hernandez
3262b8fd8f Adding test for service-account-credentials end point (#1528) 2022-02-08 10:39:15 -08:00
jinapurapu
090b7e5e26 Changed HTTP verb to DELETE for DeleteMultipleServiceAccounts (#1526) 2022-02-07 19:51:40 -08:00
Cesar Celis Hernandez
7f05c0bf06 Convert to table driven test (#1506) 2022-02-05 09:26:33 -08:00
Daniel Valdivia
fbb6c81986 Release v0.14.3 (#1520)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-02-04 20:10:34 -08:00
Kaan Kabalak
9e843f4ba0 Add concurrency argument for Permission testing (#1510)
* Add concurrency argument for Permission testing

* Create group before trying to view table

* Increase wait duration for one of the Diagnostic tests
2022-02-04 09:52:28 -06:00
Harshavardhana
4e14ec2742 update mc/termenv dependency to fix terminal hang (#1518)
refer https://github.com/minio/mc/issues/3955
2022-02-03 22:44:45 -08:00
Alex
69ccf4872e Added virtualized list to pod logs in operator console (#1517)
Also removed some execution time errors
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-02-03 22:19:17 -08:00
Prakash Senthil Vel
1c31aff147 UX Basic Dashboard (#1513) 2022-02-03 21:34:13 -08:00
Kaan Kabalak
608a5c3787 Fix User name clicked on Groups page redirecting incorrectly (#1516)
Fixes #1515
2022-02-03 19:07:23 -08:00
Lenin Alevski
297c980a8d Read subnet proxy configuration from minio or env var (#1511)
Signed-off-by: Lenin Alevski <alevsk.8772@gmail.com>
2022-02-03 10:04:35 -08:00
Alex
4091b11f99 Fixed Node Selector reset in Pod placement (#1512) 2022-02-03 08:41:35 -08:00
Harshavardhana
4718380bd2 update termenv dependency to avoid CI/CD terminal hangs (#1507) 2022-02-02 23:14:11 -08:00
Alex
52ea19809e Customized calendar & time pickers for DateTimePicker component (#1508)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-02-02 23:21:46 -06:00
dependabot[bot]
281bd78104 Bump nanoid from 3.1.30 to 3.2.0 in /portal-ui (#1509)
Bumps [nanoid](https://github.com/ai/nanoid) from 3.1.30 to 3.2.0.
- [Release notes](https://github.com/ai/nanoid/releases)
- [Changelog](https://github.com/ai/nanoid/blob/main/CHANGELOG.md)
- [Commits](https://github.com/ai/nanoid/compare/3.1.30...3.2.0)

---
updated-dependencies:
- dependency-name: nanoid
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-02-02 21:30:38 -06:00
Daniel Valdivia
d84e744d05 Update UI Dependencies (#1505)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>

Co-authored-by: Alex <33497058+bexsoft@users.noreply.github.com>
2022-02-02 18:38:20 -08:00
Harshavardhana
1b5bcad3d8 update missing base image update to ubi-8.5 2022-02-02 13:20:05 -08:00
Daniel Valdivia
bfc4b138ff Update unit test list buckets (#1482)
Update unit test list buckets
2022-02-02 12:28:03 -08:00
Lenin Alevski
5a0ec11199 Updating node image and go image in Dockerfile (#1504)
- Updating node image to 17
- Updating go image to 1.17

Signed-off-by: Lenin Alevski <alevsk.8772@gmail.com>
2022-02-02 13:44:43 -06:00
Cesar Celis Hernandez
c52ba1f859 Test to delete multiple objects (#1479) 2022-02-02 13:29:43 -06:00
Cesar Celis Hernandez
d62235ee58 Add test for listing an object (#1484)
* Add test for listing an object

* Add test for listing an object
2022-02-02 13:06:01 -06:00
jinapurapu
e5d2752436 Added multidelete function for Service Accounts (#1501)
Added multidelete function for Service Accounts
2022-02-02 10:21:56 -08:00
Harshavardhana
cffaee84bb upgrade console container base image to ubi-8.5 (#1503) 2022-02-02 08:53:13 -08:00
Alex
96b1d4fe85 Added bucket details inside objects listing (#1502)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-02-01 20:48:58 -08:00
Cesar Celis Hernandez
02acb76ac9 Add test for Bulk functionality to Add Users to Groups (#1495)
Co-authored-by: Lenin Alevski <alevsk.8772@gmail.com>
Co-authored-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-02-01 08:42:09 -08:00
Harshavardhana
038f542895 go mod tidy -compat=1.17 2022-01-31 23:39:28 -08:00
Daniel Valdivia
983e175bc9 Release v0.14.2 (#1499)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-01-31 23:33:57 -08:00
Alex
71ac8d7001 Replaced top breadcrumbs & redesign of bucket breadcrumbs (#1498) 2022-01-31 23:40:23 -07:00
jinapurapu
5258ac3d1a Logging resources selector (#1402)
Added CPU and memory request selector to Log and Log DB
2022-01-31 21:17:21 -08:00
Daniel Valdivia
27d1627c8f Show Warnings when running speed test or diagnostics (#1487)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>

Co-authored-by: Alex <33497058+bexsoft@users.noreply.github.com>
2022-01-31 20:41:02 -08:00
Alex
780cf7240b Changed position of search box for list objects module (#1497)
- Changed the searchbox component to be a controlled component
- Added reducer to control searchbox in objects list
- Adjusted styles to search box component & placeholders
- Fixed navigation of folders

Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>

Co-authored-by: Benjamin Perez <benjamin@bexsoft.net>
2022-01-31 19:46:57 -08:00
Cesar Celis Hernandez
ce989e39ab Add test to add tag to an object (#1481) 2022-01-31 20:46:40 -06:00
adfost
63d3c7207d Service Account Policy API (#1425)
* service account policy

* integration test

Co-authored-by: Alex <33497058+bexsoft@users.noreply.github.com>
Co-authored-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-01-31 13:37:00 -08:00
Lenin Alevski
eb924ec842 testscafe test for upload file button on bucket (#1491)
Signed-off-by: Lenin Alevski <alevsk.8772@gmail.com>

Co-authored-by: Alex <33497058+bexsoft@users.noreply.github.com>
2022-01-31 12:00:33 -08:00
Lenin Alevski
f826453284 Fix duplicated Documentation item in Menu (#1494)
Signed-off-by: Lenin Alevski <alevsk.8772@gmail.com>
2022-01-31 13:53:49 -06:00
Harshavardhana
1e00111b00 remove quota FIFO support (#1492) 2022-01-31 11:10:06 -06:00
Cesar Celis Hernandez
06e1592b54 Added test for downloading an object (#1480) 2022-01-31 10:25:35 -06:00
Alex
41e0c1e39b Fixed EC Parity field reset during tab change (#1490) 2022-01-29 16:28:57 -06:00
Alex
31f63a387e Added object details panel (#1489)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>

Co-authored-by: Benjamin Perez <benjamin@bexsoft.net>
2022-01-28 20:05:23 -08:00
Cesar Celis Hernandez
4a1ccf19a0 Removing unused parameters (#1465) 2022-01-28 21:24:53 -06:00
Lenin Alevski
d8b387434b Enable/Disable upload file and folder button for bucket (#1486) 2022-01-28 14:16:38 -08:00
Cesar Celis Hernandez
2e9a42320c Test to delete object (#1477) 2022-01-28 12:01:38 -06:00
Prakash Senthil Vel
1d92f90cbe UX Register screen (#1485) 2022-01-28 09:08:32 -08:00
Harshavardhana
df728fc8e6 update madmin-go (#1483) 2022-01-27 23:57:30 -07:00
Cesar Celis Hernandez
834e3fb996 Add test to upload an object (#1473)
Co-authored-by: cniackz <cniackz@cniackzs-MacBook-Air.local>
Co-authored-by: Alex <33497058+bexsoft@users.noreply.github.com>
Co-authored-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-01-27 21:51:13 -08:00
Cesar Celis Hernandez
0b7d4a2c35 Add delete bucket test (#1457)
Co-authored-by: cniackz <cniackz@cniackzs-MacBook-Air.local>
Co-authored-by: Alex <33497058+bexsoft@users.noreply.github.com>
Co-authored-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-01-27 17:56:09 -08:00
Cesar Celis Hernandez
e13626e92b Add new test for service account for user (#1469)
Co-authored-by: cniackz <cniackz@cniackzs-MacBook-Air.local>
Co-authored-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-01-27 17:31:13 -08:00
Lenin Alevski
0286010053 Fix regression on disabled elements for SecureComponent (#1478)
Signed-off-by: Lenin Alevski <alevsk.8772@gmail.com>
2022-01-27 13:10:05 -08:00
Harshavardhana
382e315668 remove an unnecessary log in subnet pkg (#1471)
Co-authored-by: Alex <33497058+bexsoft@users.noreply.github.com>
2022-01-27 13:27:44 -06:00
Prakash Senthil Vel
5f5c00adb5 UX Diagnostic icon (#1474) 2022-01-27 12:47:42 -06:00
Prakash Senthil Vel
e093efa931 UX Object Details page (#1475)
Co-authored-by: Lenin Alevski <alevsk.8772@gmail.com>
2022-01-27 09:23:21 -08:00
Alex
c129eae6a7 Bucket objects listing menu redesign (#1467)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>

Co-authored-by: Benjamin Perez <benjamin@bexsoft.net>
2022-01-27 00:28:08 -08:00
Daniel Valdivia
5b6e5786ea Release v0.14.1 (#1472)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-01-26 19:24:36 -08:00
Lenin Alevski
8a8471e49a Support multiple child components for SecureComponent (#1470)
Signed-off-by: Lenin Alevski <alevsk.8772@gmail.com>
2022-01-26 16:59:12 -08:00
Lenin Alevski
719866a574 Fix broken link on license page (#1468)
Signed-off-by: Lenin Alevski <alevsk.8772@gmail.com>
2022-01-26 15:59:07 -08:00
Cesar Celis Hernandez
95ebc3bedf add test to modify users group (#1462)
Co-authored-by: cniackz <cniackz@cniackzs-MacBook-Air.local>
Co-authored-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-01-26 11:38:14 -08:00
Daniel Valdivia
a8747614bf Release v0.14.0 (#1458)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-01-26 11:06:18 -08:00
Daniel Valdivia
c89f5a7003 Tweaks to registration. (#1463)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-01-26 10:21:53 -08:00
Daniel Valdivia
ebcebfbe5f Update MUI to v5.3.1 (#1464)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-01-26 12:12:16 -06:00
Lenin Alevski
c82782fe9f Adding support for configuring subnet proxy (#1460)
Signed-off-by: Lenin Alevski <alevsk.8772@gmail.com>
2022-01-26 09:53:11 -08:00
Cesar Celis Hernandez
e626f59feb Add bucket retention test (#1459)
Co-authored-by: cniackz <cniackz@cniackzs-MacBook-Air.local>
Co-authored-by: Alex <33497058+bexsoft@users.noreply.github.com>
2022-01-25 16:33:54 -08:00
adfost
cc8d5abcd6 Adding PVC events UI (#1448)
* adding PVC events UI

* adding label

Co-authored-by: Prakash Senthil Vel <23444145+prakashsvmx@users.noreply.github.com>
Co-authored-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-01-25 14:02:50 -08:00
Daniel Valdivia
83a4c351dd Fix diagnostics tests (#1456)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-01-25 13:24:19 -08:00
Cesar Celis Hernandez
4c0c46f5a8 Adding Bucket Info Test (#1446)
Co-authored-by: cniackz <cniackz@cniackzs-MacBook-Air.local>
Co-authored-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
Co-authored-by: Alex <33497058+bexsoft@users.noreply.github.com>
2022-01-25 12:16:51 -08:00
Daniel Valdivia
1842caff0f Fix secure component having multiple childs (#1455)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-01-25 11:49:39 -08:00
Lenin Alevski
80d3e8cdb8 Menu scrollbar css styles (#1454)
Signed-off-by: Lenin Alevski <alevsk.8772@gmail.com>

Co-authored-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-01-25 10:58:29 -08:00
Harshavardhana
d936d61b20 add header linter to avoid license header mistakes (#1414)
Co-authored-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-01-25 10:48:49 -08:00
adfost
4a10a81374 Delete Pod UI (#1381)
Co-authored-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-01-25 10:33:51 -08:00
Cesar Celis Hernandez
6404a1b984 Add test for removing a user (#1450)
Co-authored-by: cniackz <cniackz@cniackzs-MacBook-Air.local>
Co-authored-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-01-25 10:23:25 -08:00
Prakash Senthil Vel
a3dc145738 UX navigation menu selected state (#1452)
Co-authored-by: Alex <33497058+bexsoft@users.noreply.github.com>
2022-01-25 10:07:41 -08:00
Alex
dbd1b8781a Fix aria for upload file button (#1451) 2022-01-25 00:26:48 -07:00
adfost
9e7874cc04 PVC Events API (#1409)
Co-authored-by: Alex <33497058+bexsoft@users.noreply.github.com>
2022-01-24 17:07:32 -08:00
Alex
d1d3c96777 Added Upload Files menu (#1447)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>

Co-authored-by: Benjamin Perez <benjamin@bexsoft.net>
2022-01-24 16:53:47 -08:00
Daniel Valdivia
2d975eb6c9 Remove Duck hidden in code (#1445)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-01-24 15:53:23 -08:00
Daniel Valdivia
be054fe4ce License Page UI Updates (#1444)
* License Page UI Updates

Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>

* Lint

Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-01-24 17:40:38 -06:00
Daniel Valdivia
f27902ab92 Have tests create their buckets via minio-js (#1443)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-01-24 11:13:32 -08:00
Cesar Celis Hernandez
7e43719e20 Update User Information Test (#1442)
Co-authored-by: cniackz <cniackz@cniackzs-MacBook-Air.local>
Co-authored-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-01-24 10:09:27 -08:00
Daniel Valdivia
f6016c2769 Menu Adjustments: Watch to Monitoring. Tiers to Settings. Notifications to Settings. (#1436)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>

Co-authored-by: Alex <33497058+bexsoft@users.noreply.github.com>
2022-01-24 09:56:16 -08:00
Cesar Celis Hernandez
0ba60bd674 Add test for listing buckets (#1440) 2022-01-24 11:27:32 -06:00
Lenin Alevski
41b34645f9 Subnet cluster registration (#1338)
- Removed old registration flow
- Add support for new online and offline cluster registration flow
- Support login accounts with mfa enabled
- Registration screens

Signed-off-by: Lenin Alevski <alevsk.8772@gmail.com>
2022-01-23 21:42:00 -08:00
Cesar Celis Hernandez
ceff2840d8 Add get user info test (#1438)
Co-authored-by: cniackz <cniackz@cniackzs-MacBook-Air.local>
Co-authored-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-01-22 20:58:51 -08:00
Alex
6541938f16 Added TableRow customized style option (#1437) 2022-01-22 12:26:16 -08:00
Cesar Celis Hernandez
276eff4f15 Add list user test (#1435) 2022-01-21 21:54:36 -06:00
Daniel Valdivia
a3c9d0fe59 Loading component for suspense loaded screens (#1434)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-01-21 18:57:35 -06:00
Cesar Celis Hernandez
14f032971b Improving bucket tests in Console API (#1430) 2022-01-21 18:41:19 -06:00
Daniel Valdivia
9b9c54f775 Tweak some headers with the new names (#1433)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-01-21 15:57:43 -08:00
Kaan Kabalak
a778a1eaf9 Fix failing tests and remove sleep statement for GitHub Actions (#1432) 2022-01-21 15:21:28 -08:00
Alex
5f281518fc Added fallback to root testing (#1431) 2022-01-21 13:31:29 -08:00
Prakash Senthil Vel
ca7fa30aa8 UX form field label style (#1428) 2022-01-21 14:27:56 -06:00
Cesar Celis Hernandez
df4c63e2a3 Make bucket Integration Test (#1424)
Co-authored-by: cniackz <cniackz@cniackzs-MacBook-Air.local>
2022-01-21 10:20:30 -08:00
Cesar Celis Hernandez
51ce548a00 Add User Integration Test #414 (#1417) 2022-01-20 21:49:54 -06:00
Daniel Valdivia
7aa8217ee7 Adding cache to test (#1426)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-01-20 21:31:16 -06:00
Alex
a926082e4d Updated speedtest behavior (#1427)
- Allowed object size changed in autotune mode
- Removed "Please wait while we get x results... "
- Reorganized advanced options form

Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>

Co-authored-by: Benjamin Perez <benjamin@bexsoft.net>
2022-01-20 18:44:55 -08:00
adfost
3ba7b34b25 Delete all versions (#1376)
* delete all versions

* style

Co-authored-by: Prakash Senthil Vel <23444145+prakashsvmx@users.noreply.github.com>
Co-authored-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-01-20 17:28:52 -08:00
Daniel Valdivia
d9531f9617 Fix the Admin UI Tests (#1423)
* Fix the Admin UI Tests

Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>

* concurrency

* Fix heal tests

Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>

* fix Logs and trace

Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>

* Fix tests that weren't passing

* concurrency

Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>

Co-authored-by: Kaan Kabalak <kaan@minio.io>
2022-01-20 16:50:52 -08:00
Prakash Senthil Vel
18c14cc452 UX menu redesign (#1415)
Co-authored-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-01-20 10:08:00 -08:00
Daniel Valdivia
1e7a5647dd Release v0.13.3 (#1416)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-01-20 00:14:17 -08:00
Alex
7edab62651 Added new features to bucket replication rules panel (#1412)
- Added Edit option for replication
- Sorted by priority in replication list
- Fixed an issue where storage class was not saved for replication rule
- Added metadata replication selector to both add & edit windows

Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>

Co-authored-by: Benjamin Perez <benjamin@bexsoft.net>
2022-01-19 23:29:57 -08:00
Alex
9e9321ab00 Fixed issue where storage class resets when changing between tabs (#1418)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-01-19 23:23:40 -06:00
Harshavardhana
3caa9a8e38 separate operator binary code to reduce binary size (#1314)
remove logsearchapi dependency, no definitive struct
marshalling is needed since UI is schemaless for
search response.
2022-01-19 11:13:26 -08:00
Daniel Valdivia
02b6add514 Make view button for tenant available regardless of it being online (#1411)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-01-18 21:27:34 -06:00
Prakash Senthil Vel
67574ff92e Fix access rule edit name display for the default prefix (#1404) 2022-01-17 13:20:39 -06:00
Cesar Celis Hernandez
158c231858 Update Integration tests on console to build MinIO latest (#1398) 2022-01-15 09:24:54 -08:00
Kaan Kabalak
479fa34542 Automate end-to-end permission testing (#1383)
Automate permission testing
2022-01-14 17:04:40 -08:00
Daniel Valdivia
0ba5db58ec Rework Monitoring and Loggins edit forms (#1399)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-01-14 17:51:06 -06:00
Harshavardhana
a15456896b remove frivolous printing on terminal (#1400)
Co-authored-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-01-14 14:50:42 -08:00
jinapurapu
e374772fc6 Added Prometheus monitoring CPU and memory selector. (#1387)
* Added Prometheus monitoring CPU and memory selector.

* Minor text fixes

* Fixed memory units, improvements to get return

* Updated logic to add storageClassName to get response

* Minor fixes, removed warnings

* Removed blank entry for empty storageclassname

Co-authored-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-01-14 11:15:09 -08:00
Alex
257f02c554 Added priority selector to add replication screen (#1396)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>

Co-authored-by: Benjamin Perez <benjamin@bexsoft.net>
2022-01-14 10:33:37 -08:00
Daniel Valdivia
826cb41392 Fix for issue #1390 caused by secure component having multiple childs (#1394)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-01-14 12:22:01 -06:00
Prakash Senthil Vel
dcfc74ad0b UX Button for page actions (#1392)
Co-authored-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-01-13 13:55:30 -06:00
Cesar Celis Hernandez
5745137a34 updating operator in console (#1393)
Co-authored-by: cniackz <cniackz@cniackzs-MacBook-Air.local>
2022-01-13 11:10:05 -08:00
Harshavardhana
3adc4cb0d4 update console to releave v7.0.21 (#1391) 2022-01-12 20:26:10 -08:00
Daniel Valdivia
fb74ac2601 Detect basename for react router (#1384)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-01-12 19:04:08 -08:00
Daniel Valdivia
d269cfcd31 Update go-swagger and go-openapi dependencies (#1385)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-01-12 18:59:14 -08:00
Cesar Celis Hernandez
1871f2bf9e to fail test when yarn does not build (#1388)
* to fail test when yarn does not build

* Warnings cleanup (#1389)

Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>

Co-authored-by: Benjamin Perez <benjamin@bexsoft.net>

* to fail test when yarn does not build

Co-authored-by: cniackz <cniackz@cniackzs-MacBook-Air.local>
Co-authored-by: Alex <33497058+bexsoft@users.noreply.github.com>
Co-authored-by: Benjamin Perez <benjamin@bexsoft.net>
2022-01-12 16:57:50 -08:00
Alex
c386040f99 Warnings cleanup (#1389)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>

Co-authored-by: Benjamin Perez <benjamin@bexsoft.net>
2022-01-12 16:48:43 -08:00
Alex
583111fa9b Added virtualized render to buckets & tenants lists (#1386)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-01-12 15:14:24 -08:00
Prakash Senthil Vel
6448a8e821 UX service account and settings (#1374)
* UX service account and settings

* Update icon and color
2022-01-12 11:53:47 -06:00
Daniel Valdivia
2e7d8d3642 Tweaks to Tenant Details for Logging and Monitoring (#1382)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-01-11 20:23:17 -08:00
jinapurapu
6527bd02e8 Added informative message for 413 error file too large (#1379) 2022-01-11 19:45:14 -08:00
adfost
0400e0c6d5 Tenant Logs (#1140)
Co-authored-by: Adam Stafford <adamstafford@Adams-MacBook-Pro.local>
2022-01-11 15:18:31 -08:00
adfost
3a0a2b14d9 Chinese Filename Bug Fix (#1366) 2022-01-11 15:11:47 -08:00
adfost
9997afeedc Delete PVC API commit (#1378)
* Delete PVC API commit

* Delete install_nvm.sh
2022-01-11 14:28:15 -06:00
Daniel Valdivia
b026baee34 Fix bug on opertator UI where metrics was showing the menu (#1377)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-01-11 13:55:06 -06:00
Lenin Alevski
5ee3ef4fe4 Validate requests to logSearchApi endpoint (#1375)
- Previously any user with a validate session in console could query the
  `/api/v1/logs/search` endpoint which was not ideal, now we are
  limiting that to users with the `admin:OBDInfo` iam action
- Removing deprecated `has-permission` endpoint and backend code

Signed-off-by: Lenin Alevski <alevsk.8772@gmail.com>
2022-01-11 11:08:30 -08:00
Alex
c90094e328 Updated react-scripts version to 5.0.0 (#1372)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>
2022-01-10 11:35:35 -08:00
Harshavardhana
ef1dc172fd add '/' implicitly to console_subpath (#1371) 2022-01-08 20:56:54 -08:00
Daniel Valdivia
eadc449bb0 Fail PR if Warnings are present in React Code (#1348) 2022-01-07 10:29:44 -08:00
Harshavardhana
8c63d6dd4a skip failing subnet JWT tests 2022-01-06 21:23:26 -08:00
Daniel Valdivia
40c3161416 Report N/A when usage is not yet known (#1369)
* Report N/A when usage is not yet known

Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>

* lint

Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-01-06 21:17:20 -08:00
Daniel Valdivia
ef2d2875b2 Small Tweaks to Tiers List (#1368) 2022-01-06 10:02:45 -08:00
Prakash Senthil Vel
2310865425 UX Tiers (#1367) 2022-01-06 08:13:20 -08:00
Daniel Valdivia
4649e1697b Release v0.13.2 (#1362)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-01-03 22:02:23 -08:00
Prakash Senthil Vel
b9ddadf9ce UX Bucket summary (#1355) 2022-01-03 21:30:38 -08:00
Kanagaraj M
eae9f46ac4 add gcp marketplace server configurations (#1361) 2022-01-03 19:07:02 -08:00
Daniel Valdivia
68ffd0814b Rework Tenant Details as two columns (#1360)
* Rework Tenant Details as two columns

Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>

* remove placeholder

Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2022-01-03 18:42:21 -08:00
Prakash Senthil Vel
9b12f5a41e UX left sidebar menu (#1356) 2022-01-03 18:26:32 -08:00
jinapurapu
dd781dc6da Configure tenant monitoring tab (#1295)
* Configure tenant monitoring tab rework on new branch

* Removed unneeded code

* Fixed empty value bug

* rebased to master

* Configure tenant monitoring tab rework on new branch

* Removed unneded imports, commented lines

* Removed endpoints.go

* Rebased to master and modified to work without endpoints.go

* Removed unused function
2022-01-03 16:43:41 -08:00
Anis Elleuch
0cfa6f774b Add Azure marketplace VM choices (#1358)
Add Azure VM configurations for the marketplace option
2022-01-03 16:31:12 -08:00
Anis Elleuch
13a5a7186c Use default storage class for postgre/prometheus if not user specified (#1359)
Currently we are using empty string as storage class for postgre and
prometheus pods when the user does not provide any value. However any
empty value as storage class has a special meaning in Kubernetes:

```
If storageClassName is set to an empty string ('') in the PVC, no
storage class will be used (i.e.; dynamic provisioning is disabled for
this PVC)

Existing, “Available”, PVs (that do not have a specified storageClassName)
will be considered for binding to the PVC.
```

This commit will avoid setting the storage class in the PVC declaration,
so the default storage class will be used.
2022-01-03 16:29:27 -08:00
Harshavardhana
fc5cf8aeac update dependencies for selfupdate to v0.4.0 2022-01-03 11:58:18 -08:00
adfost
591440880c enable versioning if locking (#1350) 2022-01-02 22:59:02 -08:00
Alex
ac64eedc14 Renamed marketplace functions (#1354)
Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>

Co-authored-by: Benjamin Perez <benjamin@bexsoft.net>
2021-12-30 18:08:13 -08:00
Lenin Alevski
b04ea490f8 Fix object name in object manager (#1353)
Signed-off-by: Lenin Alevski <alevsk.8772@gmail.com>
2021-12-30 16:56:06 -08:00
Alex
5373e1dc19 Added initial AWS Marketplace support to operator console (#1347)
* Added initial AWS Marketplace support to operator console

Signed-off-by: Benjamin Perez <benjamin@bexsoft.net>

* Renamed interface

* Removed resources request in tenant request.

* Destructured map state in Tenant Size

* Resource Validations

Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>

* Removed ecparity set default option

Co-authored-by: Benjamin Perez <benjamin@bexsoft.net>
Co-authored-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
2021-12-30 16:43:28 -08:00
Daniel Valdivia
7410fdbcc9 Chain Upload Folders with Promises (#1352) 2021-12-30 14:34:33 -08:00
jinapurapu
3f4b595779 Improved folder drop upload behavior (#1331) 2021-12-30 15:43:33 -06:00
Prakash Senthil Vel
3d357c8c22 Tab UX colors (#1349) 2021-12-30 11:22:36 -08:00
adfost
b2f38200f7 Custom Policies for Buckets (#1332)
* custom policies

* fixing error

* add formatting
2021-12-28 20:21:29 -06:00
Prakash Senthil Vel
10b8a93b5e UX Tenant summary screen (#1346) 2021-12-28 13:37:23 -06:00
Harshavardhana
19caa72495 update to release v0.13.1 2021-12-26 22:16:01 -08:00
Harshavardhana
6cc649da83 update minio-go to v7.0.20 to fix STS error responses 2021-12-26 22:15:12 -08:00
3127 changed files with 328163 additions and 429575 deletions

View File

@@ -1,7 +0,0 @@
node_modules/
dist/
target/
console
!console/
portal-ui/node_modules/
.git/

49
.github/ISSUE_TEMPLATE/bug_report.md vendored Normal file
View File

@@ -0,0 +1,49 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: community, triage
assignees: ''
---
## NOTE
Please subscribe to our [paid subscription plans](https://min.io/pricing) for 24x7 support from our Engineering team.
<!--- Provide a general summary of the issue in the title above -->
## Expected Behavior
<!--- If you're describing a bug, tell us what should happen -->
<!--- If you're suggesting a change/improvement, tell us how it should work -->
## Current Behavior
<!--- If describing a bug, tell us what happens instead of the expected behavior -->
<!--- If suggesting a change/improvement, explain the difference from current behavior -->
## Possible Solution
<!--- Not obligatory, but suggest a fix/reason for the bug, -->
<!--- or ideas how to implement the addition or change -->
## Steps to Reproduce (for bugs)
<!--- Provide a link to a live example, or an unambiguous set of steps to -->
<!--- reproduce this bug. Include code to reproduce, if relevant -->
1.
2.
3.
4.
## Context
<!--- How has this issue affected you? What are you trying to accomplish? -->
<!--- Providing context helps us come up with a solution that is most useful in the real world -->
## Regression
<!-- Is this issue a regression? (Yes / No) -->
<!-- If Yes, optionally please include the MinIO version or commit id or PR# that caused this regression, if you have these details. -->
## Your Environment
<!--- Include as many relevant details about the environment you experienced the bug in -->
* MinIO version used (`minio --version`):
* Server setup and configuration:
* Operating System and version (`uname -a`):

View File

@@ -1,34 +0,0 @@
name: Go
on:
pull_request:
branches:
- master
push:
branches:
- master
jobs:
build:
name: Compiles on Go ${{ matrix.go-version }} and ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
go-version: [1.17.x]
os: [ubuntu-latest]
steps:
- name: Set up Go ${{ matrix.go-version }} on ${{ matrix.os }}
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go-version }}
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@v2
- name: Build on ${{ matrix.os }}
env:
GO111MODULE: on
GOOS: linux
run: |
make console

View File

@@ -1,34 +0,0 @@
name: Go
on:
pull_request:
branches:
- master
push:
branches:
- master
jobs:
build:
name: Cross compile
runs-on: ${{ matrix.os }}
strategy:
matrix:
go-version: [1.17.x]
os: [ubuntu-latest]
steps:
- name: Set up Go ${{ matrix.go-version }} on ${{ matrix.os }}
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go-version }}
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@v2
- name: Build on ${{ matrix.os }}
env:
GO111MODULE: on
GOOS: linux
run: |
make crosscompile arg1="'linux/ppc64le linux/mips64'"

View File

@@ -1,34 +0,0 @@
name: Go
on:
pull_request:
branches:
- master
push:
branches:
- master
jobs:
build:
name: Cross compile
runs-on: ${{ matrix.os }}
strategy:
matrix:
go-version: [1.17.x]
os: [ubuntu-latest]
steps:
- name: Set up Go ${{ matrix.go-version }} on ${{ matrix.os }}
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go-version }}
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@v2
- name: Build on ${{ matrix.os }}
env:
GO111MODULE: on
GOOS: linux
run: |
make crosscompile arg1="'linux/arm64 linux/s390x'"

View File

@@ -1,34 +0,0 @@
name: Go
on:
pull_request:
branches:
- master
push:
branches:
- master
jobs:
build:
name: Cross compile
runs-on: ${{ matrix.os }}
strategy:
matrix:
go-version: [1.17.x]
os: [ubuntu-latest]
steps:
- name: Set up Go ${{ matrix.go-version }} on ${{ matrix.os }}
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go-version }}
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@v2
- name: Build on ${{ matrix.os }}
env:
GO111MODULE: on
GOOS: linux
run: |
make crosscompile arg1="'darwin/amd64 freebsd/amd64'"

View File

@@ -1,34 +0,0 @@
name: Go
on:
pull_request:
branches:
- master
push:
branches:
- master
jobs:
build:
name: Cross compile
runs-on: ${{ matrix.os }}
strategy:
matrix:
go-version: [1.17.x]
os: [ubuntu-latest]
steps:
- name: Set up Go ${{ matrix.go-version }} on ${{ matrix.os }}
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go-version }}
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@v2
- name: Build on ${{ matrix.os }}
env:
GO111MODULE: on
GOOS: linux
run: |
make crosscompile arg1="'windows/amd64 linux/arm'"

View File

@@ -1,34 +0,0 @@
name: Go
on:
pull_request:
branches:
- master
push:
branches:
- master
jobs:
build:
name: Cross compile
runs-on: ${{ matrix.os }}
strategy:
matrix:
go-version: [1.17.x]
os: [ubuntu-latest]
steps:
- name: Set up Go ${{ matrix.go-version }} on ${{ matrix.os }}
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go-version }}
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@v2
- name: Build on ${{ matrix.os }}
env:
GO111MODULE: on
GOOS: linux
run: |
make crosscompile arg1="'linux/386 netbsd/amd64'"

View File

@@ -1,34 +0,0 @@
name: Go
on:
pull_request:
branches:
- master
push:
branches:
- master
jobs:
build:
name: Test Pkg on Go ${{ matrix.go-version }} and ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
go-version: [1.17.x]
os: [ubuntu-latest]
steps:
- name: Set up Go ${{ matrix.go-version }} on ${{ matrix.os }}
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go-version }}
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@v2
- name: Build on ${{ matrix.os }}
env:
GO111MODULE: on
GOOS: linux
run: |
make test-pkg

View File

@@ -1,34 +0,0 @@
name: Go
on:
pull_request:
branches:
- master
push:
branches:
- master
jobs:
build:
name: Test Restapi on Go ${{ matrix.go-version }} and ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
go-version: [1.17.x]
os: [ubuntu-latest]
steps:
- name: Set up Go ${{ matrix.go-version }} on ${{ matrix.os }}
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go-version }}
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@v2
- name: Build on ${{ matrix.os }}
env:
GO111MODULE: on
GOOS: linux
run: |
make test

View File

@@ -1,38 +0,0 @@
name: Go
on:
pull_request:
branches:
- master
push:
branches:
- master
# This ensures that previous jobs for the PR are canceled when the PR is
# updated.
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref }}
cancel-in-progress: true
jobs:
minio-test:
name: Integration Tests with Latest Distributed MinIO
runs-on: ubuntu-latest
strategy:
matrix:
go-version: [1.17.x]
steps:
- name: Set up Go ${{ matrix.go-version }} on ${{ matrix.os }}
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go-version }}
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@v2
- name: Build on ${{ matrix.os }}
run: |
make test-integration

18
.github/workflows/issues.yaml vendored Normal file
View File

@@ -0,0 +1,18 @@
# @format
name: Issue Workflow
on:
issues:
types:
- opened
jobs:
add-to-project:
name: Add issue to project
runs-on: ubuntu-latest
steps:
- uses: actions/add-to-project@v0.5.0
with:
project-url: https://github.com/orgs/miniohq/projects/2
github-token: ${{ secrets.BOT_PAT }}

1497
.github/workflows/jobs.yaml vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -1,34 +0,0 @@
name: Go
on:
pull_request:
branches:
- master
push:
branches:
- master
jobs:
build:
name: Checking Lint
runs-on: ${{ matrix.os }}
strategy:
matrix:
go-version: [1.17.x]
os: [ubuntu-latest]
steps:
- name: Set up Go ${{ matrix.go-version }} on ${{ matrix.os }}
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go-version }}
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@v2
- name: Build on ${{ matrix.os }}
env:
GO111MODULE: on
GOOS: linux
run: |
make verifiers

View File

@@ -1,15 +0,0 @@
name: "React Tests"
on:
push:
pull_request:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install modules
working-directory: ./portal-ui
run: yarn
- name: Run tests
working-directory: ./portal-ui
run: yarn test

53
.github/workflows/vulncheck.yaml vendored Normal file
View File

@@ -0,0 +1,53 @@
# @format
name: Vulnerability Check
on:
pull_request:
branches:
- master
permissions:
contents: read # to fetch code (actions/checkout)
jobs:
vulncheck:
name: Analysis
runs-on: ubuntu-latest
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 1.22.5
check-latest: true
- name: Get official govulncheck
run: go install golang.org/x/vuln/cmd/govulncheck@latest
shell: bash
- name: Run govulncheck
run: govulncheck ./...
shell: bash
react-code-known-vulnerabilities:
name: "React Code Has No Known Vulnerable Deps"
runs-on: ubuntu-latest
strategy:
matrix:
go-version: [ 1.22.5 ]
os: [ ubuntu-latest ]
steps:
- name: Check out code
uses: actions/checkout@v3
- name: Read .nvmrc
id: node_version
run: echo "$(cat .nvmrc)" && echo "NVMRC=$(cat .nvmrc)" >> $GITHUB_ENV
- name: Enable Corepack
run: corepack enable
- uses: actions/setup-node@v4
with:
node-version: ${{ env.NVMRC }}
- name: Checks for known security issues with the installed packages
working-directory: ./web-app
continue-on-error: false
run: |
yarn npm audit --recursive --environment production --no-deprecations

13
.gitignore vendored
View File

@@ -1,3 +1,13 @@
# Playwright Data
web-app/storage/
web-app/playwright/.auth/admin.json
# Report from Playwright
web-app/playwright-report/
# Coverage from Playwright
web-app/.nyc_output/
# Binaries for programs and plugins
*.exe
*.exe~
@@ -19,6 +29,7 @@ vendor/
# Ignore executables
target/
!pkg/logger/target/
console
!console/
@@ -26,7 +37,7 @@ dist/
# Ignore node_modules
portal-ui/node_modules/
web-app/node_modules/
# Ignore tls cert and key
private.key

View File

@@ -5,34 +5,45 @@ linters-settings:
misspell:
locale: US
goheader:
values:
regexp:
copyright-holder: Copyright \(c\) (20\d\d\-20\d\d)|2021|({{year}})
template-path: .license.tmpl
linters:
disable-all: true
enable:
- typecheck
- goimports
- misspell
- govet
- revive
- ineffassign
- gosimple
- deadcode
- unparam
- gomodguard
- gofmt
- unused
- structcheck
- staticcheck
- unconvert
- gocritic
- gofumpt
- durationcheck
service:
golangci-lint-version: 1.27.0 # use the fixed version to not introduce new linters unexpectedly
golangci-lint-version: 1.43.0 # use the fixed version to not introduce new linters unexpectedly
issues:
exclude-use-default: false
exclude:
- should have a package comment
# TODO(y4m4): Remove once all exported ident. have comments!
- comment on exported function
- comment on exported type
- should have comment
- use leading k in Go names
- comment on exported const
- should have a package comment
# TODO(y4m4): Remove once all exported ident. have comments!
- comment on exported function
- comment on exported type
- should have comment
- use leading k in Go names
- comment on exported const
run:
skip-dirs:
- pkg/clientgen
- pkg/apis/networking.gke.io
- api/operations

View File

@@ -1,195 +0,0 @@
# This is an example goreleaser.yaml file with some sane defaults.
# Make sure to check the documentation at http://goreleaser.com
project_name: console
release:
name_template: "Release version {{.Tag}}"
github:
owner: minio
name: console
extra_files:
- glob: "*.minisig"
before:
hooks:
# you may remove this if you don't use vgo
- go mod tidy
builds:
-
goos:
- linux
- darwin
- windows
goarch:
- amd64
- ppc64le
- s390x
- arm64
ignore:
- goos: darwin
goarch: arm
- goos: windows
goarch: arm64
- goos: windows
goarch: arm
env:
- CGO_ENABLED=0
main: ./cmd/console/
flags:
- -trimpath
- --tags=kqueue
ldflags:
- -s -w -X github.com/minio/console/pkg.ReleaseTag={{.Tag}} -X github.com/minio/console/pkg.CommitID={{.FullCommit}} -X github.com/minio/console/pkg.Version={{.Version}} -X github.com/minio/console/pkg.ShortCommitID={{.ShortCommit}} -X github.com/minio/console/pkg.ReleaseTime={{.Date}}
archives:
-
name_template: "{{ .ProjectName }}-{{ .Os }}-{{ .Arch }}"
format: binary
replacements:
arm: arm
signs:
-
signature: "${artifact}.minisig"
cmd: "sh"
args:
- '-c'
- 'minisign -s /media/${USER}/minio/minisign.key -Sm ${artifact} < /media/${USER}/minio/minisign-passphrase'
artifacts: all
snapshot:
name_template: v0.0.0@{{.ShortCommit}}
changelog:
sort: asc
nfpms:
-
vendor: MinIO, Inc.
homepage: https://github.com/minio/console
maintainer: MinIO Development <dev@min.io>
description: MinIO Console Server
license: GNU Affero General Public License v3.0
formats:
- deb
- rpm
contents:
# Basic file that applies to all packagers
- src: systemd/console.service
dst: /etc/systemd/system/minio-console.service
dockers:
- image_templates:
- "minio/console:{{ .Tag }}-amd64"
use: buildx
goarch: amd64
dockerfile: Dockerfile.release
extra_files:
- LICENSE
- CREDITS
build_flag_templates:
- "--platform=linux/amd64"
- "--build-arg=TAG={{ .Tag }}"
- image_templates:
- "minio/console:{{ .Tag }}-ppc64le"
use: buildx
goarch: ppc64le
dockerfile: Dockerfile.release
extra_files:
- LICENSE
- CREDITS
build_flag_templates:
- "--platform=linux/ppc64le"
- "--build-arg=TAG={{ .Tag }}"
- image_templates:
- "minio/console:{{ .Tag }}-s390x"
use: buildx
goarch: s390x
dockerfile: Dockerfile.release
extra_files:
- LICENSE
- CREDITS
build_flag_templates:
- "--platform=linux/s390x"
- "--build-arg=TAG={{ .Tag }}"
- image_templates:
- "minio/console:{{ .Tag }}-arm64"
use: buildx
goarch: arm64
goos: linux
dockerfile: Dockerfile.release
extra_files:
- LICENSE
- CREDITS
build_flag_templates:
- "--platform=linux/arm64"
- "--build-arg=TAG={{ .Tag }}"
- image_templates:
- "quay.io/minio/console:{{ .Tag }}-amd64"
use: buildx
goarch: amd64
dockerfile: Dockerfile.release
extra_files:
- LICENSE
- CREDITS
build_flag_templates:
- "--platform=linux/amd64"
- "--build-arg=TAG={{ .Tag }}"
- image_templates:
- "quay.io/minio/console:{{ .Tag }}-ppc64le"
use: buildx
goarch: ppc64le
dockerfile: Dockerfile.release
extra_files:
- LICENSE
- CREDITS
build_flag_templates:
- "--platform=linux/ppc64le"
- "--build-arg=TAG={{ .Tag }}"
- image_templates:
- "quay.io/minio/console:{{ .Tag }}-s390x"
use: buildx
goarch: s390x
dockerfile: Dockerfile.release
extra_files:
- LICENSE
- CREDITS
build_flag_templates:
- "--platform=linux/s390x"
- "--build-arg=TAG={{ .Tag }}"
- image_templates:
- "quay.io/minio/console:{{ .Tag }}-arm64"
use: buildx
goarch: arm64
goos: linux
dockerfile: Dockerfile.release
extra_files:
- LICENSE
- CREDITS
build_flag_templates:
- "--platform=linux/arm64"
- "--build-arg=TAG={{ .Tag }}"
docker_manifests:
- name_template: minio/console:{{ .Tag }}
image_templates:
- minio/console:{{ .Tag }}-amd64
- minio/console:{{ .Tag }}-arm64
- minio/console:{{ .Tag }}-ppc64le
- minio/console:{{ .Tag }}-s390x
- name_template: quay.io/minio/console:{{ .Tag }}
image_templates:
- quay.io/minio/console:{{ .Tag }}-amd64
- quay.io/minio/console:{{ .Tag }}-arm64
- quay.io/minio/console:{{ .Tag }}-ppc64le
- quay.io/minio/console:{{ .Tag }}-s390x
- name_template: minio/console:latest
image_templates:
- minio/console:{{ .Tag }}-amd64
- minio/console:{{ .Tag }}-arm64
- minio/console:{{ .Tag }}-ppc64le
- minio/console:{{ .Tag }}-s390x

15
.license.tmpl Normal file
View File

@@ -0,0 +1,15 @@
This file is part of MinIO Console Server
{{copyright-holder}} MinIO, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.

1
.nvmrc Normal file
View File

@@ -0,0 +1 @@
18

35
.semgrepignore Normal file
View File

@@ -0,0 +1,35 @@
# Ignore git items
.gitignore
.git/
:include .gitignore
# Common large paths
node_modules/
web-app/node_modules/
build/
dist/
.idea/
vendor/
.env/
.venv/
.tox/
*.min.js
# Common test paths
test/
tests/
*_test.go
# Semgrep rules folder
.semgrep
# Semgrep-action log folder
.semgrep_logs/
# Ignore VsCode files
.vscode/
*.code-workspace
*~
.eslintcache
consoleApi.ts

389
CHANGELOG.md Normal file
View File

@@ -0,0 +1,389 @@
<!-- @format -->
# Changelog
## Release v1.7.0
Bug Fix:
- Fixed directory listing
- Fix MinIO videos link
Additional Changes:
- Removed deprecated KES functionality
## Release v1.6.3
Additional Changes:
- Updated go.mod version
## Release v1.6.2
Bug Fix:
- Fixed minor user session issues
- Updated project dependencies
Additional Changes:
- Improved Drives List visualization
- Improved WS request logic
- Updated License page with current MinIO plans.
## Release v1.6.1
Bug Fix:
- Fixed objectManager issues under certain conditions
- Fixed Security vulnerability in dependencies
Additional Changes:
- Improved Share Link behavior
## Release v1.6.0
Bug Fix:
- Fixed share link encoding
- Fixed Edit Lifecycle Storage Class
- Added Tiers Improvements for Bucket Lifecycle management
Additional Changes:
- Vulnerability updates
- Update Logo logic
## Release v1.5.0
Features:
- Added remove Tier functionality
Bug Fix:
- Fixed ILM rule tags not being shown
- Fixed race condition Object Browser websocket
- Fixed Encryption page crashing on empty response
- Fixed Replication Delete Marker comparisons
Additional Changes:
- Use automatic URI encoding for APIs
- Vulnerability updates
## Release v1.4.0
Features:
- Added VersionID support to metadata details
- Improved Websockets handlers
Bug Fix:
- Fixed vulnerabilities and updated dependencies
- Fixed an issue with Download URL decoding
- Fixed leak in Object Browser Websocket
- Minor UX fixes
## Release v1.3.0
Features:
- Adds ExpireDeleteMarker status to BucketLifecycleRule UI
Bug Fix:
- Fixed vulnerability
- Used URL-safe base64 enconding for Share API
- Made Prefix field optional when Adding Tier
- Added Console user agent in MinIO Admin Client
## Release v1.2.0
Features:
- Updated file share logic to work as Proxy
Bug Fix:
- Updated project dependencies
- Fixed Key Permissions UX
- Added permissions validation to rewind button
- Fixed Health report upload to SUBNET
- Misc Cosmetic fixes
## Release v1.1.1
Bug Fix:
- Fixed folder download issue
## Release v1.1.0
Features:
- Added Set Expired object all versions selector
Bug Fix:
- Updated Go Dependencies
## Release v1.0.0
Features:
- Updated Preview message alert
Bug Fix:
- Updated Websocket API
- Fixed issues with download manager
- Fixed policies issues
## Release v0.46.0
Features:
- Added latest help content to forms
Bug Fix:
- Disabled Create User button in certain policy cases
- Fixed an issue with Logout request
- Upgraded project dependencies
## Release v0.45.0
Deprecated:
- Deprecated Heal / Drives page
Features:
- Updated tines on menus & pages
Bug Fix:
- Upgraded project dependencies
## Release v0.44.0
Bug Fix:
- Upgraded project dependencies
- Fixed events icons not loading in subpaths
## Release v0.43.1
Bug Fix:
- Update Share Object UI to reflect maximum expiration time in UI
## Release v0.43.0
Features:
- Updated PDF preview method
Bug Fix:
- Fixed vulnerabilities
- Prevented non-necessary metadata calls in object browser
## Release v0.42.2
Bug Fix:
- Hidden Prometheus metrics if URL is empty
## Release v0.42.1
Bug Fix:
- Reset go version to 1.19
## Release v0.42.0
Features:
- Introducing Dark Mode
Bug Fix:
- Fixed vulnerabilities
- Changes on Upload and Delete object urls
- Fixed blocking subpath creation if not enough permissions
- Removed share object option at prefix level
- Updated allowed actions for a deleted object
## Release v0.41.0
Features:
- Updated pages to use mds components
- support for resolving IPv4/IPv6
Bug Fix:
- Remove cache for ClientIP
- Fixed override environment variables display in settings page
- Fixed daylight savings time support in share modal
## Release v0.40.0
Features:
- Updated OpenID page
- Added New bucket event types support
Bug Fix:
- Fixed crash in access keys page
- Fixed AuditLog filters issue
- Fixed multiple issues with Object Browser
## Release v0.39.0
Features:
- Migrated metrics page to mds
- Migrated Register page to mds
Bug Fix:
- Fixed LDAP configuration page issues
- Load available certificates in logout
- Updated dependencies & go version
- Fixed delete objects functionality
## Release v0.38.0
Features:
- Added extra information to Service Accounts page
- Updated Tiers, Site Replication, Speedtest, Heal & Watch pages components
Bug Fix:
- Fixed IDP expiry time errors
- Updated project Dependencies
## Release v0.37.0
Features:
- Updated Trace and Logs page components
- Updated Prometheus metrics
Bug Fix:
- Disabled input fields for Subscription features if MinIO is not registered
## Release v0.36.0
Features:
- Updated Settings page components
Bug Fix:
- Show LDAP Enabled value LDAP configuration
- Download multiple objects in same path as they were selected
## Release v0.35.1
Bug Fix:
- Change timestamp format for zip creation
## Release v0.35.0
Features:
- Add Exclude Folders and Exclude Prefixes during bucket creation
- Download multiple selected objects as zip and ignore deleted objects
- Updated Call Home, Inspet, Profile and Health components
Bug Fix:
- Remove extra white spaces for configuration strings
- Allow Create New Path in bucket view when having right permissions
## Release v0.34.0
Features:
- Updated Buckets components
Bug Fix:
- Fixed SUBNET Health report upload
- Updated Download Handler
- Fixes issue with rewind
- Avoid 1 hour expiration for IDP credentials
---
## Release v0.33.0
Features:
- Updated OpenID, LDAP components
Bug Fix:
- Fixed security issues
- Fixed navigation issues in Object Browser
- Fixed Dashboard metrics
---
## Release v0.32.0
Features:
- Updated Users and Groups components
- Added placeholder image for Help Menu
Bug Fix:
- Fixed memory leak in WebSocket API for Object Browser
---
## Release v0.31.0
**Breaking Changes:**
- **Removed support for Standalone Deployments**
Features:
- Updated way files are displayed in uploading component
- Updated Audit Logs and Policies components
Bug Fix:
- Fixed Download folders issue in Object Browser
- Added missing Notification Events (ILM & REPLICA) in Events Notification Page
- Fixed Security Vulnerability for `semver` dependency
---
## Release v0.30.0
Features:
- Added MinIO Console Help Menu
- Updated UI Menu components
Bug Fix:
- Disable the Upload button on Object Browser if the user is not allowed
- Fixed security vulnerability for `lestrrat-go/jwx` and `fast-xml-parser`
- Fixed bug on sub-paths for Object Browser
- Reduce the number of calls to `/session` API endpoint to improve performance
- Rolled back the previous change for the Share File feature to no longer ask for Service Account access keys

View File

@@ -4,56 +4,80 @@ This is a REST portal server created using [go-swagger](https://github.com/go-sw
The API handlers are created using a YAML definition located in `swagger.YAML`.
To add new api, the YAML file needs to be updated with all the desired apis using the [Swagger Basic Structure](https://swagger.io/docs/specification/2-0/basic-structure/), this includes paths, parameters, definitions, tags, etc.
To add new api, the YAML file needs to be updated with all the desired apis using
the [Swagger Basic Structure](https://swagger.io/docs/specification/2-0/basic-structure/), this includes paths,
parameters, definitions, tags, etc.
## Generate server from YAML
Once the YAML file is ready we can autogenerate the code needed for the new api by just running:
Validate it:
```
swagger validate ./swagger.yml
```
Update server code:
```
make swagger-gen
```
This will update all the necessary code.
`./restapi/configure_console.go` is a file that contains the handlers to be used by the application, here is the only place where we need to update our code to support the new apis. This file is not affected when running the swagger generator and it is safe to edit.
`./api/configure_console.go` is a file that contains the handlers to be used by the application, here is the only place
where we need to update our code to support the new apis. This file is not affected when running the swagger generator
and it is safe to edit.
## Unit Tests
`./restapi/handlers_test.go` needs to be updated with the proper tests for the new api.
`./api/handlers_test.go` needs to be updated with the proper tests for the new api.
To run tests:
```
go test ./restapi
go test ./api
```
## Commit changes
After verification, commit your changes. This is a [great post](https://chris.beams.io/posts/git-commit/) on how to write useful commit messages
After verification, commit your changes. This is a [great post](https://chris.beams.io/posts/git-commit/) on how to
write useful commit messages
```
$ git commit -am 'Add some feature'
```
### Push to the branch
Push your locally committed changes to the remote origin (your fork)
```
$ git push origin my-new-feature
```
### Create a Pull Request
Pull requests can be created via GitHub. Refer to [this document](https://help.github.com/articles/creating-a-pull-request/) for detailed steps on how to create a pull request. After a Pull Request gets peer reviewed and approved, it will be merged.
Pull requests can be created via GitHub. Refer
to [this document](https://help.github.com/articles/creating-a-pull-request/) for detailed steps on how to create a pull
request. After a Pull Request gets peer reviewed and approved, it will be merged.
## FAQs
### How does ``console`` manages dependencies?
``MinIO`` uses `go mod` to manage its dependencies.
- Run `go get foo/bar` in the source folder to add the dependency to `go.mod` file.
To remove a dependency
- Edit your code and remove the import reference.
- Run `go mod tidy` in the source folder to remove dependency from `go.mod` file.
### What are the coding guidelines for console?
``console`` is fully conformant with Golang style. Refer: [Effective Go](https://github.com/golang/go/wiki/CodeReviewComments) article from Golang project. If you observe offending code, please feel free to send a pull request or ping us on [Slack](https://slack.min.io).
``console`` is fully conformant with Golang style.
Refer: [Effective Go](https://github.com/golang/go/wiki/CodeReviewComments) article from Golang project. If you observe
offending code, please feel free to send a pull request or ping us on [Slack](https://slack.min.io).

21235
CREDITS

File diff suppressed because it is too large Load Diff

View File

@@ -1,3 +1,82 @@
# Developing MinIO Console
The MinIO Console requires the [MinIO Server](https://github.com/minio/minio). For development purposes, you also need
to run both the MinIO Console web app and the MinIO Console server.
## Running MinIO Console server
Build the server in the main folder by running:
```
make
```
> Note: If it's the first time running the server, you might need to run `go mod tidy` to ensure you have all modules
> required.
> To start the server run:
```
CONSOLE_ACCESS_KEY=<your-access-key>
CONSOLE_SECRET_KEY=<your-secret-key>
CONSOLE_MINIO_SERVER=<minio-server-endpoint>
CONSOLE_DEV_MODE=on
./console server
```
## Running MinIO Console web app
Refer to `/web-app` [instructions](/web-app/README.md) to run the web app locally.
# Building with MinIO
To test console in its shipping format, you need to build it from the MinIO repository, the following step will guide
you to do that.
### 0. Building with UI Changes
If you are performing changes in the UI components of console and want to test inside the MinIO binary, you need to
build assets first.
In the console folder run
```shell
make assets
```
This will regenerate all the static assets that will be served by MinIO.
### 1. Clone the `MinIO` repository
In the parent folder of where you cloned this `console` repository, clone the MinIO Repository
```shell
git clone https://github.com/minio/minio.git
```
### 2. Update `go.mod` to use your local version
In the MinIO repository open `go.mod` and after the first `require()` directive add a `replace()` directive
```
...
)
replace (
github.com/minio/console => "../console"
)
require (
...
```
### 3. Build `MinIO`
Still in the MinIO folder, run
```shell
make build
```
# LDAP authentication with Console
## Setup
@@ -15,7 +94,8 @@ $ docker cp console/docs/ldap/billy.ldif my-openldap-container:/container/servic
$ docker exec my-openldap-container ldapadd -x -D "cn=admin,dc=example,dc=org" -w admin -f /container/service/slapd/assets/test/billy.ldif -H ldap://localhost
```
Query the ldap server to check the user billy was created correctly and got assigned to the consoleAdmin group, you should get a list
Query the ldap server to check the user billy was created correctly and got assigned to the consoleAdmin group, you
should get a list
containing ldap users and groups.
```
@@ -30,7 +110,7 @@ $ docker exec my-openldap-container ldapsearch -x -H ldap://localhost -b uid=bil
### Change the password for user billy
Set the new password for `billy` to `minio123` and enter `admin` as the default `LDAP Password`
Set the new password for `billy` to `minio123` and enter `admin` as the default `LDAP Password`
```
$ docker exec -it my-openldap-container /bin/bash
@@ -41,6 +121,7 @@ Enter LDAP Password:
```
### Add the consoleAdmin policy to user billy on MinIO
```
$ cat > consoleAdmin.json << EOF
{
@@ -66,8 +147,8 @@ $ cat > consoleAdmin.json << EOF
]
}
EOF
$ mc admin policy add myminio consoleAdmin consoleAdmin.json
$ mc admin policy set myminio consoleAdmin user="uid=billy,dc=example,dc=org"
$ mc admin policy create myminio consoleAdmin consoleAdmin.json
$ mc admin policy attach myminio consoleAdmin --user="uid=billy,dc=example,dc=org"
```
## Run MinIO

View File

@@ -1,42 +0,0 @@
FROM node:14 as uilayer
WORKDIR /app
COPY ./portal-ui/package.json ./
COPY ./portal-ui/yarn.lock ./
RUN yarn install
COPY ./portal-ui .
RUN make build-static
USER node
FROM golang:1.16 as golayer
RUN apt-get update -y && apt-get install -y ca-certificates
ADD go.mod /go/src/github.com/minio/console/go.mod
ADD go.sum /go/src/github.com/minio/console/go.sum
WORKDIR /go/src/github.com/minio/console/
# Get dependencies - will also be cached if we won't change mod/sum
RUN go mod download
ADD . /go/src/github.com/minio/console/
WORKDIR /go/src/github.com/minio/console/
ENV CGO_ENABLED=0
COPY --from=uilayer /app/build /go/src/github.com/minio/console/portal-ui/build
RUN go build -ldflags "-w -s" -a -o console ./cmd/console
FROM registry.access.redhat.com/ubi8/ubi-minimal:8.3
MAINTAINER MinIO Development "dev@min.io"
EXPOSE 9090
COPY --from=golayer /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=golayer /go/src/github.com/minio/console/console .
ENTRYPOINT ["/console"]

View File

@@ -1,13 +0,0 @@
FROM node:14 as uilayer
WORKDIR /app
COPY ./portal-ui/package.json ./
COPY ./portal-ui/yarn.lock ./
RUN yarn install
COPY ./portal-ui .
RUN yarn install && make build-static
USER node

View File

@@ -1,23 +0,0 @@
FROM registry.access.redhat.com/ubi8/ubi-minimal:8.4
ARG TAG
COPY CREDITS /licenses/CREDITS
COPY LICENSE /licenses/LICENSE
LABEL name="MinIO" \
vendor="MinIO Inc <dev@min.io>" \
maintainer="MinIO Inc <dev@min.io>" \
version="${TAG}" \
release="${TAG}" \
summary="A graphical user interface for MinIO" \
description="MinIO object storage is fundamentally different. Designed for performance and the S3 API, it is 100% open-source. MinIO is ideal for large, private cloud environments with stringent security requirements and delivers mission-critical availability across a diverse range of workloads."
RUN \
microdnf update --nodocs && \
microdnf install ca-certificates --nodocs
EXPOSE 9090
COPY console /console
ENTRYPOINT ["/console"]

255
Makefile
View File

@@ -4,6 +4,9 @@ GOPATH := $(shell go env GOPATH)
BUILD_VERSION:=$(shell git describe --exact-match --tags $(git log -n1 --pretty='%h') 2>/dev/null || git rev-parse --abbrev-ref HEAD 2>/dev/null)
BUILD_TIME:=$(shell date 2>/dev/null)
TAG ?= "minio/console:$(BUILD_VERSION)-dev"
MINIO_VERSION ?= "quay.io/minio/minio:latest"
TARGET_BUCKET ?= "target"
NODE_VERSION := $(shell cat .nvmrc)
default: console
@@ -12,23 +15,15 @@ console:
@echo "Building Console binary to './console'"
@(GO111MODULE=on CGO_ENABLED=0 go build -trimpath --tags=kqueue --ldflags "-s -w" -o console ./cmd/console)
k8sdev:
@docker build -t $(TAG) --build-arg build_version=$(BUILD_VERSION) --build-arg build_time='$(BUILD_TIME)' .
@kind load docker-image $(TAG)
@echo "Done, now restart your console deployment"
getdeps:
@mkdir -p ${GOPATH}/bin
@which golangci-lint 1>/dev/null || (echo "Installing golangci-lint" && curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(GOPATH)/bin v1.40.1)
@echo "Installing golangci-lint" && curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(GOPATH)/bin
verifiers: getdeps fmt lint
fmt:
@echo "Running $@ check"
@GO111MODULE=on gofmt -d restapi/
@GO111MODULE=on gofmt -d pkg/
@GO111MODULE=on gofmt -d cmd/
@GO111MODULE=on gofmt -d cluster/
@(env bash $(PWD)/verify-gofmt.sh)
crosscompile:
@(env bash $(PWD)/cross-compile.sh $(arg1))
@@ -38,44 +33,248 @@ lint:
@GO111MODULE=on ${GOPATH}/bin/golangci-lint cache clean
@GO111MODULE=on ${GOPATH}/bin/golangci-lint run --timeout=5m --config ./.golangci.yml
lint-fix: getdeps ## runs golangci-lint suite of linters with automatic fixes
@echo "Running $@ check"
@GO111MODULE=on ${GOPATH}/bin/golangci-lint run --timeout=5m --config ./.golangci.yml --fix
install: console
@echo "Installing console binary to '$(GOPATH)/bin/console'"
@mkdir -p $(GOPATH)/bin && cp -f $(PWD)/console $(GOPATH)/bin/console
@echo "Installation successful. To learn more, try \"console --help\"."
swagger-gen: clean-swagger swagger-console swagger-operator
swagger-gen: clean-swagger swagger-console apply-gofmt
@echo "Done Generating swagger server code from yaml"
apply-gofmt:
@echo "Applying gofmt to all generated an existing files"
@GO111MODULE=on gofmt -w .
clean-swagger:
@echo "cleaning"
@rm -rf models
@rm -rf restapi/operations
@rm -rf operatorapi/operations
@rm -rf api/operations
swagger-console:
@echo "Generating swagger server code from yaml"
@swagger generate server -A console --main-package=management --server-package=restapi --exclude-main -P models.Principal -f ./swagger-console.yml -r NOTICE
@swagger generate server -A console --main-package=management --server-package=api --exclude-main -P models.Principal -f ./swagger.yml -r NOTICE
@echo "Generating typescript api"
@npx swagger-typescript-api -p ./swagger.yml -o ./web-app/src/api -n consoleApi.ts --custom-config generator.config.js
@git restore api/server.go
swagger-operator:
@echo "Generating swagger server code from yaml"
@swagger generate server -A operator --main-package=operator --server-package=operatorapi --exclude-main -P models.Principal -f ./swagger-operator.yml -r NOTICE
assets:
@(cd portal-ui; yarn install; make build-static; yarn prettier --write . --loglevel warn; cd ..)
@(if [ -f "${NVM_DIR}/nvm.sh" ]; then \. "${NVM_DIR}/nvm.sh" && nvm install && nvm use && npm install -g yarn ; fi &&\
cd web-app; corepack enable; yarn install --prefer-offline; make build-static; yarn prettier --write . --loglevel warn; cd ..)
test-integration:
@(docker run -d --name minio --rm -p 9000:9000 quay.io/minio/minio:latest server /data{1...4} && sleep 5)
@(GO111MODULE=on go test -race -v github.com/minio/console/integration/...)
@(docker stop pgsqlcontainer || true)
@(docker stop minio || true)
@(docker stop minio2 || true)
@(docker network rm mynet123 || true)
@echo "create docker network to communicate containers MinIO & PostgreSQL"
@(docker network create --subnet=173.18.0.0/29 mynet123)
@echo "docker run with MinIO Version below:"
@echo $(MINIO_VERSION)
@echo "MinIO 1"
@(docker run -v /data1 -v /data2 -v /data3 -v /data4 --net=mynet123 -d --name minio --rm -p 9000:9000 -p 9091:9091 -e MINIO_KMS_SECRET_KEY=my-minio-key:OSMM+vkKUTCvQs9YL/CVMIMt43HFhkUpqJxTmGl6rYw= $(MINIO_VERSION) server /data{1...4} --console-address ':9091' && sleep 5)
@echo "MinIO 2"
@(docker run -v /data1 -v /data2 -v /data3 -v /data4 --net=mynet123 -d --name minio2 --rm -p 9001:9001 -p 9092:9092 -e MINIO_KMS_SECRET_KEY=my-minio-key:OSMM+vkKUTCvQs9YL/CVMIMt43HFhkUpqJxTmGl6rYw= $(MINIO_VERSION) server /data{1...4} --address ':9001' --console-address ':9092' && sleep 5)
@echo "Postgres"
@(docker run --net=mynet123 --ip=173.18.0.4 --name pgsqlcontainer --rm -p 5432:5432 -e POSTGRES_PASSWORD=password -d postgres && sleep 5)
@echo "execute test and get coverage for test-integration:"
@(cd integration && go test -coverpkg=../api -c -tags testrunmain . && mkdir -p coverage && ./integration.test -test.v -test.run "^Test*" -test.coverprofile=coverage/system.out)
@(docker stop pgsqlcontainer)
@(docker stop minio)
@(docker stop minio2)
@(docker network rm mynet123)
test-replication:
@(docker stop minio || true)
@(docker stop minio1 || true)
@(docker stop minio2 || true)
@(docker network rm mynet123 || true)
@(docker network create mynet123)
@(docker run -v /data1 -v /data2 -v /data3 -v /data4 \
--net=mynet123 -d \
--name minio \
--rm \
-p 9000:9000 \
-p 6000:6000 \
-e MINIO_KMS_SECRET_KEY=my-minio-key:OSMM+vkKUTCvQs9YL/CVMIMt43HFhkUpqJxTmGl6rYw= \
-e MINIO_ROOT_USER="minioadmin" \
-e MINIO_ROOT_PASSWORD="minioadmin" \
$(MINIO_VERSION) server /data{1...4} \
--address :9000 \
--console-address :6000)
@(docker run -v /data1 -v /data2 -v /data3 -v /data4 \
--net=mynet123 -d \
--name minio1 \
--rm \
-p 9001:9001 \
-p 6001:6001 \
-e MINIO_KMS_SECRET_KEY=my-minio-key:OSMM+vkKUTCvQs9YL/CVMIMt43HFhkUpqJxTmGl6rYw= \
-e MINIO_ROOT_USER="minioadmin" \
-e MINIO_ROOT_PASSWORD="minioadmin" \
$(MINIO_VERSION) server /data{1...4} \
--address :9001 \
--console-address :6001)
@(docker run -v /data1 -v /data2 -v /data3 -v /data4 \
--net=mynet123 -d \
--name minio2 \
--rm \
-p 9002:9002 \
-p 6002:6002 \
-e MINIO_KMS_SECRET_KEY=my-minio-key:OSMM+vkKUTCvQs9YL/CVMIMt43HFhkUpqJxTmGl6rYw= \
-e MINIO_ROOT_USER="minioadmin" \
-e MINIO_ROOT_PASSWORD="minioadmin" \
$(MINIO_VERSION) server /data{1...4} \
--address :9002 \
--console-address :6002)
@(cd replication && go test -coverpkg=../api -c -tags testrunmain . && mkdir -p coverage && ./replication.test -test.v -test.run "^Test*" -test.coverprofile=coverage/replication.out)
@(docker stop minio || true)
@(docker stop minio1 || true)
@(docker stop minio2 || true)
@(docker network rm mynet123 || true)
test-sso-integration:
@echo "create the network in bridge mode to communicate all containers"
@(docker network create my-net)
@echo "run openldap container using MinIO Image: quay.io/minio/openldap:latest"
@(docker run \
-e LDAP_ORGANIZATION="MinIO Inc" \
-e LDAP_DOMAIN="min.io" \
-e LDAP_ADMIN_PASSWORD="admin" \
--network my-net \
-p 389:389 \
-p 636:636 \
--name openldap \
--detach quay.io/minio/openldap:latest)
@echo "Run Dex container using MinIO Image: quay.io/minio/dex:latest"
@(docker run \
-e DEX_ISSUER=http://dex:5556/dex \
-e DEX_CLIENT_REDIRECT_URI=http://127.0.0.1:9090/oauth_callback \
-e DEX_LDAP_SERVER=openldap:389 \
--network my-net \
-p 5556:5556 \
--name dex \
--detach quay.io/minio/dex:latest)
@echo "running minio server"
@(docker run \
-v /data1 -v /data2 -v /data3 -v /data4 \
--network my-net \
-d \
--name minio \
--rm \
-p 9000:9000 \
-p 9001:9001 \
-e MINIO_IDENTITY_OPENID_CLIENT_ID="minio-client-app" \
-e MINIO_IDENTITY_OPENID_CLIENT_SECRET="minio-client-app-secret" \
-e MINIO_IDENTITY_OPENID_CLAIM_NAME=name \
-e MINIO_IDENTITY_OPENID_CONFIG_URL=http://dex:5556/dex/.well-known/openid-configuration \
-e MINIO_IDENTITY_OPENID_REDIRECT_URI=http://127.0.0.1:9090/oauth_callback \
-e MINIO_ROOT_USER=minio \
-e MINIO_ROOT_PASSWORD=minio123 $(MINIO_VERSION) server /data{1...4} --address :9000 --console-address :9001)
@echo "run mc commands to set the policy"
@(docker run --name minio-client --network my-net -dit --entrypoint=/bin/sh minio/mc)
@(docker exec minio-client mc alias set myminio/ http://minio:9000 minio minio123)
@echo "adding policy to Dillon Harper to be able to login:"
@(cd sso-integration && docker cp allaccess.json minio-client:/ && docker exec minio-client mc admin policy create myminio "Dillon Harper" allaccess.json)
@echo "starting bash script"
@(env bash $(PWD)/sso-integration/set-sso.sh)
@echo "add python module"
@(pip3 install bs4)
@echo "Executing the test:"
@(cd sso-integration && go test -coverpkg=../api -c -tags testrunmain . && mkdir -p coverage && ./sso-integration.test -test.v -test.run "^Test*" -test.coverprofile=coverage/sso-system.out)
test-permissions-1:
@(docker run -v /data1 -v /data2 -v /data3 -v /data4 -d --name minio --rm -p 9000:9000 quay.io/minio/minio:latest server /data{1...4})
@(env bash $(PWD)/web-app/tests/scripts/permissions.sh "web-app/tests/permissions-1/")
@(docker stop minio)
test:
@(GO111MODULE=on go test -race -v github.com/minio/console/restapi/...)
test-permissions-2:
@(docker run -v /data1 -v /data2 -v /data3 -v /data4 -d --name minio --rm -p 9000:9000 quay.io/minio/minio:latest server /data{1...4})
@(env bash $(PWD)/web-app/tests/scripts/permissions.sh "web-app/tests/permissions-2/")
@(docker stop minio)
test-permissions-3:
@(docker run -v /data1 -v /data2 -v /data3 -v /data4 -d --name minio --rm -p 9000:9000 quay.io/minio/minio:latest server /data{1...4})
@(env bash $(PWD)/web-app/tests/scripts/permissions.sh "web-app/tests/permissions-3/")
@(docker stop minio)
test-permissions-4:
@(docker run -v /data1 -v /data2 -v /data3 -v /data4 -d --name minio --rm -p 9000:9000 quay.io/minio/minio:latest server /data{1...4})
@(env bash $(PWD)/web-app/tests/scripts/permissions.sh "web-app/tests/permissions-4/")
@(docker stop minio)
test-permissions-5:
@(docker run -v /data1 -v /data2 -v /data3 -v /data4 -d --name minio --rm -p 9000:9000 quay.io/minio/minio:latest server /data{1...4})
@(env bash $(PWD)/web-app/tests/scripts/permissions.sh "web-app/tests/permissions-5/")
@(docker stop minio)
test-permissions-6:
@(docker run -v /data1 -v /data2 -v /data3 -v /data4 -d --name minio --rm -p 9000:9000 quay.io/minio/minio:latest server /data{1...4})
@(env bash $(PWD)/web-app/tests/scripts/permissions.sh "web-app/tests/permissions-6/")
@(docker stop minio)
test-permissions-7:
@(docker run -v /data1 -v /data2 -v /data3 -v /data4 -d --name minio --rm -p 9000:9000 quay.io/minio/minio:latest server /data{1...4})
@(env bash $(PWD)/web-app/tests/scripts/permissions.sh "web-app/tests/permissions-7/")
@(docker stop minio)
test-apply-permissions:
@(env bash $(PWD)/web-app/tests/scripts/initialize-env.sh)
test-start-docker-minio:
@(docker run -v /data1 -v /data2 -v /data3 -v /data4 -d --name minio --rm -p 9000:9000 quay.io/minio/minio:latest server /data{1...4})
initialize-permissions: test-start-docker-minio test-apply-permissions
@echo "Done initializing permissions test"
cleanup-permissions:
@(env bash $(PWD)/web-app/tests/scripts/cleanup-env.sh)
@(docker stop minio)
initialize-docker-network:
@(docker network create test-network)
test-start-docker-minio-w-redirect-url: initialize-docker-network
@(docker run \
-e MINIO_BROWSER_REDIRECT_URL='http://localhost:8000/console/subpath/' \
-e MINIO_SERVER_URL='http://localhost:9000' \
-v /data1 -v /data2 -v /data3 -v /data4 \
-d --network host --name minio --rm\
quay.io/minio/minio:latest server /data{1...4})
test-start-docker-nginx-w-subpath:
@(docker run \
--network host \
-d --rm \
--add-host=host.docker.internal:host-gateway \
-v ./web-app/tests/subpath-nginx/nginx.conf:/etc/nginx/nginx.conf \
--name test-nginx nginx)
test-initialize-minio-nginx: test-start-docker-minio-w-redirect-url test-start-docker-nginx-w-subpath
cleanup-minio-nginx:
@(docker stop minio test-nginx & docker network rm test-network)
# https://stackoverflow.com/questions/19200235/golang-tests-in-sub-directory
# Note: go test ./... will run tests on the current folder and all subfolders.
# This is needed because tests can be in the folder or sub-folder(s), let's include them all please!.
test:
@echo "execute test and get coverage"
@(cd api && mkdir -p coverage && GO111MODULE=on go test ./... -test.v -coverprofile=coverage/coverage.out)
# https://stackoverflow.com/questions/19200235/golang-tests-in-sub-directory
# Note: go test ./... will run tests on the current folder and all subfolders.
# This is since tests in pkg folder are in subfolders and were not executed.
test-pkg:
@(GO111MODULE=on go test -race -v github.com/minio/console/pkg/...)
@echo "execute test and get coverage"
@(cd pkg && mkdir -p coverage && GO111MODULE=on go test ./... -test.v -coverprofile=coverage/coverage-pkg.out)
coverage:
@(GO111MODULE=on go test -v -coverprofile=coverage.out github.com/minio/console/restapi/... && go tool cover -html=coverage.out && open coverage.html)
@(GO111MODULE=on go test -v -coverprofile=coverage.out github.com/minio/console/api/... && go tool cover -html=coverage.out && open coverage.html)
clean:
@echo "Cleaning up all the generated files"
@@ -84,4 +283,10 @@ clean:
@rm -vf console
docker:
@docker buildx build --output=type=docker --platform linux/amd64 -t $(TAG) --build-arg build_version=$(BUILD_VERSION) --build-arg build_time='$(BUILD_TIME)' .
@docker buildx build --output=type=docker --platform linux/amd64 -t $(TAG) --build-arg build_version=$(BUILD_VERSION) --build-arg build_time='$(BUILD_TIME)' --build-arg NODE_VERSION='$(NODE_VERSION)' .
release: swagger-gen
@echo "Generating Release: $(RELEASE)"
@make assets
@git add -u .
@git add web-app/build/

2
NOTICE
View File

@@ -1,5 +1,5 @@
This file is part of MinIO Console Server
Copyright (c) 2021 MinIO, Inc.
Copyright (c) 2023 MinIO, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by

136
README.md
View File

@@ -4,57 +4,38 @@
A graphical user interface for [MinIO](https://github.com/minio/minio)
| Dashboard | Creating a bucket |
| ------------- | ------------- |
| ![Dashboard](images/pic1.png) | ![Dashboard](images/pic2.png) |
| Object Browser | Dashboard | Creating a bucket |
|------------------------------------|-------------------------------|-------------------------------|
| ![Object Browser](images/pic3.png) | ![Dashboard](images/pic1.png) | ![Dashboard](images/pic2.png) |
<!-- markdown-toc start - Don't edit this section. Run M-x markdown-toc-refresh-toc -->
**Table of Contents**
- [MinIO Console](#minio-console)
- [Install](#install)
- [Binary Releases](#binary-releases)
- [Docker](#docker)
- [Build from source](#build-from-source)
- [Setup](#setup)
- [1. Create a user `console` using `mc`](#1-create-a-user-console-using-mc)
- [2. Create a policy for `console` with admin access to all resources (for testing)](#2-create-a-policy-for-console-with-admin-access-to-all-resources-for-testing)
- [3. Set the policy for the new `console` user](#3-set-the-policy-for-the-new-console-user)
- [Start Console service:](#start-console-service)
- [Start Console service with TLS:](#start-console-service-with-tls)
- [Connect Console to a Minio using TLS and a self-signed certificate](#connect-console-to-a-minio-using-tls-and-a-self-signed-certificate)
- [Install](#install)
- [Build from source](#build-from-source)
- [Setup](#setup)
- [1. Create a user `console` using `mc`](#1-create-a-user-console-using-mc)
- [2. Create a policy for `console` with admin access to all resources (for testing)](#2-create-a-policy-for-console-with-admin-access-to-all-resources-for-testing)
- [3. Set the policy for the new `console` user](#3-set-the-policy-for-the-new-console-user)
- [Start Console service:](#start-console-service)
- [Start Console service with TLS:](#start-console-service-with-tls)
- [Connect Console to a Minio using TLS and a self-signed certificate](#connect-console-to-a-minio-using-tls-and-a-self-signed-certificate)
- [Contribute to console Project](#contribute-to-console-project)
<!-- markdown-toc end -->
## Install
### Binary Releases
MinIO Console is a library that provides a management and browser UI overlay for the MinIO Server.
The standalone binary installation path has been removed.
| OS | ARCH | Binary |
|:-------:|:-------:|:----------------------------------------------------------------------------------------------------:|
| Linux | amd64 | [linux-amd64](https://github.com/minio/console/releases/latest/download/console-linux-amd64) |
| Linux | arm64 | [linux-arm64](https://github.com/minio/console/releases/latest/download/console-linux-arm64) |
| Linux | ppc64le | [linux-ppc64le](https://github.com/minio/console/releases/latest/download/console-linux-ppc64le) |
| Linux | s390x | [linux-s390x](https://github.com/minio/console/releases/latest/download/console-linux-s390x) |
| Apple | amd64 | [darwin-amd64](https://github.com/minio/console/releases/latest/download/console-darwin-amd64) |
| Windows | amd64 | [windows-amd64](https://github.com/minio/console/releases/latest/download/console-windows-amd64.exe) |
You can also verify the binary with [minisign](https://jedisct1.github.io/minisign/) by downloading the corresponding [`.minisig`](https://github.com/minio/console/releases/latest) signature file. Then run:
```
minisign -Vm console-<OS>-<ARCH> -P RWTx5Zr1tiHQLwG9keckT0c45M3AGeHD6IvimQHpyRywVWGbP1aVSGav
```
### Docker
Pull the latest release via:
```
docker pull minio/console
```
In case a Console standalone binary is needed, it can be generated by building this package from source as follows:
### Build from source
> You will need a working Go environment. Therefore, please follow [How to install Go](https://golang.org/doc/install).
> Minimum version required is go1.17
> Minimum version required is go1.22
```
go install github.com/minio/console/cmd/console@latest
@@ -103,60 +84,64 @@ EOF
```
```sh
mc admin policy add myminio/ consoleAdmin admin.json
mc admin policy create myminio/ consoleAdmin admin.json
```
### 3. Set the policy for the new `console` user
```sh
mc admin policy set myminio consoleAdmin user=console
mc admin policy attach myminio consoleAdmin --user=console
```
> NOTE: Additionally, you can create policies to limit the privileges for other `console` users, for example, if you want the user to only have access to dashboard, buckets, notifications and watch page, the policy should look like this:
> NOTE: Additionally, you can create policies to limit the privileges for other `console` users, for example, if you
> want the user to only have access to dashboard, buckets, notifications and watch page, the policy should look like
> this:
```json
{
"Version": "2012-10-17",
"Statement": [{
"Action": [
"admin:ServerInfo"
],
"Effect": "Allow",
"Sid": ""
},
{
"Action": [
"s3:ListenBucketNotification",
"s3:PutBucketNotification",
"s3:GetBucketNotification",
"s3:ListMultipartUploadParts",
"s3:ListBucketMultipartUploads",
"s3:ListBucket",
"s3:HeadBucket",
"s3:GetObject",
"s3:GetBucketLocation",
"s3:AbortMultipartUpload",
"s3:CreateBucket",
"s3:PutObject",
"s3:DeleteObject",
"s3:DeleteBucket",
"s3:PutBucketPolicy",
"s3:DeleteBucketPolicy",
"s3:GetBucketPolicy"
],
"Effect": "Allow",
"Resource": [
"arn:aws:s3:::*"
],
"Sid": ""
}
]
"Version": "2012-10-17",
"Statement": [
{
"Action": [
"admin:ServerInfo"
],
"Effect": "Allow",
"Sid": ""
},
{
"Action": [
"s3:ListenBucketNotification",
"s3:PutBucketNotification",
"s3:GetBucketNotification",
"s3:ListMultipartUploadParts",
"s3:ListBucketMultipartUploads",
"s3:ListBucket",
"s3:HeadBucket",
"s3:GetObject",
"s3:GetBucketLocation",
"s3:AbortMultipartUpload",
"s3:CreateBucket",
"s3:PutObject",
"s3:DeleteObject",
"s3:DeleteBucket",
"s3:PutBucketPolicy",
"s3:DeleteBucketPolicy",
"s3:GetBucketPolicy"
],
"Effect": "Allow",
"Resource": [
"arn:aws:s3:::*"
],
"Sid": ""
}
]
}
```
## Start Console service:
Before running console service, following environment settings must be supplied
```sh
# Salt to encrypt JWT payload
export CONSOLE_PBKDF_PASSPHRASE=SECRET
@@ -169,6 +154,7 @@ export CONSOLE_MINIO_SERVER=http://localhost:9000
```
Now start the console service.
```
./console server
2021-01-19 02:36:08.893735 I | 2021/01/19 02:36:08 server.go:129: Serving console at http://localhost:9090
@@ -189,6 +175,7 @@ Copy your `public.crt` and `private.key` to `~/.console/certs`, then:
For advanced users, `console` has support for multiple certificates to service clients through multiple domains.
Following tree structure is expected for supporting multiple domains:
```sh
certs/
@@ -219,4 +206,5 @@ export CONSOLE_MINIO_SERVER=https://localhost:9000
You can verify that the apis work by doing the request on `localhost:9090/api/v1/...`
# Contribute to console Project
Please follow console [Contributor's Guide](https://github.com/minio/console/blob/master/CONTRIBUTING.md)

View File

@@ -18,9 +18,10 @@ you need access credentials for a successful exploit).
If you have not received a reply to your email within 48 hours or you have not heard from the security team
for the past five days please contact the security team directly:
- Primary security coordinator: lenin@min.io
- Secondary coordinator: security@min.io
- If you receive no response: dev@min.io
- Primary security coordinator: daniel@min.io
- Secondary coordinator: security@min.io
- If you receive no response: dev@min.io
### Disclosure Process

70
api/admin_arns.go Normal file
View File

@@ -0,0 +1,70 @@
// This file is part of MinIO Console Server
// Copyright (c) 2021 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package api
import (
"context"
systemApi "github.com/minio/console/api/operations/system"
"github.com/go-openapi/runtime/middleware"
"github.com/minio/console/api/operations"
"github.com/minio/console/models"
)
func registerAdminArnsHandlers(api *operations.ConsoleAPI) {
// return a list of arns
api.SystemArnListHandler = systemApi.ArnListHandlerFunc(func(params systemApi.ArnListParams, session *models.Principal) middleware.Responder {
arnsResp, err := getArnsResponse(session, params)
if err != nil {
return systemApi.NewArnListDefault(err.Code).WithPayload(err.APIError)
}
return systemApi.NewArnListOK().WithPayload(arnsResp)
})
}
// getArns invokes admin info and returns a list of arns
func getArns(ctx context.Context, client MinioAdmin) (*models.ArnsResponse, error) {
serverInfo, err := client.serverInfo(ctx)
if err != nil {
return nil, err
}
// build response
return &models.ArnsResponse{
Arns: serverInfo.SQSARN,
}, nil
}
// getArnsResponse returns a list of active arns in the instance
func getArnsResponse(session *models.Principal, params systemApi.ArnListParams) (*models.ArnsResponse, *CodedAPIError) {
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
defer cancel()
mAdmin, err := NewMinioAdminClient(params.HTTPRequest.Context(), session)
if err != nil {
return nil, ErrorWithContext(ctx, err)
}
// create a minioClient interface implementation
// defining the client to be used
adminClient := AdminClient{Client: mAdmin}
// serialize output
arnsList, err := getArns(ctx, adminClient)
if err != nil {
return nil, ErrorWithContext(ctx, err)
}
return arnsList, nil
}

97
api/admin_arns_test.go Normal file
View File

@@ -0,0 +1,97 @@
// This file is part of MinIO Console Server
// Copyright (c) 2021 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package api
import (
"context"
"errors"
"fmt"
"net/http"
"strings"
"testing"
"github.com/go-openapi/runtime/middleware"
"github.com/minio/console/api/operations/system"
"github.com/minio/console/models"
"github.com/go-openapi/loads"
"github.com/minio/console/api/operations"
"github.com/minio/madmin-go/v3"
asrt "github.com/stretchr/testify/assert"
)
func TestArnsList(t *testing.T) {
assert := asrt.New(t)
adminClient := AdminClientMock{}
// Test-1 : getArns() returns proper arn list
MinioServerInfoMock = func(_ context.Context) (madmin.InfoMessage, error) {
return madmin.InfoMessage{
SQSARN: []string{"uno"},
}, nil
}
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
arnsList, err := getArns(ctx, adminClient)
assert.NotNil(arnsList, "arn list was returned nil")
if arnsList != nil {
assert.Equal(len(arnsList.Arns), 1, "Incorrect arns count")
}
assert.Nil(err, "Error should have been nil")
// Test-2 : getArns(ctx) fails for whatever reason
MinioServerInfoMock = func(_ context.Context) (madmin.InfoMessage, error) {
return madmin.InfoMessage{}, errors.New("some reason")
}
arnsList, err = getArns(ctx, adminClient)
assert.Nil(arnsList, "arn list was not returned nil")
assert.NotNil(err, "An error should have been returned")
}
func TestRegisterAdminArnsHandlers(t *testing.T) {
assert := asrt.New(t)
swaggerSpec, err := loads.Embedded(SwaggerJSON, FlatSwaggerJSON)
if err != nil {
assert.Fail("Error")
}
api := operations.NewConsoleAPI(swaggerSpec)
api.SystemArnListHandler = nil
registerAdminArnsHandlers(api)
if api.SystemArnListHandler == nil {
assert.Fail("Assignment should happen")
} else {
fmt.Println("Function got assigned: ", api.SystemArnListHandler)
}
// To test error case in registerAdminArnsHandlers
request, _ := http.NewRequest(
"GET",
"http://localhost:9090/api/v1/buckets/",
nil,
)
ArnListParamsStruct := system.ArnListParams{
HTTPRequest: request,
}
modelsPrincipal := models.Principal{
STSAccessKeyID: "accesskey",
}
var value middleware.Responder = api.SystemArnListHandler.Handle(ArnListParamsStruct, &modelsPrincipal)
str := fmt.Sprintf("%#v", value)
fmt.Println("value: ", str)
assert.Equal(strings.Contains(str, "_statusCode:500"), true)
}

355
api/admin_client_mock.go Normal file
View File

@@ -0,0 +1,355 @@
// This file is part of MinIO Console Server
// Copyright (c) 2023 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package api
import (
"context"
"io"
"time"
"github.com/minio/madmin-go/v3"
iampolicy "github.com/minio/pkg/v3/policy"
)
type AdminClientMock struct{}
var (
MinioServerInfoMock func(ctx context.Context) (madmin.InfoMessage, error)
minioChangePasswordMock func(ctx context.Context, accessKey, secretKey string) error
minioHelpConfigKVMock func(subSys, key string, envOnly bool) (madmin.Help, error)
minioGetConfigKVMock func(key string) ([]byte, error)
minioSetConfigKVMock func(kv string) (restart bool, err error)
minioDelConfigKVMock func(name string) (err error)
minioHelpConfigKVGlobalMock func(envOnly bool) (madmin.Help, error)
minioGetLogsMock func(ctx context.Context, node string, lineCnt int, logKind string) <-chan madmin.LogInfo
minioListGroupsMock func() ([]string, error)
minioUpdateGroupMembersMock func(madmin.GroupAddRemove) error
minioGetGroupDescriptionMock func(group string) (*madmin.GroupDesc, error)
minioSetGroupStatusMock func(group string, status madmin.GroupStatus) error
minioHealMock func(ctx context.Context, bucket, prefix string, healOpts madmin.HealOpts, clientToken string,
forceStart, forceStop bool) (healStart madmin.HealStartSuccess, healTaskStatus madmin.HealTaskStatus, err error)
minioServerHealthInfoMock func(ctx context.Context, deadline time.Duration) (interface{}, string, error)
minioListPoliciesMock func() (map[string]*iampolicy.Policy, error)
minioGetPolicyMock func(name string) (*iampolicy.Policy, error)
minioRemovePolicyMock func(name string) error
minioAddPolicyMock func(name string, policy *iampolicy.Policy) error
minioSetPolicyMock func(policyName, entityName string, isGroup bool) error
minioStartProfiling func(profiler madmin.ProfilerType) ([]madmin.StartProfilingResult, error)
minioStopProfiling func() (io.ReadCloser, error)
minioServiceRestartMock func(ctx context.Context) error
getSiteReplicationInfo func(ctx context.Context) (*madmin.SiteReplicationInfo, error)
addSiteReplicationInfo func(ctx context.Context, sites []madmin.PeerSite) (*madmin.ReplicateAddStatus, error)
editSiteReplicationInfo func(ctx context.Context, site madmin.PeerInfo) (*madmin.ReplicateEditStatus, error)
deleteSiteReplicationInfoMock func(ctx context.Context, removeReq madmin.SRRemoveReq) (*madmin.ReplicateRemoveStatus, error)
getSiteReplicationStatus func(ctx context.Context, params madmin.SRStatusOptions) (*madmin.SRStatusInfo, error)
minioListTiersMock func(ctx context.Context) ([]*madmin.TierConfig, error)
minioTierStatsMock func(ctx context.Context) ([]madmin.TierInfo, error)
minioAddTiersMock func(ctx context.Context, tier *madmin.TierConfig) error
minioRemoveTierMock func(ctx context.Context, tierName string) error
minioEditTiersMock func(ctx context.Context, tierName string, creds madmin.TierCreds) error
minioVerifyTierStatusMock func(ctx context.Context, tierName string) error
minioServiceTraceMock func(ctx context.Context, threshold int64, s3, internal, storage, os, errTrace bool) <-chan madmin.ServiceTraceInfo
minioListUsersMock func() (map[string]madmin.UserInfo, error)
minioAddUserMock func(accessKey, secreyKey string) error
minioRemoveUserMock func(accessKey string) error
minioGetUserInfoMock func(accessKey string) (madmin.UserInfo, error)
minioSetUserStatusMock func(accessKey string, status madmin.AccountStatus) error
minioAccountInfoMock func(ctx context.Context) (madmin.AccountInfo, error)
minioAddServiceAccountMock func(ctx context.Context, policy string, user string, accessKey string, secretKey string, description string, name string, expiry *time.Time, status string) (madmin.Credentials, error)
minioListServiceAccountsMock func(ctx context.Context, user string) (madmin.ListServiceAccountsResp, error)
minioDeleteServiceAccountMock func(ctx context.Context, serviceAccount string) error
minioInfoServiceAccountMock func(ctx context.Context, serviceAccount string) (madmin.InfoServiceAccountResp, error)
minioUpdateServiceAccountMock func(ctx context.Context, serviceAccount string, opts madmin.UpdateServiceAccountReq) error
minioGetLDAPPolicyEntitiesMock func(ctx context.Context, query madmin.PolicyEntitiesQuery) (madmin.PolicyEntitiesResult, error)
minioListRemoteBucketsMock func(ctx context.Context, bucket, arnType string) (targets []madmin.BucketTarget, err error)
minioGetRemoteBucketMock func(ctx context.Context, bucket, arnType string) (targets *madmin.BucketTarget, err error)
minioAddRemoteBucketMock func(ctx context.Context, bucket string, target *madmin.BucketTarget) (string, error)
)
func (ac AdminClientMock) serverInfo(ctx context.Context) (madmin.InfoMessage, error) {
return MinioServerInfoMock(ctx)
}
func (ac AdminClientMock) listRemoteBuckets(ctx context.Context, bucket, arnType string) (targets []madmin.BucketTarget, err error) {
return minioListRemoteBucketsMock(ctx, bucket, arnType)
}
func (ac AdminClientMock) getRemoteBucket(ctx context.Context, bucket, arnType string) (targets *madmin.BucketTarget, err error) {
return minioGetRemoteBucketMock(ctx, bucket, arnType)
}
func (ac AdminClientMock) removeRemoteBucket(_ context.Context, _, _ string) error {
return nil
}
func (ac AdminClientMock) addRemoteBucket(ctx context.Context, bucket string, target *madmin.BucketTarget) (string, error) {
return minioAddRemoteBucketMock(ctx, bucket, target)
}
func (ac AdminClientMock) changePassword(ctx context.Context, accessKey, secretKey string) error {
return minioChangePasswordMock(ctx, accessKey, secretKey)
}
func (ac AdminClientMock) speedtest(_ context.Context, _ madmin.SpeedtestOpts) (chan madmin.SpeedTestResult, error) {
return nil, nil
}
func (ac AdminClientMock) verifyTierStatus(ctx context.Context, tier string) error {
return minioVerifyTierStatusMock(ctx, tier)
}
// mock function helpConfigKV()
func (ac AdminClientMock) helpConfigKV(_ context.Context, subSys, key string, envOnly bool) (madmin.Help, error) {
return minioHelpConfigKVMock(subSys, key, envOnly)
}
// mock function getConfigKV()
func (ac AdminClientMock) getConfigKV(_ context.Context, name string) ([]byte, error) {
return minioGetConfigKVMock(name)
}
// mock function setConfigKV()
func (ac AdminClientMock) setConfigKV(_ context.Context, kv string) (restart bool, err error) {
return minioSetConfigKVMock(kv)
}
// mock function helpConfigKV()
func (ac AdminClientMock) helpConfigKVGlobal(_ context.Context, envOnly bool) (madmin.Help, error) {
return minioHelpConfigKVGlobalMock(envOnly)
}
func (ac AdminClientMock) delConfigKV(_ context.Context, name string) (err error) {
return minioDelConfigKVMock(name)
}
func (ac AdminClientMock) getLogs(ctx context.Context, node string, lineCnt int, logKind string) <-chan madmin.LogInfo {
return minioGetLogsMock(ctx, node, lineCnt, logKind)
}
func (ac AdminClientMock) listGroups(_ context.Context) ([]string, error) {
return minioListGroupsMock()
}
func (ac AdminClientMock) updateGroupMembers(_ context.Context, req madmin.GroupAddRemove) error {
return minioUpdateGroupMembersMock(req)
}
func (ac AdminClientMock) getGroupDescription(_ context.Context, group string) (*madmin.GroupDesc, error) {
return minioGetGroupDescriptionMock(group)
}
func (ac AdminClientMock) setGroupStatus(_ context.Context, group string, status madmin.GroupStatus) error {
return minioSetGroupStatusMock(group, status)
}
func (ac AdminClientMock) heal(ctx context.Context, bucket, prefix string, healOpts madmin.HealOpts, clientToken string,
forceStart, forceStop bool,
) (healStart madmin.HealStartSuccess, healTaskStatus madmin.HealTaskStatus, err error) {
return minioHealMock(ctx, bucket, prefix, healOpts, clientToken, forceStart, forceStop)
}
func (ac AdminClientMock) serverHealthInfo(ctx context.Context, deadline time.Duration) (interface{}, string, error) {
return minioServerHealthInfoMock(ctx, deadline)
}
func (ac AdminClientMock) addOrUpdateIDPConfig(_ context.Context, _, _, _ string, _ bool) (restart bool, err error) {
return true, nil
}
func (ac AdminClientMock) listIDPConfig(_ context.Context, _ string) ([]madmin.IDPListItem, error) {
return []madmin.IDPListItem{{Name: "mock"}}, nil
}
func (ac AdminClientMock) deleteIDPConfig(_ context.Context, _, _ string) (restart bool, err error) {
return true, nil
}
func (ac AdminClientMock) getIDPConfig(_ context.Context, _, _ string) (c madmin.IDPConfig, err error) {
return madmin.IDPConfig{Info: []madmin.IDPCfgInfo{{Key: "mock", Value: "mock"}}}, nil
}
func (ac AdminClientMock) kmsStatus(_ context.Context) (madmin.KMSStatus, error) {
return madmin.KMSStatus{Name: "name", DefaultKeyID: "key", Endpoints: map[string]madmin.ItemState{"localhost": madmin.ItemState("online")}}, nil
}
func (ac AdminClientMock) kmsAPIs(_ context.Context) ([]madmin.KMSAPI, error) {
return []madmin.KMSAPI{{Method: "GET", Path: "/mock"}}, nil
}
func (ac AdminClientMock) kmsMetrics(_ context.Context) (*madmin.KMSMetrics, error) {
return &madmin.KMSMetrics{}, nil
}
func (ac AdminClientMock) kmsVersion(_ context.Context) (*madmin.KMSVersion, error) {
return &madmin.KMSVersion{Version: "test-version"}, nil
}
func (ac AdminClientMock) createKey(_ context.Context, _ string) error {
return nil
}
func (ac AdminClientMock) listKeys(_ context.Context, _ string) ([]madmin.KMSKeyInfo, error) {
return []madmin.KMSKeyInfo{{
Name: "name",
CreatedBy: "by",
}}, nil
}
func (ac AdminClientMock) keyStatus(_ context.Context, _ string) (*madmin.KMSKeyStatus, error) {
return &madmin.KMSKeyStatus{KeyID: "key"}, nil
}
func (ac AdminClientMock) listPolicies(_ context.Context) (map[string]*iampolicy.Policy, error) {
return minioListPoliciesMock()
}
func (ac AdminClientMock) getPolicy(_ context.Context, name string) (*iampolicy.Policy, error) {
return minioGetPolicyMock(name)
}
func (ac AdminClientMock) removePolicy(_ context.Context, name string) error {
return minioRemovePolicyMock(name)
}
func (ac AdminClientMock) addPolicy(_ context.Context, name string, policy *iampolicy.Policy) error {
return minioAddPolicyMock(name, policy)
}
func (ac AdminClientMock) setPolicy(_ context.Context, policyName, entityName string, isGroup bool) error {
return minioSetPolicyMock(policyName, entityName, isGroup)
}
// mock function for startProfiling()
func (ac AdminClientMock) startProfiling(_ context.Context, profiler madmin.ProfilerType) ([]madmin.StartProfilingResult, error) {
return minioStartProfiling(profiler)
}
// mock function for stopProfiling()
func (ac AdminClientMock) stopProfiling(_ context.Context) (io.ReadCloser, error) {
return minioStopProfiling()
}
// mock function of serviceRestart()
func (ac AdminClientMock) serviceRestart(ctx context.Context) error {
return minioServiceRestartMock(ctx)
}
func (ac AdminClientMock) getSiteReplicationInfo(ctx context.Context) (*madmin.SiteReplicationInfo, error) {
return getSiteReplicationInfo(ctx)
}
func (ac AdminClientMock) addSiteReplicationInfo(ctx context.Context, sites []madmin.PeerSite, _ madmin.SRAddOptions) (*madmin.ReplicateAddStatus, error) {
return addSiteReplicationInfo(ctx, sites)
}
func (ac AdminClientMock) editSiteReplicationInfo(ctx context.Context, site madmin.PeerInfo, _ madmin.SREditOptions) (*madmin.ReplicateEditStatus, error) {
return editSiteReplicationInfo(ctx, site)
}
func (ac AdminClientMock) deleteSiteReplicationInfo(ctx context.Context, removeReq madmin.SRRemoveReq) (*madmin.ReplicateRemoveStatus, error) {
return deleteSiteReplicationInfoMock(ctx, removeReq)
}
func (ac AdminClientMock) getSiteReplicationStatus(ctx context.Context, params madmin.SRStatusOptions) (*madmin.SRStatusInfo, error) {
return getSiteReplicationStatus(ctx, params)
}
func (ac AdminClientMock) listTiers(ctx context.Context) ([]*madmin.TierConfig, error) {
return minioListTiersMock(ctx)
}
func (ac AdminClientMock) tierStats(ctx context.Context) ([]madmin.TierInfo, error) {
return minioTierStatsMock(ctx)
}
func (ac AdminClientMock) addTier(ctx context.Context, tier *madmin.TierConfig) error {
return minioAddTiersMock(ctx, tier)
}
func (ac AdminClientMock) removeTier(ctx context.Context, tierName string) error {
return minioRemoveTierMock(ctx, tierName)
}
func (ac AdminClientMock) editTierCreds(ctx context.Context, tierName string, creds madmin.TierCreds) error {
return minioEditTiersMock(ctx, tierName, creds)
}
func (ac AdminClientMock) serviceTrace(ctx context.Context, threshold int64, s3, internal, storage, os, errTrace bool) <-chan madmin.ServiceTraceInfo {
return minioServiceTraceMock(ctx, threshold, s3, internal, storage, os, errTrace)
}
func (ac AdminClientMock) listUsers(_ context.Context) (map[string]madmin.UserInfo, error) {
return minioListUsersMock()
}
func (ac AdminClientMock) addUser(_ context.Context, accessKey, secretKey string) error {
return minioAddUserMock(accessKey, secretKey)
}
func (ac AdminClientMock) removeUser(_ context.Context, accessKey string) error {
return minioRemoveUserMock(accessKey)
}
func (ac AdminClientMock) getUserInfo(_ context.Context, accessKey string) (madmin.UserInfo, error) {
return minioGetUserInfoMock(accessKey)
}
func (ac AdminClientMock) setUserStatus(_ context.Context, accessKey string, status madmin.AccountStatus) error {
return minioSetUserStatusMock(accessKey, status)
}
func (ac AdminClientMock) AccountInfo(ctx context.Context) (madmin.AccountInfo, error) {
return minioAccountInfoMock(ctx)
}
func (ac AdminClientMock) addServiceAccount(ctx context.Context, policy string, user string, accessKey string, secretKey string, description string, name string, expiry *time.Time, status string) (madmin.Credentials, error) {
return minioAddServiceAccountMock(ctx, policy, user, accessKey, secretKey, description, name, expiry, status)
}
func (ac AdminClientMock) listServiceAccounts(ctx context.Context, user string) (madmin.ListServiceAccountsResp, error) {
return minioListServiceAccountsMock(ctx, user)
}
func (ac AdminClientMock) deleteServiceAccount(ctx context.Context, serviceAccount string) error {
return minioDeleteServiceAccountMock(ctx, serviceAccount)
}
func (ac AdminClientMock) infoServiceAccount(ctx context.Context, serviceAccount string) (madmin.InfoServiceAccountResp, error) {
return minioInfoServiceAccountMock(ctx, serviceAccount)
}
func (ac AdminClientMock) updateServiceAccount(ctx context.Context, serviceAccount string, opts madmin.UpdateServiceAccountReq) error {
return minioUpdateServiceAccountMock(ctx, serviceAccount, opts)
}
func (ac AdminClientMock) getLDAPPolicyEntities(ctx context.Context, query madmin.PolicyEntitiesQuery) (madmin.PolicyEntitiesResult, error) {
return minioGetLDAPPolicyEntitiesMock(ctx, query)
}

316
api/admin_config.go Normal file
View File

@@ -0,0 +1,316 @@
// This file is part of MinIO Console Server
// Copyright (c) 2021 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package api
import (
"context"
"encoding/base64"
"fmt"
"strings"
"github.com/go-openapi/runtime/middleware"
"github.com/go-openapi/swag"
"github.com/minio/console/api/operations"
"github.com/minio/console/models"
madmin "github.com/minio/madmin-go/v3"
cfgApi "github.com/minio/console/api/operations/configuration"
)
func registerConfigHandlers(api *operations.ConsoleAPI) {
// List Configurations
api.ConfigurationListConfigHandler = cfgApi.ListConfigHandlerFunc(func(params cfgApi.ListConfigParams, session *models.Principal) middleware.Responder {
configListResp, err := getListConfigResponse(session, params)
if err != nil {
return cfgApi.NewListConfigDefault(err.Code).WithPayload(err.APIError)
}
return cfgApi.NewListConfigOK().WithPayload(configListResp)
})
// Configuration Info
api.ConfigurationConfigInfoHandler = cfgApi.ConfigInfoHandlerFunc(func(params cfgApi.ConfigInfoParams, session *models.Principal) middleware.Responder {
config, err := getConfigResponse(session, params)
if err != nil {
return cfgApi.NewConfigInfoDefault(err.Code).WithPayload(err.APIError)
}
return cfgApi.NewConfigInfoOK().WithPayload(config)
})
// Set Configuration
api.ConfigurationSetConfigHandler = cfgApi.SetConfigHandlerFunc(func(params cfgApi.SetConfigParams, session *models.Principal) middleware.Responder {
resp, err := setConfigResponse(session, params)
if err != nil {
return cfgApi.NewSetConfigDefault(err.Code).WithPayload(err.APIError)
}
return cfgApi.NewSetConfigOK().WithPayload(resp)
})
// Reset Configuration
api.ConfigurationResetConfigHandler = cfgApi.ResetConfigHandlerFunc(func(params cfgApi.ResetConfigParams, session *models.Principal) middleware.Responder {
resp, err := resetConfigResponse(session, params)
if err != nil {
return cfgApi.NewResetConfigDefault(err.Code).WithPayload(err.APIError)
}
return cfgApi.NewResetConfigOK().WithPayload(resp)
})
// Export Configuration as base64 string.
api.ConfigurationExportConfigHandler = cfgApi.ExportConfigHandlerFunc(func(params cfgApi.ExportConfigParams, session *models.Principal) middleware.Responder {
resp, err := exportConfigResponse(session, params)
if err != nil {
return cfgApi.NewExportConfigDefault(err.Code).WithPayload(err.APIError)
}
return cfgApi.NewExportConfigOK().WithPayload(resp)
})
api.ConfigurationPostConfigsImportHandler = cfgApi.PostConfigsImportHandlerFunc(func(params cfgApi.PostConfigsImportParams, session *models.Principal) middleware.Responder {
_, err := importConfigResponse(session, params)
if err != nil {
return cfgApi.NewPostConfigsImportDefault(err.Code).WithPayload(err.APIError)
}
return cfgApi.NewPostConfigsImportDefault(200)
})
}
// listConfig gets all configurations' names and their descriptions
func listConfig(client MinioAdmin) ([]*models.ConfigDescription, error) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
configKeysHelp, err := client.helpConfigKV(ctx, "", "", false)
if err != nil {
return nil, err
}
var configDescs []*models.ConfigDescription
for _, c := range configKeysHelp.KeysHelp {
desc := &models.ConfigDescription{
Key: c.Key,
Description: c.Description,
}
configDescs = append(configDescs, desc)
}
return configDescs, nil
}
// getListConfigResponse performs listConfig() and serializes it to the handler's output
func getListConfigResponse(session *models.Principal, params cfgApi.ListConfigParams) (*models.ListConfigResponse, *CodedAPIError) {
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
defer cancel()
mAdmin, err := NewMinioAdminClient(params.HTTPRequest.Context(), session)
if err != nil {
return nil, ErrorWithContext(ctx, err)
}
// create a MinIO Admin Client interface implementation
// defining the client to be used
adminClient := AdminClient{Client: mAdmin}
configDescs, err := listConfig(adminClient)
if err != nil {
return nil, ErrorWithContext(ctx, err)
}
listGroupsResponse := &models.ListConfigResponse{
Configurations: configDescs,
Total: int64(len(configDescs)),
}
return listGroupsResponse, nil
}
// getConfig gets the key values for a defined configuration.
func getConfig(ctx context.Context, client MinioAdmin, name string) ([]*models.Configuration, error) {
configBytes, err := client.getConfigKV(ctx, name)
if err != nil {
return nil, err
}
subSysConfigs, err := madmin.ParseServerConfigOutput(string(configBytes))
if err != nil {
return nil, err
}
var configSubSysList []*models.Configuration
for _, scfg := range subSysConfigs {
if !madmin.SubSystems.Contains(scfg.SubSystem) {
return nil, fmt.Errorf("no sub-systems found")
}
var confkv []*models.ConfigurationKV
for _, kv := range scfg.KV {
var envOverride *models.EnvOverride
if kv.EnvOverride != nil {
envOverride = &models.EnvOverride{
Name: kv.EnvOverride.Name,
Value: kv.EnvOverride.Value,
}
}
confkv = append(confkv, &models.ConfigurationKV{Key: kv.Key, Value: kv.Value, EnvOverride: envOverride})
}
if len(confkv) == 0 {
continue
}
var fullConfigName string
if scfg.Target == "" {
fullConfigName = scfg.SubSystem
} else {
fullConfigName = scfg.SubSystem + ":" + scfg.Target
}
configSubSysList = append(configSubSysList, &models.Configuration{KeyValues: confkv, Name: fullConfigName})
}
return configSubSysList, nil
}
// getConfigResponse performs getConfig() and serializes it to the handler's output
func getConfigResponse(session *models.Principal, params cfgApi.ConfigInfoParams) ([]*models.Configuration, *CodedAPIError) {
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
defer cancel()
mAdmin, err := NewMinioAdminClient(params.HTTPRequest.Context(), session)
if err != nil {
return nil, ErrorWithContext(ctx, err)
}
// create a MinIO Admin Client interface implementation
// defining the client to be used
adminClient := AdminClient{Client: mAdmin}
configurations, err := getConfig(ctx, adminClient, params.Name)
if err != nil {
errorVal := ErrorWithContext(ctx, err)
minioError := madmin.ToErrorResponse(err)
if minioError.Code == "XMinioConfigError" {
errorVal.Code = 404
}
return nil, errorVal
}
return configurations, nil
}
// setConfig sets a configuration with the defined key values
func setConfig(ctx context.Context, client MinioAdmin, configName *string, kvs []*models.ConfigurationKV) (restart bool, err error) {
config := buildConfig(configName, kvs)
restart, err = client.setConfigKV(ctx, *config)
if err != nil {
return false, err
}
return restart, nil
}
func setConfigWithARNAccountID(ctx context.Context, client MinioAdmin, configName *string, kvs []*models.ConfigurationKV, arnAccountID string) (restart bool, err error) {
// if arnAccountID is not empty the configuration will be treated as a notification target
// arnAccountID will be used as an identifier for that specific target
// docs: https://min.io/docs/minio/linux/administration/monitoring/bucket-notifications.html
if arnAccountID != "" {
configName = swag.String(fmt.Sprintf("%s:%s", *configName, arnAccountID))
}
return setConfig(ctx, client, configName, kvs)
}
// buildConfig builds a concatenated string including name and keyvalues
// e.g. `region name=us-west-1`
func buildConfig(configName *string, kvs []*models.ConfigurationKV) *string {
var builder strings.Builder
builder.WriteString(*configName)
for _, kv := range kvs {
key := strings.TrimSpace(kv.Key)
if key == "" {
continue
}
builder.WriteString(" ")
builder.WriteString(key)
builder.WriteString("=")
// All newlines must be converted to ','
builder.WriteString(strings.ReplaceAll(strings.TrimSpace(fmt.Sprintf("\"%s\"", kv.Value)), "\n", ","))
}
config := builder.String()
return &config
}
// setConfigResponse implements setConfig() to be used by handler
func setConfigResponse(session *models.Principal, params cfgApi.SetConfigParams) (*models.SetConfigResponse, *CodedAPIError) {
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
defer cancel()
mAdmin, err := NewMinioAdminClient(params.HTTPRequest.Context(), session)
if err != nil {
return nil, ErrorWithContext(ctx, err)
}
// create a MinIO Admin Client interface implementation
// defining the client to be used
adminClient := AdminClient{Client: mAdmin}
configName := params.Name
needsRestart, err := setConfigWithARNAccountID(ctx, adminClient, &configName, params.Body.KeyValues, params.Body.ArnResourceID)
if err != nil {
return nil, ErrorWithContext(ctx, err)
}
return &models.SetConfigResponse{Restart: needsRestart}, nil
}
func resetConfig(ctx context.Context, client MinioAdmin, configName *string) (err error) {
err = client.delConfigKV(ctx, *configName)
return err
}
// resetConfigResponse implements resetConfig() to be used by handler
func resetConfigResponse(session *models.Principal, params cfgApi.ResetConfigParams) (*models.SetConfigResponse, *CodedAPIError) {
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
defer cancel()
mAdmin, err := NewMinioAdminClient(params.HTTPRequest.Context(), session)
if err != nil {
return nil, ErrorWithContext(ctx, err)
}
// create a MinIO Admin Client interface implementation
// defining the client to be used
adminClient := AdminClient{Client: mAdmin}
err = resetConfig(ctx, adminClient, &params.Name)
if err != nil {
return nil, ErrorWithContext(ctx, err)
}
return &models.SetConfigResponse{Restart: true}, nil
}
func exportConfigResponse(session *models.Principal, params cfgApi.ExportConfigParams) (*models.ConfigExportResponse, *CodedAPIError) {
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
defer cancel()
mAdmin, err := NewMinioAdminClient(params.HTTPRequest.Context(), session)
if err != nil {
return nil, ErrorWithContext(ctx, err)
}
configRes, err := mAdmin.GetConfig(ctx)
if err != nil {
return nil, ErrorWithContext(ctx, err)
}
// may contain sensitive information so unpack only when required.
return &models.ConfigExportResponse{
Status: "success",
Value: base64.StdEncoding.EncodeToString(configRes),
}, nil
}
func importConfigResponse(session *models.Principal, params cfgApi.PostConfigsImportParams) (*cfgApi.PostConfigsImportDefault, *CodedAPIError) {
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
defer cancel()
mAdmin, err := NewMinioAdminClient(params.HTTPRequest.Context(), session)
if err != nil {
return nil, ErrorWithContext(ctx, err)
}
file, _, err := params.HTTPRequest.FormFile("file")
if err != nil {
return nil, ErrorWithContext(ctx, err)
}
defer file.Close()
err = mAdmin.SetConfig(ctx, file)
if err != nil {
return nil, ErrorWithContext(ctx, err)
}
return &cfgApi.PostConfigsImportDefault{}, nil
}

View File

@@ -14,7 +14,7 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package restapi
package api
import (
"context"
@@ -28,52 +28,21 @@ import (
"github.com/stretchr/testify/assert"
"github.com/minio/console/models"
"github.com/minio/madmin-go"
"github.com/minio/madmin-go/v3"
)
const (
NotifyPostgresSubSys = "notify_postgres"
PostgresFormat = "format"
PostgresConnectionString = "connection_string"
PostgresTable = "table"
PostgresHost = "host"
PostgresPort = "port"
PostgresUsername = "username"
PostgresPassword = "password"
PostgresDatabase = "database"
PostgresQueueDir = "queue_dir"
PostgresQueueLimit = "queue_limit"
PostgresMaxOpenConnections = "max_open_connections"
NotifyPostgresSubSys = "notify_postgres"
PostgresFormat = "format"
PostgresConnectionString = "connection_string"
PostgresTable = "table"
PostgresQueueDir = "queue_dir"
PostgresQueueLimit = "queue_limit"
)
// assigning mock at runtime instead of compile time
var minioHelpConfigKVMock func(subSys, key string, envOnly bool) (madmin.Help, error)
var minioGetConfigKVMock func(key string) ([]byte, error)
var minioSetConfigKVMock func(kv string) (restart bool, err error)
var minioDelConfigKVMock func(name string) (err error)
// mock function helpConfigKV()
func (ac adminClientMock) helpConfigKV(ctx context.Context, subSys, key string, envOnly bool) (madmin.Help, error) {
return minioHelpConfigKVMock(subSys, key, envOnly)
}
// mock function getConfigKV()
func (ac adminClientMock) getConfigKV(ctx context.Context, name string) ([]byte, error) {
return minioGetConfigKVMock(name)
}
// mock function setConfigKV()
func (ac adminClientMock) setConfigKV(ctx context.Context, kv string) (restart bool, err error) {
return minioSetConfigKVMock(kv)
}
func (ac adminClientMock) delConfigKV(ctx context.Context, name string) (err error) {
return minioDelConfigKVMock(name)
}
func TestListConfig(t *testing.T) {
assert := assert.New(t)
adminClient := adminClientMock{}
adminClient := AdminClientMock{}
function := "listConfig()"
// Test-1 : listConfig() get list of two configurations and ensure is output correctly
configListMock := []madmin.HelpKV{
@@ -94,7 +63,7 @@ func TestListConfig(t *testing.T) {
}
expectedKeysDesc := mockConfigList.KeysHelp
// mock function response from listConfig()
minioHelpConfigKVMock = func(subSys, key string, envOnly bool) (madmin.Help, error) {
minioHelpConfigKVMock = func(_, _ string, _ bool) (madmin.Help, error) {
return mockConfigList, nil
}
configList, err := listConfig(adminClient)
@@ -111,7 +80,7 @@ func TestListConfig(t *testing.T) {
// Test-2 : listConfig() Return error and see that the error is handled correctly and returned
// mock function response from listConfig()
minioHelpConfigKVMock = func(subSys, key string, envOnly bool) (madmin.Help, error) {
minioHelpConfigKVMock = func(_, _ string, _ bool) (madmin.Help, error) {
return madmin.Help{}, errors.New("error")
}
_, err = listConfig(adminClient)
@@ -122,10 +91,10 @@ func TestListConfig(t *testing.T) {
func TestSetConfig(t *testing.T) {
assert := assert.New(t)
adminClient := adminClientMock{}
adminClient := AdminClientMock{}
function := "setConfig()"
// mock function response from setConfig()
minioSetConfigKVMock = func(kv string) (restart bool, err error) {
minioSetConfigKVMock = func(_ string) (restart bool, err error) {
return false, nil
}
configName := "notify_postgres"
@@ -140,7 +109,8 @@ func TestSetConfig(t *testing.T) {
},
}
ctx := context.Background()
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
// Test-1 : setConfig() sets a config with two key value pairs
restart, err := setConfig(ctx, adminClient, &configName, kvs)
if err != nil {
@@ -149,7 +119,7 @@ func TestSetConfig(t *testing.T) {
assert.Equal(restart, false)
// Test-2 : setConfig() returns error, handle properly
minioSetConfigKVMock = func(kv string) (restart bool, err error) {
minioSetConfigKVMock = func(_ string) (restart bool, err error) {
return false, errors.New("error")
}
restart, err = setConfig(ctx, adminClient, &configName, kvs)
@@ -159,7 +129,7 @@ func TestSetConfig(t *testing.T) {
assert.Equal(restart, false)
// Test-4 : setConfig() set config, need restart
minioSetConfigKVMock = func(kv string) (restart bool, err error) {
minioSetConfigKVMock = func(_ string) (restart bool, err error) {
return true, nil
}
restart, err = setConfig(ctx, adminClient, &configName, kvs)
@@ -167,20 +137,20 @@ func TestSetConfig(t *testing.T) {
t.Errorf("Failed on %s:, error occurred: %s", function, err.Error())
}
assert.Equal(restart, true)
}
func TestDelConfig(t *testing.T) {
assert := assert.New(t)
adminClient := adminClientMock{}
adminClient := AdminClientMock{}
function := "resetConfig()"
// mock function response from setConfig()
minioDelConfigKVMock = func(name string) (err error) {
minioDelConfigKVMock = func(_ string) (err error) {
return nil
}
configName := "region"
ctx := context.Background()
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
// Test-1 : resetConfig() resets a config with the config name
err := resetConfig(ctx, adminClient, &configName)
if err != nil {
@@ -188,7 +158,7 @@ func TestDelConfig(t *testing.T) {
}
// Test-2 : resetConfig() returns error, handle properly
minioDelConfigKVMock = func(name string) (err error) {
minioDelConfigKVMock = func(_ string) (err error) {
return errors.New("error")
}
@@ -250,7 +220,7 @@ func Test_buildConfig(t *testing.T) {
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
t.Run(tt.name, func(_ *testing.T) {
if got := buildConfig(tt.args.configName, tt.args.kvs); !reflect.DeepEqual(got, tt.want) {
t.Errorf("buildConfig() = %s, want %s", *got, *tt.want)
}
@@ -260,7 +230,7 @@ func Test_buildConfig(t *testing.T) {
func Test_setConfigWithARN(t *testing.T) {
assert := assert.New(t)
client := adminClientMock{}
client := AdminClientMock{}
type args struct {
ctx context.Context
@@ -290,7 +260,7 @@ func Test_setConfigWithARN(t *testing.T) {
},
arn: "1",
},
mockSetConfig: func(kv string) (restart bool, err error) {
mockSetConfig: func(_ string) (restart bool, err error) {
return false, nil
},
wantErr: false,
@@ -310,7 +280,7 @@ func Test_setConfigWithARN(t *testing.T) {
},
arn: "1",
},
mockSetConfig: func(kv string) (restart bool, err error) {
mockSetConfig: func(_ string) (restart bool, err error) {
return true, nil
},
wantErr: false,
@@ -330,7 +300,7 @@ func Test_setConfigWithARN(t *testing.T) {
},
arn: "",
},
mockSetConfig: func(kv string) (restart bool, err error) {
mockSetConfig: func(_ string) (restart bool, err error) {
return false, nil
},
wantErr: false,
@@ -350,7 +320,7 @@ func Test_setConfigWithARN(t *testing.T) {
},
arn: "",
},
mockSetConfig: func(kv string) (restart bool, err error) {
mockSetConfig: func(_ string) (restart bool, err error) {
return false, errors.New("error")
},
wantErr: true,
@@ -358,7 +328,7 @@ func Test_setConfigWithARN(t *testing.T) {
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
t.Run(tt.name, func(_ *testing.T) {
// mock function response from setConfig()
minioSetConfigKVMock = tt.mockSetConfig
restart, err := setConfigWithARNAccountID(tt.args.ctx, tt.args.client, tt.args.configName, tt.args.kvs, tt.args.arn)
@@ -371,7 +341,7 @@ func Test_setConfigWithARN(t *testing.T) {
}
func Test_getConfig(t *testing.T) {
client := adminClientMock{}
client := AdminClientMock{}
type args struct {
client MinioAdmin
name string
@@ -380,7 +350,7 @@ func Test_getConfig(t *testing.T) {
name string
args args
mock func()
want []*models.ConfigurationKV
want []*models.Configuration
wantErr bool
}{
{
@@ -391,7 +361,7 @@ func Test_getConfig(t *testing.T) {
},
mock: func() {
// mock function response from getConfig()
minioGetConfigKVMock = func(key string) ([]byte, error) {
minioGetConfigKVMock = func(_ string) ([]byte, error) {
return []byte(`notify_postgres:_ connection_string="host=localhost dbname=minio_events user=postgres password=password port=5432 sslmode=disable" table=bucketevents`), nil
}
@@ -437,18 +407,22 @@ func Test_getConfig(t *testing.T) {
KeysHelp: configListMock,
}
// mock function response from listConfig()
minioHelpConfigKVMock = func(subSys, key string, envOnly bool) (madmin.Help, error) {
minioHelpConfigKVMock = func(_, _ string, _ bool) (madmin.Help, error) {
return mockConfigList, nil
}
},
want: []*models.ConfigurationKV{
want: []*models.Configuration{
{
Key: PostgresConnectionString,
Value: "host=localhost dbname=minio_events user=postgres password=password port=5432 sslmode=disable",
},
{
Key: PostgresTable,
Value: "bucketevents",
KeyValues: []*models.ConfigurationKV{
{
Key: PostgresConnectionString,
Value: "host=localhost dbname=minio_events user=postgres password=password port=5432 sslmode=disable",
},
{
Key: PostgresTable,
Value: "bucketevents",
},
}, Name: "notify_postgres",
},
},
wantErr: false,
@@ -461,7 +435,7 @@ func Test_getConfig(t *testing.T) {
},
mock: func() {
// mock function response from getConfig()
minioGetConfigKVMock = func(key string) ([]byte, error) {
minioGetConfigKVMock = func(_ string) ([]byte, error) {
return []byte(`notify_postgres:_`), nil
}
@@ -507,12 +481,12 @@ func Test_getConfig(t *testing.T) {
KeysHelp: configListMock,
}
// mock function response from listConfig()
minioHelpConfigKVMock = func(subSys, key string, envOnly bool) (madmin.Help, error) {
minioHelpConfigKVMock = func(_, _ string, _ bool) (madmin.Help, error) {
return mockConfigList, nil
}
},
want: nil,
wantErr: true,
wantErr: false,
},
{
name: "random bytes coming out of getConfigKv",
@@ -521,9 +495,8 @@ func Test_getConfig(t *testing.T) {
name: "notify_postgres",
},
mock: func() {
// mock function response from getConfig()
minioGetConfigKVMock = func(key string) ([]byte, error) {
minioGetConfigKVMock = func(_ string) ([]byte, error) {
x := make(map[string]string)
x["x"] = "x"
j, _ := json.Marshal(x)
@@ -572,7 +545,7 @@ func Test_getConfig(t *testing.T) {
KeysHelp: configListMock,
}
// mock function response from listConfig()
minioHelpConfigKVMock = func(subSys, key string, envOnly bool) (madmin.Help, error) {
minioHelpConfigKVMock = func(_, _ string, _ bool) (madmin.Help, error) {
return mockConfigList, nil
}
},
@@ -586,15 +559,14 @@ func Test_getConfig(t *testing.T) {
name: "notify_postgresx",
},
mock: func() {
// mock function response from getConfig()
minioGetConfigKVMock = func(key string) ([]byte, error) {
minioGetConfigKVMock = func(_ string) ([]byte, error) {
return nil, errors.New("invalid config")
}
mockConfigList := madmin.Help{}
// mock function response from listConfig()
minioHelpConfigKVMock = func(subSys, key string, envOnly bool) (madmin.Help, error) {
minioHelpConfigKVMock = func(_, _ string, _ bool) (madmin.Help, error) {
return mockConfigList, nil
}
},
@@ -609,11 +581,11 @@ func Test_getConfig(t *testing.T) {
},
mock: func() {
// mock function response from getConfig()
minioGetConfigKVMock = func(key string) ([]byte, error) {
minioGetConfigKVMock = func(_ string) ([]byte, error) {
return nil, errors.New("invalid config")
}
// mock function response from listConfig()
minioHelpConfigKVMock = func(subSys, key string, envOnly bool) (madmin.Help, error) {
minioHelpConfigKVMock = func(_, _ string, _ bool) (madmin.Help, error) {
return madmin.Help{}, errors.New("no help")
}
},
@@ -623,7 +595,7 @@ func Test_getConfig(t *testing.T) {
}
for _, tt := range tests {
tt.mock()
t.Run(tt.name, func(t *testing.T) {
t.Run(tt.name, func(_ *testing.T) {
got, err := getConfig(context.Background(), tt.args.client, tt.args.name)
if (err != nil) != tt.wantErr {
t.Errorf("getConfig() error = %v, wantErr %v", err, tt.wantErr)

View File

@@ -14,7 +14,7 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package restapi
package api
import (
"context"
@@ -22,29 +22,42 @@ import (
"strings"
"time"
"github.com/gorilla/websocket"
"github.com/minio/madmin-go"
"github.com/minio/madmin-go/v3"
"github.com/minio/websocket"
)
const logTimeFormat string = "15:04:05 MST 01/02/2006"
// startConsoleLog starts log of the servers
func startConsoleLog(ctx context.Context, conn WSConn, client MinioAdmin) error {
// TODO: accept parameters as variables
func startConsoleLog(ctx context.Context, conn WSConn, client MinioAdmin, logRequest LogRequest) error {
var node string
// name of node, default = "" (all)
node := ""
if logRequest.node == "all" {
node = ""
} else {
node = logRequest.node
}
trimNode := strings.Split(node, ":")
// number of log lines
lineCount := 100
// type of logs "minio"|"application"|"all" default = "all"
logKind := "all"
var logKind string
if logRequest.logType == "minio" || logRequest.logType == "application" || logRequest.logType == "all" {
logKind = logRequest.logType
} else {
logKind = "all"
}
// Start listening on all Console Log activity.
logCh := client.getLogs(ctx, node, lineCount, logKind)
logCh := client.getLogs(ctx, trimNode[0], lineCount, logKind)
for {
select {
case <-ctx.Done():
return nil
case logInfo, ok := <-logCh:
// zero value returned because the channel is closed and empty
if !ok {
return nil

117
api/admin_console_test.go Normal file
View File

@@ -0,0 +1,117 @@
// This file is part of MinIO Console Server
// Copyright (c) 2021 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package api
import (
"context"
"encoding/json"
"fmt"
"testing"
"github.com/minio/madmin-go/v3"
"github.com/stretchr/testify/assert"
)
func TestAdminConsoleLog(t *testing.T) {
assert := assert.New(t)
adminClient := AdminClientMock{}
mockWSConn := mockConn{}
function := "startConsoleLog(ctx, )"
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
testReceiver := make(chan madmin.LogInfo, 5)
textToReceive := "test message"
testStreamSize := 5
isClosed := false // testReceiver is closed?
// Test-1: Serve Console with no errors until Console finishes sending
// define mock function behavior for minio server Console
minioGetLogsMock = func(_ context.Context, _ string, _ int, _ string) <-chan madmin.LogInfo {
ch := make(chan madmin.LogInfo)
// Only success, start a routine to start reading line by line.
go func(ch chan<- madmin.LogInfo) {
defer close(ch)
lines := make([]int, testStreamSize)
// mocking sending 5 lines of info
for range lines {
info := madmin.LogInfo{
ConsoleMsg: textToReceive,
}
ch <- info
}
}(ch)
return ch
}
writesCount := 1
// mock connection WriteMessage() no error
connWriteMessageMock = func(_ int, data []byte) error {
// emulate that receiver gets the message written
var t madmin.LogInfo
_ = json.Unmarshal(data, &t)
if writesCount == testStreamSize {
if !isClosed {
close(testReceiver)
isClosed = true
}
return nil
}
testReceiver <- t
writesCount++
return nil
}
if err := startConsoleLog(ctx, mockWSConn, adminClient, LogRequest{node: "", logType: "all"}); err != nil {
t.Errorf("Failed on %s:, error occurred: %s", function, err.Error())
}
// check that the TestReceiver got the same number of data from Console.
for i := range testReceiver {
assert.Equal(textToReceive, i.ConsoleMsg)
}
// Test-2: if error happens while writing, return error
connWriteMessageMock = func(_ int, _ []byte) error {
return fmt.Errorf("error on write")
}
if err := startConsoleLog(ctx, mockWSConn, adminClient, LogRequest{node: "", logType: "all"}); assert.Error(err) {
assert.Equal("error on write", err.Error())
}
// Test-3: error happens on GetLogs Minio, Console should stop
// and error shall be returned.
minioGetLogsMock = func(_ context.Context, _ string, _ int, _ string) <-chan madmin.LogInfo {
ch := make(chan madmin.LogInfo)
// Only success, start a routine to start reading line by line.
go func(ch chan<- madmin.LogInfo) {
defer close(ch)
lines := make([]int, 2)
// mocking sending 5 lines of info
for range lines {
info := madmin.LogInfo{
ConsoleMsg: textToReceive,
}
ch <- info
}
ch <- madmin.LogInfo{Err: fmt.Errorf("error on Console")}
}(ch)
return ch
}
connWriteMessageMock = func(_ int, _ []byte) error {
return nil
}
if err := startConsoleLog(ctx, mockWSConn, adminClient, LogRequest{node: "", logType: "all"}); assert.Error(err) {
assert.Equal("error on Console", err.Error())
}
}

339
api/admin_groups.go Normal file
View File

@@ -0,0 +1,339 @@
// This file is part of MinIO Console Server
// Copyright (c) 2021 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package api
import (
"context"
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime/middleware"
"github.com/minio/console/api/operations"
"github.com/minio/madmin-go/v3"
groupApi "github.com/minio/console/api/operations/group"
"github.com/minio/console/models"
)
func registerGroupsHandlers(api *operations.ConsoleAPI) {
// List Groups
api.GroupListGroupsHandler = groupApi.ListGroupsHandlerFunc(func(params groupApi.ListGroupsParams, session *models.Principal) middleware.Responder {
listGroupsResponse, err := getListGroupsResponse(session, params)
if err != nil {
return groupApi.NewListGroupsDefault(err.Code).WithPayload(err.APIError)
}
return groupApi.NewListGroupsOK().WithPayload(listGroupsResponse)
})
// Group Info
api.GroupGroupInfoHandler = groupApi.GroupInfoHandlerFunc(func(params groupApi.GroupInfoParams, session *models.Principal) middleware.Responder {
groupInfo, err := getGroupInfoResponse(session, params)
if err != nil {
return groupApi.NewGroupInfoDefault(err.Code).WithPayload(err.APIError)
}
return groupApi.NewGroupInfoOK().WithPayload(groupInfo)
})
// Add Group
api.GroupAddGroupHandler = groupApi.AddGroupHandlerFunc(func(params groupApi.AddGroupParams, session *models.Principal) middleware.Responder {
if err := getAddGroupResponse(session, params); err != nil {
return groupApi.NewAddGroupDefault(err.Code).WithPayload(err.APIError)
}
return groupApi.NewAddGroupCreated()
})
// Remove Group
api.GroupRemoveGroupHandler = groupApi.RemoveGroupHandlerFunc(func(params groupApi.RemoveGroupParams, session *models.Principal) middleware.Responder {
if err := getRemoveGroupResponse(session, params); err != nil {
return groupApi.NewRemoveGroupDefault(err.Code).WithPayload(err.APIError)
}
return groupApi.NewRemoveGroupNoContent()
})
// Update Group
api.GroupUpdateGroupHandler = groupApi.UpdateGroupHandlerFunc(func(params groupApi.UpdateGroupParams, session *models.Principal) middleware.Responder {
groupUpdateResp, err := getUpdateGroupResponse(session, params)
if err != nil {
return groupApi.NewUpdateGroupDefault(err.Code).WithPayload(err.APIError)
}
return groupApi.NewUpdateGroupOK().WithPayload(groupUpdateResp)
})
}
// getListGroupsResponse performs listGroups() and serializes it to the handler's output
func getListGroupsResponse(session *models.Principal, params groupApi.ListGroupsParams) (*models.ListGroupsResponse, *CodedAPIError) {
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
defer cancel()
mAdmin, err := NewMinioAdminClient(params.HTTPRequest.Context(), session)
if err != nil {
return nil, ErrorWithContext(ctx, err)
}
// create a MinIO Admin Client interface implementation
// defining the client to be used
adminClient := AdminClient{Client: mAdmin}
groups, err := adminClient.listGroups(ctx)
if err != nil {
return nil, ErrorWithContext(ctx, err)
}
// serialize output
listGroupsResponse := &models.ListGroupsResponse{
Groups: groups,
Total: int64(len(groups)),
}
return listGroupsResponse, nil
}
// groupInfo calls MinIO server get Group's info
func groupInfo(ctx context.Context, client MinioAdmin, group string) (*madmin.GroupDesc, error) {
groupDesc, err := client.getGroupDescription(ctx, group)
if err != nil {
return nil, err
}
return groupDesc, nil
}
// getGroupInfoResponse performs groupInfo() and serializes it to the handler's output
func getGroupInfoResponse(session *models.Principal, params groupApi.GroupInfoParams) (*models.Group, *CodedAPIError) {
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
defer cancel()
mAdmin, err := NewMinioAdminClient(params.HTTPRequest.Context(), session)
if err != nil {
return nil, ErrorWithContext(ctx, err)
}
// create a MinIO Admin Client interface implementation
// defining the client to be used
adminClient := AdminClient{Client: mAdmin}
groupDesc, err := groupInfo(ctx, adminClient, params.Name)
if err != nil {
return nil, ErrorWithContext(ctx, err)
}
groupResponse := &models.Group{
Members: groupDesc.Members,
Name: groupDesc.Name,
Policy: groupDesc.Policy,
Status: groupDesc.Status,
}
return groupResponse, nil
}
// addGroupAdd a MinIO group with the defined members
func addGroup(ctx context.Context, client MinioAdmin, group string, members []string) error {
gAddRemove := madmin.GroupAddRemove{
Group: group,
Members: members,
IsRemove: false,
}
err := client.updateGroupMembers(ctx, gAddRemove)
if err != nil {
return err
}
return nil
}
// getAddGroupResponse performs addGroup() and serializes it to the handler's output
func getAddGroupResponse(session *models.Principal, params groupApi.AddGroupParams) *CodedAPIError {
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
defer cancel()
// AddGroup request needed to proceed
if params.Body == nil {
return ErrorWithContext(ctx, ErrGroupBodyNotInRequest)
}
groupRequest := params.Body
mAdmin, err := NewMinioAdminClient(params.HTTPRequest.Context(), session)
if err != nil {
return ErrorWithContext(ctx, err)
}
// create a MinIO Admin Client interface implementation
// defining the client to be used
adminClient := AdminClient{Client: mAdmin}
groupList, _ := adminClient.listGroups(ctx)
for _, b := range groupList {
if b == *groupRequest.Group {
return ErrorWithContext(ctx, ErrGroupAlreadyExists)
}
}
if err := addGroup(ctx, adminClient, *groupRequest.Group, groupRequest.Members); err != nil {
return ErrorWithContext(ctx, err)
}
return nil
}
// removeGroup deletes a minIO group only if it has no members
func removeGroup(ctx context.Context, client MinioAdmin, group string) error {
gAddRemove := madmin.GroupAddRemove{
Group: group,
Members: []string{},
IsRemove: true,
}
err := client.updateGroupMembers(ctx, gAddRemove)
if err != nil {
return err
}
return nil
}
// getRemoveGroupResponse performs removeGroup() and serializes it to the handler's output
func getRemoveGroupResponse(session *models.Principal, params groupApi.RemoveGroupParams) *CodedAPIError {
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
defer cancel()
if params.Name == "" {
return ErrorWithContext(ctx, ErrGroupNameNotInRequest)
}
mAdmin, err := NewMinioAdminClient(params.HTTPRequest.Context(), session)
if err != nil {
return ErrorWithContext(ctx, err)
}
// Create a MinIO Admin Client interface implementation
// defining the client to be used
adminClient := AdminClient{Client: mAdmin}
if err := removeGroup(ctx, adminClient, params.Name); err != nil {
minioError := madmin.ToErrorResponse(err)
err2 := ErrorWithContext(ctx, err)
if minioError.Code == "XMinioAdminNoSuchGroup" {
err2.Code = 404
}
return err2
}
return nil
}
// updateGroup updates a group by adding/removing members and setting the status to the desired one
//
// isRemove: whether remove members or not
func updateGroupMembers(ctx context.Context, client MinioAdmin, group string, members []string, isRemove bool) error {
gAddRemove := madmin.GroupAddRemove{
Group: group,
Members: members,
IsRemove: isRemove,
}
err := client.updateGroupMembers(ctx, gAddRemove)
if err != nil {
return err
}
return nil
}
// addOrDeleteMembers updates a group members by adding or deleting them based on the expectedMembers
func addOrDeleteMembers(ctx context.Context, client MinioAdmin, group *madmin.GroupDesc, expectedMembers []string) error {
// get members to delete/add
membersToDelete := DifferenceArrays(group.Members, expectedMembers)
membersToAdd := DifferenceArrays(expectedMembers, group.Members)
// delete members if any to be deleted
if len(membersToDelete) > 0 {
err := updateGroupMembers(ctx, client, group.Name, membersToDelete, true)
if err != nil {
return err
}
}
// add members if any to be added
if len(membersToAdd) > 0 {
err := updateGroupMembers(ctx, client, group.Name, membersToAdd, false)
if err != nil {
return err
}
}
return nil
}
func setGroupStatus(ctx context.Context, client MinioAdmin, group, status string) error {
var setStatus madmin.GroupStatus
switch status {
case "enabled":
setStatus = madmin.GroupEnabled
case "disabled":
setStatus = madmin.GroupDisabled
default:
return errors.New(500, "status not valid")
}
return client.setGroupStatus(ctx, group, setStatus)
}
// getUpdateGroupResponse updates a group by adding or removing it's members depending on the request,
// also sets the group's status if status in the request is different than the current one.
// Then serializes the output to be used by the handler.
func getUpdateGroupResponse(session *models.Principal, params groupApi.UpdateGroupParams) (*models.Group, *CodedAPIError) {
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
defer cancel()
if params.Name == "" {
return nil, ErrorWithContext(ctx, ErrGroupNameNotInRequest)
}
if params.Body == nil {
return nil, ErrorWithContext(ctx, ErrGroupBodyNotInRequest)
}
expectedGroupUpdate := params.Body
mAdmin, err := NewMinioAdminClient(params.HTTPRequest.Context(), session)
if err != nil {
return nil, ErrorWithContext(ctx, err)
}
// create a MinIO Admin Client interface implementation
// defining the client to be used
adminClient := AdminClient{Client: mAdmin}
groupUpdated, err := groupUpdate(ctx, adminClient, params.Name, expectedGroupUpdate)
if err != nil {
return nil, ErrorWithContext(ctx, err)
}
groupResponse := &models.Group{
Name: groupUpdated.Name,
Members: groupUpdated.Members,
Policy: groupUpdated.Policy,
Status: groupUpdated.Status,
}
return groupResponse, nil
}
// groupUpdate updates a group given the expected parameters, compares the expected parameters against the current ones
// and updates them accordingly, status is only updated if the expected status is different than the current one.
// Then fetches the group again to return the object updated.
func groupUpdate(ctx context.Context, client MinioAdmin, groupName string, expectedGroup *models.UpdateGroupRequest) (*madmin.GroupDesc, error) {
expectedMembers := expectedGroup.Members
expectedStatus := *expectedGroup.Status
// get current members and status
groupDescription, err := groupInfo(ctx, client, groupName)
if err != nil {
LogInfo("error getting group info: %v", err)
return nil, err
}
// update group members
err = addOrDeleteMembers(ctx, client, groupDescription, expectedMembers)
if err != nil {
LogInfo("error updating group: %v", err)
return nil, err
}
// update group status only if different from current status
if expectedStatus != groupDescription.Status {
err = setGroupStatus(ctx, client, groupDescription.Name, expectedStatus)
if err != nil {
LogInfo("error updating group's status: %v", err)
return nil, err
}
}
// return latest group info to verify that changes were applied correctly
groupDescription, err = groupInfo(ctx, client, groupName)
if err != nil {
LogInfo("error getting group info: %v", err)
return nil, err
}
return groupDescription, nil
}

View File

@@ -14,52 +14,25 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package restapi
package api
import (
"context"
"errors"
"fmt"
"testing"
"github.com/go-openapi/swag"
"github.com/minio/console/models"
"github.com/minio/madmin-go"
"github.com/minio/madmin-go/v3"
"github.com/stretchr/testify/assert"
"errors"
)
// assigning mock at runtime instead of compile time
var minioListGroupsMock func() ([]string, error)
var minioUpdateGroupMembersMock func(madmin.GroupAddRemove) error
var minioGetGroupDescriptionMock func(group string) (*madmin.GroupDesc, error)
var minioSetGroupStatusMock func(group string, status madmin.GroupStatus) error
// mock function of listGroups()
func (ac adminClientMock) listGroups(ctx context.Context) ([]string, error) {
return minioListGroupsMock()
}
// mock function of updateGroupMembers()
func (ac adminClientMock) updateGroupMembers(ctx context.Context, req madmin.GroupAddRemove) error {
return minioUpdateGroupMembersMock(req)
}
// mock function of getGroupDescription()
func (ac adminClientMock) getGroupDescription(ctx context.Context, group string) (*madmin.GroupDesc, error) {
return minioGetGroupDescriptionMock(group)
}
// mock function setGroupStatus()
func (ac adminClientMock) setGroupStatus(ctx context.Context, group string, status madmin.GroupStatus) error {
return minioSetGroupStatusMock(group, status)
}
func TestListGroups(t *testing.T) {
assert := assert.New(t)
adminClient := adminClientMock{}
ctx := context.Background()
adminClient := AdminClientMock{}
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
// Test-1 : listGroups() Get response from minio client with two Groups and return the same number on listGroups()
mockGroupsList := []string{"group1", "group2"}
@@ -93,9 +66,9 @@ func TestListGroups(t *testing.T) {
func TestAddGroup(t *testing.T) {
assert := assert.New(t)
adminClient := adminClientMock{}
ctx := context.Background()
adminClient := AdminClientMock{}
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
// Test-1 : addGroup() add a new group with two members
newGroup := "acmeGroup"
groupMembers := []string{"user1", "user2"}
@@ -120,9 +93,9 @@ func TestAddGroup(t *testing.T) {
func TestRemoveGroup(t *testing.T) {
assert := assert.New(t)
adminClient := adminClientMock{}
ctx := context.Background()
adminClient := AdminClientMock{}
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
// Test-1 : removeGroup() remove group assume it has no members
groupToRemove := "acmeGroup"
// mock function response from updateGroupMembers()
@@ -145,9 +118,9 @@ func TestRemoveGroup(t *testing.T) {
func TestGroupInfo(t *testing.T) {
assert := assert.New(t)
adminClient := adminClientMock{}
ctx := context.Background()
adminClient := AdminClientMock{}
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
// Test-1 : groupInfo() get group info
groupName := "acmeGroup"
mockResponse := &madmin.GroupDesc{
@@ -157,7 +130,7 @@ func TestGroupInfo(t *testing.T) {
Status: "enabled",
}
// mock function response from updateGroupMembers()
minioGetGroupDescriptionMock = func(group string) (*madmin.GroupDesc, error) {
minioGetGroupDescriptionMock = func(_ string) (*madmin.GroupDesc, error) {
return mockResponse, nil
}
function := "groupInfo()"
@@ -171,7 +144,7 @@ func TestGroupInfo(t *testing.T) {
assert.Equal("enabled", info.Status)
// Test-2 : groupInfo() Return error and see that the error is handled correctly and returned
minioGetGroupDescriptionMock = func(group string) (*madmin.GroupDesc, error) {
minioGetGroupDescriptionMock = func(_ string) (*madmin.GroupDesc, error) {
return nil, errors.New("error")
}
_, err = groupInfo(ctx, adminClient, groupName)
@@ -182,9 +155,9 @@ func TestGroupInfo(t *testing.T) {
func TestUpdateGroup(t *testing.T) {
assert := assert.New(t)
adminClient := adminClientMock{}
ctx := context.Background()
adminClient := AdminClientMock{}
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
// Test-1 : addOrDeleteMembers() update group members add user3 and delete user2
function := "addOrDeleteMembers()"
groupName := "acmeGroup"
@@ -253,7 +226,7 @@ func TestUpdateGroup(t *testing.T) {
// the function twice but the second time returned an error
is2ndRunGroupInfo := false
// mock function response from updateGroupMembers()
minioGetGroupDescriptionMock = func(group string) (*madmin.GroupDesc, error) {
minioGetGroupDescriptionMock = func(_ string) (*madmin.GroupDesc, error) {
if is2ndRunGroupInfo {
return mockResponseAfterUpdate, nil
}
@@ -263,7 +236,7 @@ func TestUpdateGroup(t *testing.T) {
minioUpdateGroupMembersMock = func(madmin.GroupAddRemove) error {
return nil
}
minioSetGroupStatusMock = func(group string, status madmin.GroupStatus) error {
minioSetGroupStatusMock = func(_ string, _ madmin.GroupStatus) error {
return nil
}
groupUpdated, err := groupUpdate(ctx, adminClient, groupName, expectedGroupUpdate)
@@ -278,14 +251,14 @@ func TestUpdateGroup(t *testing.T) {
func TestSetGroupStatus(t *testing.T) {
assert := assert.New(t)
adminClient := adminClientMock{}
adminClient := AdminClientMock{}
function := "setGroupStatus()"
groupName := "acmeGroup"
ctx := context.Background()
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
// Test-1: setGroupStatus() update valid disabled status
expectedStatus := "disabled"
minioSetGroupStatusMock = func(group string, status madmin.GroupStatus) error {
minioSetGroupStatusMock = func(_ string, _ madmin.GroupStatus) error {
return nil
}
if err := setGroupStatus(ctx, adminClient, groupName, expectedStatus); err != nil {
@@ -293,7 +266,7 @@ func TestSetGroupStatus(t *testing.T) {
}
// Test-2: setGroupStatus() update valid enabled status
expectedStatus = "enabled"
minioSetGroupStatusMock = func(group string, status madmin.GroupStatus) error {
minioSetGroupStatusMock = func(_ string, _ madmin.GroupStatus) error {
return nil
}
if err := setGroupStatus(ctx, adminClient, groupName, expectedStatus); err != nil {
@@ -301,7 +274,7 @@ func TestSetGroupStatus(t *testing.T) {
}
// Test-3: setGroupStatus() update invalid status, should send error
expectedStatus = "invalid"
minioSetGroupStatusMock = func(group string, status madmin.GroupStatus) error {
minioSetGroupStatusMock = func(_ string, _ madmin.GroupStatus) error {
return nil
}
if err := setGroupStatus(ctx, adminClient, groupName, expectedStatus); assert.Error(err) {
@@ -309,7 +282,7 @@ func TestSetGroupStatus(t *testing.T) {
}
// Test-4: setGroupStatus() handler error correctly
expectedStatus = "enabled"
minioSetGroupStatusMock = func(group string, status madmin.GroupStatus) error {
minioSetGroupStatusMock = func(_ string, _ madmin.GroupStatus) error {
return errors.New("error")
}
if err := setGroupStatus(ctx, adminClient, groupName, expectedStatus); assert.Error(err) {

153
api/admin_health_info.go Normal file
View File

@@ -0,0 +1,153 @@
// This file is part of MinIO Console Server
// Copyright (c) 2021 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package api
import (
"context"
b64 "encoding/base64"
"encoding/json"
"errors"
"fmt"
"net/http"
"net/url"
"os"
"time"
"github.com/minio/console/pkg/logger"
"github.com/minio/console/pkg/utils"
subnet "github.com/minio/console/pkg/subnet"
mc "github.com/minio/mc/cmd"
"github.com/minio/websocket"
)
// startHealthInfo starts fetching mc.ServerHealthInfo and
// sends messages with the corresponding data on the websocket connection
func startHealthInfo(ctx context.Context, conn WSConn, client MinioAdmin, deadline *time.Duration) error {
if deadline == nil {
return errors.New("duration can't be nil on startHealthInfo")
}
// Fetch info of all servers (cluster or single server)
healthInfo, version, err := client.serverHealthInfo(ctx, *deadline)
if err != nil {
return err
}
compressedDiag, err := mc.TarGZHealthInfo(healthInfo, version)
if err != nil {
return err
}
encodedDiag := b64.StdEncoding.EncodeToString(compressedDiag)
type messageReport struct {
Encoded string `json:"encoded"`
ServerHealthInfo interface{} `json:"serverHealthInfo"`
SubnetResponse string `json:"subnetResponse"`
}
ctx = context.WithValue(ctx, utils.ContextClientIP, conn.remoteAddress())
err = sendHealthInfoToSubnet(ctx, compressedDiag, client)
report := messageReport{
Encoded: encodedDiag,
ServerHealthInfo: healthInfo,
SubnetResponse: mc.SubnetBaseURL() + "/health",
}
if err != nil {
report.SubnetResponse = fmt.Sprintf("Error: %s", err.Error())
}
message, err := json.Marshal(report)
if err != nil {
return err
}
// Send Message through websocket connection
return conn.writeMessage(websocket.TextMessage, message)
}
// getHealthInfoOptionsFromReq gets duration for startHealthInfo request
// path come as : `/health-info?deadline=2h`
func getHealthInfoOptionsFromReq(req *http.Request) (*time.Duration, error) {
deadlineDuration, err := time.ParseDuration(req.FormValue("deadline"))
if err != nil {
return nil, err
}
return &deadlineDuration, nil
}
func updateMcGlobals(subnetTokenConfig subnet.LicenseTokenConfig) error {
mc.GlobalDevMode = getConsoleDevMode()
if len(subnetTokenConfig.Proxy) > 0 {
proxyURL, e := url.Parse(subnetTokenConfig.Proxy)
if e != nil {
return e
}
mc.GlobalSubnetProxyURL = proxyURL
}
return nil
}
func sendHealthInfoToSubnet(ctx context.Context, compressedHealthInfo []byte, client MinioAdmin) error {
filename := fmt.Sprintf("health_%d.json.gz", time.Now().Unix())
subnetTokenConfig, e := GetSubnetKeyFromMinIOConfig(ctx, client)
if e != nil {
return e
}
e = updateMcGlobals(*subnetTokenConfig)
if e != nil {
return e
}
var apiKey string
if len(subnetTokenConfig.APIKey) != 0 {
apiKey = subnetTokenConfig.APIKey
} else {
apiKey, e = subnet.GetSubnetAPIKeyUsingLicense(subnetTokenConfig.License)
if e != nil {
return e
}
}
e = os.WriteFile(filename, compressedHealthInfo, 0o666)
if e != nil {
return e
}
headers := mc.SubnetAPIKeyAuthHeaders(apiKey)
resp, e := (&mc.SubnetFileUploader{
FilePath: filename,
ReqURL: mc.SubnetUploadURL("health"),
Headers: headers,
DeleteAfterUpload: true,
}).UploadFileToSubnet()
if e != nil {
// file gets deleted only if upload is successful
// so we delete explicitly here as we already have the bytes
logger.LogIf(ctx, os.Remove(filename))
return e
}
type SubnetResponse struct {
LicenseV2 string `json:"license_v2,omitempty"`
APIKey string `json:"api_key,omitempty"`
}
var subnetResp SubnetResponse
e = json.Unmarshal([]byte(resp), &subnetResp)
if e != nil {
return e
}
return nil
}

View File

@@ -0,0 +1,147 @@
// This file is part of MinIO Console Server
// Copyright (c) 2021 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package api
import (
"context"
"encoding/json"
"errors"
"reflect"
"testing"
"time"
madmin "github.com/minio/madmin-go/v3"
)
func Test_serverHealthInfo(t *testing.T) {
var testReceiver chan madmin.HealthInfo
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
client := AdminClientMock{}
mockWSConn := mockConn{}
deadlineDuration, _ := time.ParseDuration("1h")
type args struct {
deadline time.Duration
wsWriteMock func(messageType int, data []byte) error
mockMessages []madmin.HealthInfo
}
tests := []struct {
test string
args args
wantError error
}{
{
test: "Return simple health info, no errors",
args: args{
deadline: deadlineDuration,
mockMessages: []madmin.HealthInfo{{}, {}},
wsWriteMock: func(_ int, data []byte) error {
// mock connection WriteMessage() no error
// emulate that receiver gets the message written
var t madmin.HealthInfo
_ = json.Unmarshal(data, &t)
testReceiver <- t
return nil
},
},
wantError: nil,
},
{
test: "Return simple health info2, no errors",
args: args{
deadline: deadlineDuration,
mockMessages: []madmin.HealthInfo{{}},
wsWriteMock: func(_ int, data []byte) error {
// mock connection WriteMessage() no error
// emulate that receiver gets the message written
var t madmin.HealthInfo
_ = json.Unmarshal(data, &t)
testReceiver <- t
return nil
},
},
wantError: nil,
},
{
test: "Handle error on ws write",
args: args{
deadline: deadlineDuration,
mockMessages: []madmin.HealthInfo{{}},
wsWriteMock: func(_ int, data []byte) error {
// mock connection WriteMessage() no error
// emulate that receiver gets the message written
var t madmin.HealthInfo
_ = json.Unmarshal(data, &t)
return errors.New("error on write")
},
},
wantError: errors.New("error on write"),
},
{
test: "Handle error on health function",
args: args{
deadline: deadlineDuration,
mockMessages: []madmin.HealthInfo{
{
Error: "error on healthInfo",
},
},
wsWriteMock: func(_ int, data []byte) error {
// mock connection WriteMessage() no error
// emulate that receiver gets the message written
var t madmin.HealthInfo
_ = json.Unmarshal(data, &t)
return nil
},
},
wantError: nil,
},
}
for _, tt := range tests {
tt := tt
t.Run(tt.test, func(_ *testing.T) {
// make testReceiver channel
testReceiver = make(chan madmin.HealthInfo, len(tt.args.mockMessages))
// mock function same for all tests, changes mockMessages
minioServerHealthInfoMock = func(_ context.Context,
_ time.Duration,
) (interface{}, string, error) {
info := tt.args.mockMessages[0]
return info, madmin.HealthInfoVersion, nil
}
connWriteMessageMock = tt.args.wsWriteMock
err := startHealthInfo(ctx, mockWSConn, client, &deadlineDuration)
// close test mock channel
close(testReceiver)
// check that the TestReceiver got the same number of data from Console.
index := 0
for info := range testReceiver {
if !reflect.DeepEqual(info, tt.args.mockMessages[index]) {
t.Errorf("startHealthInfo() got: %v, want: %v", info, tt.args.mockMessages[index])
return
}
index++
}
if !reflect.DeepEqual(err, tt.wantError) {
t.Errorf("startHealthInfo() error: %v, wantError: %v", err, tt.wantError)
return
}
})
}
}

290
api/admin_idp.go Normal file
View File

@@ -0,0 +1,290 @@
// This file is part of MinIO Console Server
// Copyright (c) 2022 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
package api
import (
"context"
"fmt"
"time"
"github.com/go-openapi/runtime/middleware"
"github.com/minio/console/api/operations"
"github.com/minio/console/api/operations/idp"
"github.com/minio/console/models"
"github.com/minio/madmin-go/v3"
)
var errInvalidIDPType = fmt.Errorf("IDP type must be one of %v", madmin.ValidIDPConfigTypes)
func registerIDPHandlers(api *operations.ConsoleAPI) {
api.IdpCreateConfigurationHandler = idp.CreateConfigurationHandlerFunc(func(params idp.CreateConfigurationParams, session *models.Principal) middleware.Responder {
response, err := createIDPConfigurationResponse(session, params)
if err != nil {
return idp.NewCreateConfigurationDefault(err.Code).WithPayload(err.APIError)
}
return idp.NewCreateConfigurationCreated().WithPayload(response)
})
api.IdpUpdateConfigurationHandler = idp.UpdateConfigurationHandlerFunc(func(params idp.UpdateConfigurationParams, session *models.Principal) middleware.Responder {
response, err := updateIDPConfigurationResponse(session, params)
if err != nil {
return idp.NewUpdateConfigurationDefault(err.Code).WithPayload(err.APIError)
}
return idp.NewUpdateConfigurationOK().WithPayload(response)
})
api.IdpListConfigurationsHandler = idp.ListConfigurationsHandlerFunc(func(params idp.ListConfigurationsParams, session *models.Principal) middleware.Responder {
response, err := listIDPConfigurationsResponse(session, params)
if err != nil {
return idp.NewListConfigurationsDefault(err.Code).WithPayload(err.APIError)
}
return idp.NewListConfigurationsOK().WithPayload(response)
})
api.IdpDeleteConfigurationHandler = idp.DeleteConfigurationHandlerFunc(func(params idp.DeleteConfigurationParams, session *models.Principal) middleware.Responder {
response, err := deleteIDPConfigurationResponse(session, params)
if err != nil {
return idp.NewDeleteConfigurationDefault(err.Code).WithPayload(err.APIError)
}
return idp.NewDeleteConfigurationOK().WithPayload(response)
})
api.IdpGetConfigurationHandler = idp.GetConfigurationHandlerFunc(func(params idp.GetConfigurationParams, session *models.Principal) middleware.Responder {
response, err := getIDPConfigurationsResponse(session, params)
if err != nil {
return idp.NewGetConfigurationDefault(err.Code).WithPayload(err.APIError)
}
return idp.NewGetConfigurationOK().WithPayload(response)
})
api.IdpGetLDAPEntitiesHandler = idp.GetLDAPEntitiesHandlerFunc(func(params idp.GetLDAPEntitiesParams, session *models.Principal) middleware.Responder {
response, err := getLDAPEntitiesResponse(session, params)
if err != nil {
return idp.NewGetLDAPEntitiesDefault(err.Code).WithPayload(err.APIError)
}
return idp.NewGetLDAPEntitiesOK().WithPayload(response)
})
}
func createIDPConfigurationResponse(session *models.Principal, params idp.CreateConfigurationParams) (*models.SetIDPResponse, *CodedAPIError) {
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
defer cancel()
mAdmin, err := NewMinioAdminClient(params.HTTPRequest.Context(), session)
if err != nil {
return nil, ErrorWithContext(ctx, err)
}
restart, err := createOrUpdateIDPConfig(ctx, params.Type, params.Body.Name, params.Body.Input, false, AdminClient{Client: mAdmin})
if err != nil {
return nil, ErrorWithContext(ctx, err)
}
return &models.SetIDPResponse{Restart: restart}, nil
}
func updateIDPConfigurationResponse(session *models.Principal, params idp.UpdateConfigurationParams) (*models.SetIDPResponse, *CodedAPIError) {
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
defer cancel()
mAdmin, err := NewMinioAdminClient(params.HTTPRequest.Context(), session)
if err != nil {
return nil, ErrorWithContext(ctx, err)
}
restart, err := createOrUpdateIDPConfig(ctx, params.Type, params.Name, params.Body.Input, true, AdminClient{Client: mAdmin})
if err != nil {
return nil, ErrorWithContext(ctx, err)
}
return &models.SetIDPResponse{Restart: restart}, nil
}
func createOrUpdateIDPConfig(ctx context.Context, idpType, name, input string, update bool, client MinioAdmin) (bool, error) {
if !madmin.ValidIDPConfigTypes.Contains(idpType) {
return false, errInvalidIDPType
}
restart, err := client.addOrUpdateIDPConfig(ctx, idpType, name, input, update)
if err != nil {
return false, err
}
return restart, nil
}
func listIDPConfigurationsResponse(session *models.Principal, params idp.ListConfigurationsParams) (*models.IdpListConfigurationsResponse, *CodedAPIError) {
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
defer cancel()
mAdmin, err := NewMinioAdminClient(params.HTTPRequest.Context(), session)
if err != nil {
return nil, ErrorWithContext(ctx, err)
}
results, err := listIDPConfigurations(ctx, params.Type, AdminClient{Client: mAdmin})
if err != nil {
return nil, ErrorWithContext(ctx, err)
}
return &models.IdpListConfigurationsResponse{Results: results}, nil
}
func listIDPConfigurations(ctx context.Context, idpType string, client MinioAdmin) ([]*models.IdpServerConfiguration, error) {
if !madmin.ValidIDPConfigTypes.Contains(idpType) {
return nil, errInvalidIDPType
}
results, err := client.listIDPConfig(ctx, idpType)
if err != nil {
return nil, err
}
return parseIDPConfigurations(results), nil
}
func parseIDPConfigurations(configs []madmin.IDPListItem) (serverConfigs []*models.IdpServerConfiguration) {
for _, c := range configs {
serverConfigs = append(serverConfigs, &models.IdpServerConfiguration{
Name: c.Name,
Enabled: c.Enabled,
Type: c.Type,
})
}
return serverConfigs
}
func deleteIDPConfigurationResponse(session *models.Principal, params idp.DeleteConfigurationParams) (*models.SetIDPResponse, *CodedAPIError) {
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
defer cancel()
mAdmin, err := NewMinioAdminClient(params.HTTPRequest.Context(), session)
if err != nil {
return nil, ErrorWithContext(ctx, err)
}
restart, err := deleteIDPConfig(ctx, params.Type, params.Name, AdminClient{Client: mAdmin})
if err != nil {
return nil, ErrorWithContext(ctx, err)
}
return &models.SetIDPResponse{Restart: restart}, nil
}
func deleteIDPConfig(ctx context.Context, idpType, name string, client MinioAdmin) (bool, error) {
if !madmin.ValidIDPConfigTypes.Contains(idpType) {
return false, errInvalidIDPType
}
restart, err := client.deleteIDPConfig(ctx, idpType, name)
if err != nil {
return false, err
}
return restart, nil
}
func getIDPConfigurationsResponse(session *models.Principal, params idp.GetConfigurationParams) (*models.IdpServerConfiguration, *CodedAPIError) {
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
defer cancel()
mAdmin, err := NewMinioAdminClient(params.HTTPRequest.Context(), session)
if err != nil {
return nil, ErrorWithContext(ctx, err)
}
result, err := getIDPConfiguration(ctx, params.Type, params.Name, AdminClient{Client: mAdmin})
if err != nil {
return nil, ErrorWithContext(ctx, err)
}
return result, nil
}
func getIDPConfiguration(ctx context.Context, idpType, name string, client MinioAdmin) (*models.IdpServerConfiguration, error) {
if !madmin.ValidIDPConfigTypes.Contains(idpType) {
return nil, errInvalidIDPType
}
config, err := client.getIDPConfig(ctx, idpType, name)
if err != nil {
return nil, err
}
return &models.IdpServerConfiguration{
Name: config.Name,
Type: config.Type,
Info: parseIDPConfigurationsInfo(config.Info),
}, nil
}
func parseIDPConfigurationsInfo(infoList []madmin.IDPCfgInfo) (results []*models.IdpServerConfigurationInfo) {
for _, info := range infoList {
results = append(results, &models.IdpServerConfigurationInfo{
Key: info.Key,
Value: info.Value,
IsCfg: info.IsCfg,
IsEnv: info.IsEnv,
})
}
return results
}
func getLDAPEntitiesResponse(session *models.Principal, params idp.GetLDAPEntitiesParams) (*models.LdapEntities, *CodedAPIError) {
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
defer cancel()
mAdmin, err := NewMinioAdminClient(params.HTTPRequest.Context(), session)
if err != nil {
return nil, ErrorWithContext(ctx, err)
}
result, err := getEntitiesResult(ctx, AdminClient{Client: mAdmin}, params.Body.Users, params.Body.Groups, params.Body.Policies)
if err != nil {
return nil, ErrorWithContext(ctx, err)
}
return result, nil
}
func getEntitiesResult(ctx context.Context, client MinioAdmin, users, groups, policies []string) (*models.LdapEntities, error) {
entities, err := client.getLDAPPolicyEntities(ctx, madmin.PolicyEntitiesQuery{
Users: users,
Groups: groups,
Policy: policies,
})
if err != nil {
return nil, err
}
var result models.LdapEntities
var usersEntity []*models.LdapUserPolicyEntity
var groupsEntity []*models.LdapGroupPolicyEntity
var policiesEntity []*models.LdapPolicyEntity
result.Timestamp = entities.Timestamp.Format(time.RFC3339)
for _, userMapping := range entities.UserMappings {
mapItem := models.LdapUserPolicyEntity{
User: userMapping.User,
Policies: userMapping.Policies,
}
usersEntity = append(usersEntity, &mapItem)
}
result.Users = usersEntity
for _, groupsMapping := range entities.GroupMappings {
mapItem := models.LdapGroupPolicyEntity{
Group: groupsMapping.Group,
Policies: groupsMapping.Policies,
}
groupsEntity = append(groupsEntity, &mapItem)
}
result.Groups = groupsEntity
for _, policyMapping := range entities.PolicyMappings {
mapItem := models.LdapPolicyEntity{
Policy: policyMapping.Policy,
Users: policyMapping.Users,
Groups: policyMapping.Groups,
}
policiesEntity = append(policiesEntity, &mapItem)
}
result.Policies = policiesEntity
return &result, nil
}

319
api/admin_idp_test.go Normal file
View File

@@ -0,0 +1,319 @@
// This file is part of MinIO Console Server
// Copyright (c) 2022 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package api
import (
"context"
"errors"
"fmt"
"net/http"
"net/http/httptest"
"os"
"testing"
"github.com/minio/madmin-go/v3"
"github.com/minio/console/api/operations"
"github.com/minio/console/api/operations/idp"
"github.com/minio/console/models"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/suite"
)
type IDPTestSuite struct {
suite.Suite
assert *assert.Assertions
currentServer string
isServerSet bool
server *httptest.Server
adminClient AdminClientMock
}
func (suite *IDPTestSuite) SetupSuite() {
suite.assert = assert.New(suite.T())
suite.adminClient = AdminClientMock{}
minioServiceRestartMock = func(_ context.Context) error {
return nil
}
}
func (suite *IDPTestSuite) SetupTest() {
suite.server = httptest.NewServer(http.HandlerFunc(suite.serverHandler))
suite.currentServer, suite.isServerSet = os.LookupEnv(ConsoleMinIOServer)
os.Setenv(ConsoleMinIOServer, suite.server.URL)
}
func (suite *IDPTestSuite) serverHandler(w http.ResponseWriter, _ *http.Request) {
w.WriteHeader(400)
}
func (suite *IDPTestSuite) TearDownSuite() {
}
func (suite *IDPTestSuite) TearDownTest() {
if suite.isServerSet {
os.Setenv(ConsoleMinIOServer, suite.currentServer)
} else {
os.Unsetenv(ConsoleMinIOServer)
}
}
func (suite *IDPTestSuite) TestRegisterIDPHandlers() {
api := &operations.ConsoleAPI{}
suite.assertHandlersAreNil(api)
registerIDPHandlers(api)
suite.assertHandlersAreNotNil(api)
}
func (suite *IDPTestSuite) assertHandlersAreNil(api *operations.ConsoleAPI) {
suite.assert.Nil(api.IdpCreateConfigurationHandler)
suite.assert.Nil(api.IdpListConfigurationsHandler)
suite.assert.Nil(api.IdpUpdateConfigurationHandler)
suite.assert.Nil(api.IdpGetConfigurationHandler)
suite.assert.Nil(api.IdpGetConfigurationHandler)
suite.assert.Nil(api.IdpDeleteConfigurationHandler)
}
func (suite *IDPTestSuite) assertHandlersAreNotNil(api *operations.ConsoleAPI) {
suite.assert.NotNil(api.IdpCreateConfigurationHandler)
suite.assert.NotNil(api.IdpListConfigurationsHandler)
suite.assert.NotNil(api.IdpUpdateConfigurationHandler)
suite.assert.NotNil(api.IdpGetConfigurationHandler)
suite.assert.NotNil(api.IdpGetConfigurationHandler)
suite.assert.NotNil(api.IdpDeleteConfigurationHandler)
}
func (suite *IDPTestSuite) TestCreateIDPConfigurationHandlerWithError() {
params, api := suite.initCreateIDPConfigurationRequest()
response := api.IdpCreateConfigurationHandler.Handle(params, &models.Principal{})
_, ok := response.(*idp.CreateConfigurationDefault)
suite.assert.True(ok)
}
func (suite *IDPTestSuite) initCreateIDPConfigurationRequest() (params idp.CreateConfigurationParams, api operations.ConsoleAPI) {
registerIDPHandlers(&api)
params.HTTPRequest = &http.Request{}
params.Body = &models.IdpServerConfiguration{}
params.Type = "ldap"
return params, api
}
func (suite *IDPTestSuite) TestCreateIDPConfigurationWithoutError() {
ctx := context.Background()
_, err := createOrUpdateIDPConfig(ctx, "ldap", "", "", false, suite.adminClient)
suite.assert.Nil(err)
}
func (suite *IDPTestSuite) TestCreateIDPConfigurationWithWrongType() {
ctx := context.Background()
_, err := createOrUpdateIDPConfig(ctx, "", "", "", false, suite.adminClient)
suite.assert.NotNil(err)
}
func (suite *IDPTestSuite) TestUpdateIDPConfigurationHandlerWithError() {
params, api := suite.initUpdateIDPConfigurationRequest()
response := api.IdpUpdateConfigurationHandler.Handle(params, &models.Principal{})
_, ok := response.(*idp.UpdateConfigurationDefault)
suite.assert.True(ok)
}
func (suite *IDPTestSuite) initUpdateIDPConfigurationRequest() (params idp.UpdateConfigurationParams, api operations.ConsoleAPI) {
registerIDPHandlers(&api)
params.HTTPRequest = &http.Request{}
params.Body = &models.IdpServerConfiguration{}
params.Type = "ldap"
return params, api
}
func (suite *IDPTestSuite) TestUpdateIDPConfigurationWithoutError() {
ctx := context.Background()
_, err := createOrUpdateIDPConfig(ctx, "ldap", "", "", true, suite.adminClient)
suite.assert.Nil(err)
}
func (suite *IDPTestSuite) TestUpdateIDPConfigurationWithWrongType() {
ctx := context.Background()
_, err := createOrUpdateIDPConfig(ctx, "", "", "", true, suite.adminClient)
suite.assert.NotNil(err)
}
func (suite *IDPTestSuite) TestListIDPConfigurationHandlerWithError() {
params, api := suite.initListIDPConfigurationsRequest()
response := api.IdpListConfigurationsHandler.Handle(params, &models.Principal{})
_, ok := response.(*idp.ListConfigurationsDefault)
suite.assert.True(ok)
}
func (suite *IDPTestSuite) initListIDPConfigurationsRequest() (params idp.ListConfigurationsParams, api operations.ConsoleAPI) {
registerIDPHandlers(&api)
params.HTTPRequest = &http.Request{}
params.Type = "ldap"
return params, api
}
func (suite *IDPTestSuite) TestListIDPConfigurationsWithoutError() {
ctx := context.Background()
res, err := listIDPConfigurations(ctx, "ldap", suite.adminClient)
suite.assert.NotNil(res)
suite.assert.Nil(err)
}
func (suite *IDPTestSuite) TestListIDPConfigurationsWithWrongType() {
ctx := context.Background()
res, err := listIDPConfigurations(ctx, "", suite.adminClient)
suite.assert.Nil(res)
suite.assert.NotNil(err)
}
func (suite *IDPTestSuite) TestDeleteIDPConfigurationHandlerWithError() {
params, api := suite.initDeleteIDPConfigurationRequest()
response := api.IdpDeleteConfigurationHandler.Handle(params, &models.Principal{})
_, ok := response.(*idp.DeleteConfigurationDefault)
suite.assert.True(ok)
}
func (suite *IDPTestSuite) initDeleteIDPConfigurationRequest() (params idp.DeleteConfigurationParams, api operations.ConsoleAPI) {
registerIDPHandlers(&api)
params.HTTPRequest = &http.Request{}
params.Type = "ldap"
return params, api
}
func (suite *IDPTestSuite) TestDeleteIDPConfigurationWithoutError() {
ctx := context.Background()
_, err := deleteIDPConfig(ctx, "ldap", "", suite.adminClient)
suite.assert.Nil(err)
}
func (suite *IDPTestSuite) TestDeleteIDPConfigurationWithWrongType() {
ctx := context.Background()
_, err := deleteIDPConfig(ctx, "", "", suite.adminClient)
suite.assert.NotNil(err)
}
func (suite *IDPTestSuite) TestGetIDPConfigurationHandlerWithError() {
params, api := suite.initGetIDPConfigurationRequest()
response := api.IdpGetConfigurationHandler.Handle(params, &models.Principal{})
_, ok := response.(*idp.GetConfigurationDefault)
suite.assert.True(ok)
}
func (suite *IDPTestSuite) initGetIDPConfigurationRequest() (params idp.GetConfigurationParams, api operations.ConsoleAPI) {
registerIDPHandlers(&api)
params.HTTPRequest = &http.Request{}
params.Type = "ldap"
return params, api
}
func (suite *IDPTestSuite) TestGetIDPConfigurationWithoutError() {
ctx := context.Background()
res, err := getIDPConfiguration(ctx, "ldap", "", suite.adminClient)
suite.assert.NotNil(res)
suite.assert.Nil(err)
}
func (suite *IDPTestSuite) TestGetIDPConfigurationWithWrongType() {
ctx := context.Background()
res, err := getIDPConfiguration(ctx, "", "", suite.adminClient)
suite.assert.Nil(res)
suite.assert.NotNil(err)
}
func TestIDP(t *testing.T) {
suite.Run(t, new(IDPTestSuite))
}
func TestGetEntitiesResult(t *testing.T) {
assert := assert.New(t)
// mock minIO client
client := AdminClientMock{}
function := "getEntitiesResult()"
usersList := []string{"user1", "user2", "user3"}
policiesList := []string{"policy1", "policy2", "policy3"}
groupsList := []string{"group1", "group3", "group5"}
policyMap := []madmin.PolicyEntities{
{Policy: "testPolicy0", Groups: groupsList, Users: usersList},
{Policy: "testPolicy1", Groups: groupsList, Users: usersList},
}
usersMap := []madmin.UserPolicyEntities{
{User: "testUser0", Policies: policiesList},
{User: "testUser1", Policies: policiesList},
}
groupsMap := []madmin.GroupPolicyEntities{
{Group: "group0", Policies: policiesList},
{Group: "group1", Policies: policiesList},
}
// Test-1: getEntitiesResult list all information provided
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
mockResponse := madmin.PolicyEntitiesResult{
PolicyMappings: policyMap,
GroupMappings: groupsMap,
UserMappings: usersMap,
}
minioGetLDAPPolicyEntitiesMock = func(_ context.Context, _ madmin.PolicyEntitiesQuery) (madmin.PolicyEntitiesResult, error) {
return mockResponse, nil
}
entities, err := getEntitiesResult(ctx, client, usersList, groupsList, policiesList)
if err != nil {
t.Errorf("Failed on %s:, error occurred: %s", function, err.Error())
}
for i, groupIt := range entities.Groups {
assert.Equal(fmt.Sprintf("group%d", i), groupIt.Group)
for i, polItm := range groupIt.Policies {
assert.Equal(policiesList[i], polItm)
}
}
for i, usrIt := range entities.Users {
assert.Equal(fmt.Sprintf("testUser%d", i), usrIt.User)
for i, polItm := range usrIt.Policies {
assert.Equal(policiesList[i], polItm)
}
}
for i, policyIt := range entities.Policies {
assert.Equal(fmt.Sprintf("testPolicy%d", i), policyIt.Policy)
for i, userItm := range policyIt.Users {
assert.Equal(usersList[i], userItm)
}
for i, grItm := range policyIt.Groups {
assert.Equal(groupsList[i], grItm)
}
}
// Test-2: getEntitiesResult error is returned from getLDAPPolicyEntities()
minioGetLDAPPolicyEntitiesMock = func(_ context.Context, _ madmin.PolicyEntitiesQuery) (madmin.PolicyEntitiesResult, error) {
return madmin.PolicyEntitiesResult{}, errors.New("error")
}
_, err = getEntitiesResult(ctx, client, usersList, groupsList, policiesList)
if assert.Error(err) {
assert.Equal("error", err.Error())
}
}

1192
api/admin_info.go Normal file

File diff suppressed because it is too large Load Diff

152
api/admin_info_test.go Normal file
View File

@@ -0,0 +1,152 @@
// This file is part of MinIO Console Server
// Copyright (c) 2023 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package api
import (
"context"
"net/http"
"net/http/httptest"
"os"
"testing"
"github.com/minio/console/pkg/utils"
"github.com/minio/console/api/operations"
systemApi "github.com/minio/console/api/operations/system"
"github.com/minio/console/models"
"github.com/minio/madmin-go/v3"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/suite"
)
type AdminInfoTestSuite struct {
suite.Suite
assert *assert.Assertions
currentServer string
isServerSet bool
isPrometheusRequest bool
server *httptest.Server
adminClient AdminClientMock
}
func (suite *AdminInfoTestSuite) SetupSuite() {
suite.assert = assert.New(suite.T())
suite.adminClient = AdminClientMock{}
MinioServerInfoMock = func(_ context.Context) (madmin.InfoMessage, error) {
return madmin.InfoMessage{
Servers: []madmin.ServerProperties{{
Disks: []madmin.Disk{{}},
}},
Backend: madmin.ErasureBackend{Type: "mock"},
}, nil
}
}
func (suite *AdminInfoTestSuite) SetupTest() {
suite.server = httptest.NewServer(http.HandlerFunc(suite.serverHandler))
suite.currentServer, suite.isServerSet = os.LookupEnv(ConsoleMinIOServer)
os.Setenv(ConsoleMinIOServer, suite.server.URL)
}
func (suite *AdminInfoTestSuite) serverHandler(w http.ResponseWriter, _ *http.Request) {
if suite.isPrometheusRequest {
w.WriteHeader(200)
} else {
w.WriteHeader(400)
}
}
func (suite *AdminInfoTestSuite) TearDownSuite() {
}
func (suite *AdminInfoTestSuite) TearDownTest() {
if suite.isServerSet {
os.Setenv(ConsoleMinIOServer, suite.currentServer)
} else {
os.Unsetenv(ConsoleMinIOServer)
}
}
func (suite *AdminInfoTestSuite) TestRegisterAdminInfoHandlers() {
api := &operations.ConsoleAPI{}
suite.assertHandlersAreNil(api)
registerAdminInfoHandlers(api)
suite.assertHandlersAreNotNil(api)
}
func (suite *AdminInfoTestSuite) assertHandlersAreNil(api *operations.ConsoleAPI) {
suite.assert.Nil(api.SystemAdminInfoHandler)
suite.assert.Nil(api.SystemDashboardWidgetDetailsHandler)
}
func (suite *AdminInfoTestSuite) assertHandlersAreNotNil(api *operations.ConsoleAPI) {
suite.assert.NotNil(api.SystemAdminInfoHandler)
suite.assert.NotNil(api.SystemDashboardWidgetDetailsHandler)
}
func (suite *AdminInfoTestSuite) TestSystemAdminInfoHandlerWithError() {
params, api := suite.initSystemAdminInfoRequest()
response := api.SystemAdminInfoHandler.Handle(params, &models.Principal{})
_, ok := response.(*systemApi.AdminInfoDefault)
suite.assert.True(ok)
}
func (suite *AdminInfoTestSuite) initSystemAdminInfoRequest() (params systemApi.AdminInfoParams, api operations.ConsoleAPI) {
registerAdminInfoHandlers(&api)
params.HTTPRequest = &http.Request{}
defaultOnly := false
params.DefaultOnly = &defaultOnly
return params, api
}
func (suite *AdminInfoTestSuite) TestSystemDashboardWidgetDetailsHandlerWithError() {
params, api := suite.initSystemDashboardWidgetDetailsRequest()
response := api.SystemDashboardWidgetDetailsHandler.Handle(params, &models.Principal{})
_, ok := response.(*systemApi.DashboardWidgetDetailsDefault)
suite.assert.True(ok)
}
func (suite *AdminInfoTestSuite) initSystemDashboardWidgetDetailsRequest() (params systemApi.DashboardWidgetDetailsParams, api operations.ConsoleAPI) {
registerAdminInfoHandlers(&api)
params.HTTPRequest = &http.Request{}
return params, api
}
func (suite *AdminInfoTestSuite) TestGetUsageWidgetsForDeploymentWithoutError() {
ctx := context.WithValue(context.Background(), utils.ContextClientIP, "127.0.0.1")
suite.isPrometheusRequest = true
res, err := getUsageWidgetsForDeployment(ctx, suite.server.URL, suite.adminClient)
suite.assert.Nil(err)
suite.assert.NotNil(res)
suite.isPrometheusRequest = false
}
func (suite *AdminInfoTestSuite) TestGetWidgetDetailsWithoutError() {
ctx := context.WithValue(context.Background(), utils.ContextClientIP, "127.0.0.1")
suite.isPrometheusRequest = true
var step int32 = 1
var start int64
var end int64 = 1
res, err := getWidgetDetails(ctx, suite.server.URL, "mock", 1, &step, &start, &end)
suite.assert.Nil(err)
suite.assert.NotNil(res)
suite.isPrometheusRequest = false
}
func TestAdminInfo(t *testing.T) {
suite.Run(t, new(AdminInfoTestSuite))
}

117
api/admin_inspect.go Normal file
View File

@@ -0,0 +1,117 @@
// This file is part of MinIO Console Server
// Copyright (c) 2022 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package api
import (
"encoding/base64"
"fmt"
"io"
"net/http"
"strings"
"github.com/go-openapi/runtime"
"github.com/go-openapi/runtime/middleware"
"github.com/minio/console/api/operations"
inspectApi "github.com/minio/console/api/operations/inspect"
"github.com/minio/console/models"
"github.com/minio/madmin-go/v3"
"github.com/secure-io/sio-go"
)
func registerInspectHandler(api *operations.ConsoleAPI) {
api.InspectInspectHandler = inspectApi.InspectHandlerFunc(func(params inspectApi.InspectParams, principal *models.Principal) middleware.Responder {
k, r, err := getInspectResult(principal, &params)
if err != nil {
return inspectApi.NewInspectDefault(err.Code).WithPayload(err.APIError)
}
return middleware.ResponderFunc(processInspectResponse(&params, k, r))
})
}
func getInspectResult(session *models.Principal, params *inspectApi.InspectParams) ([]byte, io.ReadCloser, *CodedAPIError) {
ctx := params.HTTPRequest.Context()
mAdmin, err := NewMinioAdminClient(params.HTTPRequest.Context(), session)
if err != nil {
return nil, nil, ErrorWithContext(ctx, err)
}
cfg := madmin.InspectOptions{
File: params.File,
Volume: params.Volume,
}
// TODO: Remove encryption option and always encrypt.
// Maybe also add public key field.
if params.Encrypt != nil && *params.Encrypt {
cfg.PublicKey, _ = base64.StdEncoding.DecodeString("MIIBCgKCAQEAs/128UFS9A8YSJY1XqYKt06dLVQQCGDee69T+0Tip/1jGAB4z0/3QMpH0MiS8Wjs4BRWV51qvkfAHzwwdU7y6jxU05ctb/H/WzRj3FYdhhHKdzear9TLJftlTs+xwj2XaADjbLXCV1jGLS889A7f7z5DgABlVZMQd9BjVAR8ED3xRJ2/ZCNuQVJ+A8r7TYPGMY3wWvhhPgPk3Lx4WDZxDiDNlFs4GQSaESSsiVTb9vyGe/94CsCTM6Cw9QG6ifHKCa/rFszPYdKCabAfHcS3eTr0GM+TThSsxO7KfuscbmLJkfQev1srfL2Ii2RbnysqIJVWKEwdW05ID8ryPkuTuwIDAQAB")
}
// create a MinIO Admin Client interface implementation
// defining the client to be used
adminClient := AdminClient{Client: mAdmin}
k, r, err := adminClient.inspect(ctx, cfg)
if err != nil {
return nil, nil, ErrorWithContext(ctx, err)
}
return k, r, nil
}
// borrowed from mc cli
func decryptInspectV1(key [32]byte, r io.Reader) io.ReadCloser {
stream, err := sio.AES_256_GCM.Stream(key[:])
if err != nil {
return nil
}
nonce := make([]byte, stream.NonceSize())
return io.NopCloser(stream.DecryptReader(r, nonce, nil))
}
func processInspectResponse(params *inspectApi.InspectParams, k []byte, r io.ReadCloser) func(w http.ResponseWriter, _ runtime.Producer) {
isEnc := params.Encrypt != nil && *params.Encrypt
return func(w http.ResponseWriter, _ runtime.Producer) {
ext := "enc"
if len(k) == 32 && !isEnc {
ext = "zip"
r = decryptInspectV1(*(*[32]byte)(k), r)
}
fileName := fmt.Sprintf("inspect-%s-%s.%s", params.Volume, params.File, ext)
fileName = strings.Map(func(r rune) rune {
switch {
case r >= 'A' && r <= 'Z':
return r
case r >= 'a' && r <= 'z':
return r
case r >= '0' && r <= '9':
return r
default:
if strings.ContainsAny(string(r), "-+._") {
return r
}
return '_'
}
}, fileName)
w.Header().Set("Content-Type", "application/octet-stream")
w.Header().Set("Content-Disposition", fmt.Sprintf("attachment; filename=\"%s\"", fileName))
_, err := io.Copy(w, r)
if err != nil {
LogError("unable to write all the data: %v", err)
}
}
}

291
api/admin_kms.go Normal file
View File

@@ -0,0 +1,291 @@
// This file is part of MinIO Console Server
// Copyright (c) 2022 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
package api
import (
"context"
"sort"
"github.com/go-openapi/runtime/middleware"
"github.com/minio/console/api/operations"
kmsAPI "github.com/minio/console/api/operations/k_m_s"
"github.com/minio/console/models"
"github.com/minio/madmin-go/v3"
)
func registerKMSHandlers(api *operations.ConsoleAPI) {
registerKMSStatusHandlers(api)
registerKMSKeyHandlers(api)
}
func registerKMSStatusHandlers(api *operations.ConsoleAPI) {
api.KmsKMSStatusHandler = kmsAPI.KMSStatusHandlerFunc(func(params kmsAPI.KMSStatusParams, session *models.Principal) middleware.Responder {
resp, err := GetKMSStatusResponse(session, params)
if err != nil {
return kmsAPI.NewKMSStatusDefault(err.Code).WithPayload(err.APIError)
}
return kmsAPI.NewKMSStatusOK().WithPayload(resp)
})
api.KmsKMSMetricsHandler = kmsAPI.KMSMetricsHandlerFunc(func(params kmsAPI.KMSMetricsParams, session *models.Principal) middleware.Responder {
resp, err := GetKMSMetricsResponse(session, params)
if err != nil {
return kmsAPI.NewKMSMetricsDefault(err.Code).WithPayload(err.APIError)
}
return kmsAPI.NewKMSMetricsOK().WithPayload(resp)
})
api.KmsKMSAPIsHandler = kmsAPI.KMSAPIsHandlerFunc(func(params kmsAPI.KMSAPIsParams, session *models.Principal) middleware.Responder {
resp, err := GetKMSAPIsResponse(session, params)
if err != nil {
return kmsAPI.NewKMSAPIsDefault(err.Code).WithPayload(err.APIError)
}
return kmsAPI.NewKMSAPIsOK().WithPayload(resp)
})
api.KmsKMSVersionHandler = kmsAPI.KMSVersionHandlerFunc(func(params kmsAPI.KMSVersionParams, session *models.Principal) middleware.Responder {
resp, err := GetKMSVersionResponse(session, params)
if err != nil {
return kmsAPI.NewKMSVersionDefault(err.Code).WithPayload(err.APIError)
}
return kmsAPI.NewKMSVersionOK().WithPayload(resp)
})
}
func GetKMSStatusResponse(session *models.Principal, params kmsAPI.KMSStatusParams) (*models.KmsStatusResponse, *CodedAPIError) {
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
defer cancel()
mAdmin, err := NewMinioAdminClient(params.HTTPRequest.Context(), session)
if err != nil {
return nil, ErrorWithContext(ctx, err)
}
return kmsStatus(ctx, AdminClient{Client: mAdmin})
}
func kmsStatus(ctx context.Context, minioClient MinioAdmin) (*models.KmsStatusResponse, *CodedAPIError) {
st, err := minioClient.kmsStatus(ctx)
if err != nil {
return nil, ErrorWithContext(ctx, err)
}
return &models.KmsStatusResponse{
DefaultKeyID: st.DefaultKeyID,
Name: st.Name,
Endpoints: parseStatusEndpoints(st.Endpoints),
}, nil
}
func parseStatusEndpoints(endpoints map[string]madmin.ItemState) (kmsEndpoints []*models.KmsEndpoint) {
for key, value := range endpoints {
kmsEndpoints = append(kmsEndpoints, &models.KmsEndpoint{URL: key, Status: string(value)})
}
return kmsEndpoints
}
func GetKMSMetricsResponse(session *models.Principal, params kmsAPI.KMSMetricsParams) (*models.KmsMetricsResponse, *CodedAPIError) {
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
defer cancel()
mAdmin, err := NewMinioAdminClient(params.HTTPRequest.Context(), session)
if err != nil {
return nil, ErrorWithContext(ctx, err)
}
return kmsMetrics(ctx, AdminClient{Client: mAdmin})
}
func kmsMetrics(ctx context.Context, minioClient MinioAdmin) (*models.KmsMetricsResponse, *CodedAPIError) {
metrics, err := minioClient.kmsMetrics(ctx)
if err != nil {
return nil, ErrorWithContext(ctx, err)
}
return &models.KmsMetricsResponse{
RequestOK: &metrics.RequestOK,
RequestErr: &metrics.RequestErr,
RequestFail: &metrics.RequestFail,
RequestActive: &metrics.RequestActive,
AuditEvents: &metrics.AuditEvents,
ErrorEvents: &metrics.ErrorEvents,
LatencyHistogram: parseHistogram(metrics.LatencyHistogram),
Uptime: &metrics.UpTime,
Cpus: &metrics.CPUs,
UsableCPUs: &metrics.UsableCPUs,
Threads: &metrics.Threads,
HeapAlloc: &metrics.HeapAlloc,
HeapObjects: metrics.HeapObjects,
StackAlloc: &metrics.StackAlloc,
}, nil
}
func parseHistogram(histogram map[int64]int64) (records []*models.KmsLatencyHistogram) {
for duration, total := range histogram {
records = append(records, &models.KmsLatencyHistogram{Duration: duration, Total: total})
}
cp := func(i, j int) bool {
return records[i].Duration < records[j].Duration
}
sort.Slice(records, cp)
return records
}
func GetKMSAPIsResponse(session *models.Principal, params kmsAPI.KMSAPIsParams) (*models.KmsAPIsResponse, *CodedAPIError) {
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
defer cancel()
mAdmin, err := NewMinioAdminClient(params.HTTPRequest.Context(), session)
if err != nil {
return nil, ErrorWithContext(ctx, err)
}
return kmsAPIs(ctx, AdminClient{Client: mAdmin})
}
func kmsAPIs(ctx context.Context, minioClient MinioAdmin) (*models.KmsAPIsResponse, *CodedAPIError) {
apis, err := minioClient.kmsAPIs(ctx)
if err != nil {
return nil, ErrorWithContext(ctx, err)
}
return &models.KmsAPIsResponse{
Results: parseApis(apis),
}, nil
}
func parseApis(apis []madmin.KMSAPI) (data []*models.KmsAPI) {
for _, api := range apis {
data = append(data, &models.KmsAPI{
Method: api.Method,
Path: api.Path,
MaxBody: api.MaxBody,
Timeout: api.Timeout,
})
}
return data
}
func GetKMSVersionResponse(session *models.Principal, params kmsAPI.KMSVersionParams) (*models.KmsVersionResponse, *CodedAPIError) {
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
defer cancel()
mAdmin, err := NewMinioAdminClient(params.HTTPRequest.Context(), session)
if err != nil {
return nil, ErrorWithContext(ctx, err)
}
return kmsVersion(ctx, AdminClient{Client: mAdmin})
}
func kmsVersion(ctx context.Context, minioClient MinioAdmin) (*models.KmsVersionResponse, *CodedAPIError) {
version, err := minioClient.kmsVersion(ctx)
if err != nil {
return nil, ErrorWithContext(ctx, err)
}
return &models.KmsVersionResponse{
Version: version.Version,
}, nil
}
func registerKMSKeyHandlers(api *operations.ConsoleAPI) {
api.KmsKMSCreateKeyHandler = kmsAPI.KMSCreateKeyHandlerFunc(func(params kmsAPI.KMSCreateKeyParams, session *models.Principal) middleware.Responder {
err := GetKMSCreateKeyResponse(session, params)
if err != nil {
return kmsAPI.NewKMSCreateKeyDefault(err.Code).WithPayload(err.APIError)
}
return kmsAPI.NewKMSCreateKeyCreated()
})
api.KmsKMSListKeysHandler = kmsAPI.KMSListKeysHandlerFunc(func(params kmsAPI.KMSListKeysParams, session *models.Principal) middleware.Responder {
resp, err := GetKMSListKeysResponse(session, params)
if err != nil {
return kmsAPI.NewKMSListKeysDefault(err.Code).WithPayload(err.APIError)
}
return kmsAPI.NewKMSListKeysOK().WithPayload(resp)
})
api.KmsKMSKeyStatusHandler = kmsAPI.KMSKeyStatusHandlerFunc(func(params kmsAPI.KMSKeyStatusParams, session *models.Principal) middleware.Responder {
resp, err := GetKMSKeyStatusResponse(session, params)
if err != nil {
return kmsAPI.NewKMSKeyStatusDefault(err.Code).WithPayload(err.APIError)
}
return kmsAPI.NewKMSKeyStatusOK().WithPayload(resp)
})
}
func GetKMSCreateKeyResponse(session *models.Principal, params kmsAPI.KMSCreateKeyParams) *CodedAPIError {
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
defer cancel()
mAdmin, err := NewMinioAdminClient(params.HTTPRequest.Context(), session)
if err != nil {
return ErrorWithContext(ctx, err)
}
return createKey(ctx, *params.Body.Key, AdminClient{Client: mAdmin})
}
func createKey(ctx context.Context, key string, minioClient MinioAdmin) *CodedAPIError {
if err := minioClient.createKey(ctx, key); err != nil {
return ErrorWithContext(ctx, err)
}
return nil
}
func GetKMSListKeysResponse(session *models.Principal, params kmsAPI.KMSListKeysParams) (*models.KmsListKeysResponse, *CodedAPIError) {
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
defer cancel()
mAdmin, err := NewMinioAdminClient(params.HTTPRequest.Context(), session)
if err != nil {
return nil, ErrorWithContext(ctx, err)
}
pattern := ""
if params.Pattern != nil {
pattern = *params.Pattern
}
return listKeys(ctx, pattern, AdminClient{Client: mAdmin})
}
func listKeys(ctx context.Context, pattern string, minioClient MinioAdmin) (*models.KmsListKeysResponse, *CodedAPIError) {
results, err := minioClient.listKeys(ctx, pattern)
if err != nil {
return nil, ErrorWithContext(ctx, err)
}
return &models.KmsListKeysResponse{Results: parseKeys(results)}, nil
}
func parseKeys(results []madmin.KMSKeyInfo) (data []*models.KmsKeyInfo) {
for _, key := range results {
data = append(data, &models.KmsKeyInfo{
CreatedAt: key.CreatedAt,
CreatedBy: key.CreatedBy,
Name: key.Name,
})
}
return data
}
func GetKMSKeyStatusResponse(session *models.Principal, params kmsAPI.KMSKeyStatusParams) (*models.KmsKeyStatusResponse, *CodedAPIError) {
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
defer cancel()
mAdmin, err := NewMinioAdminClient(params.HTTPRequest.Context(), session)
if err != nil {
return nil, ErrorWithContext(ctx, err)
}
return keyStatus(ctx, params.Name, AdminClient{Client: mAdmin})
}
func keyStatus(ctx context.Context, key string, minioClient MinioAdmin) (*models.KmsKeyStatusResponse, *CodedAPIError) {
ks, err := minioClient.keyStatus(ctx, key)
if err != nil {
return nil, ErrorWithContext(ctx, err)
}
return &models.KmsKeyStatusResponse{
KeyID: ks.KeyID,
EncryptionErr: ks.EncryptionErr,
DecryptionErr: ks.DecryptionErr,
}, nil
}

238
api/admin_kms_test.go Normal file
View File

@@ -0,0 +1,238 @@
// This file is part of MinIO Console Server
// Copyright (c) 2022 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package api
import (
"context"
"net/http"
"net/http/httptest"
"os"
"testing"
"github.com/minio/console/api/operations"
kmsAPI "github.com/minio/console/api/operations/k_m_s"
"github.com/minio/console/models"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/suite"
)
type KMSTestSuite struct {
suite.Suite
assert *assert.Assertions
currentServer string
isServerSet bool
server *httptest.Server
adminClient AdminClientMock
}
func (suite *KMSTestSuite) SetupSuite() {
suite.assert = assert.New(suite.T())
suite.adminClient = AdminClientMock{}
}
func (suite *KMSTestSuite) SetupTest() {
suite.server = httptest.NewServer(http.HandlerFunc(suite.serverHandler))
suite.currentServer, suite.isServerSet = os.LookupEnv(ConsoleMinIOServer)
os.Setenv(ConsoleMinIOServer, suite.server.URL)
}
func (suite *KMSTestSuite) serverHandler(w http.ResponseWriter, _ *http.Request) {
w.WriteHeader(400)
}
func (suite *KMSTestSuite) TearDownSuite() {
}
func (suite *KMSTestSuite) TearDownTest() {
if suite.isServerSet {
os.Setenv(ConsoleMinIOServer, suite.currentServer)
} else {
os.Unsetenv(ConsoleMinIOServer)
}
}
func (suite *KMSTestSuite) TestRegisterKMSHandlers() {
api := &operations.ConsoleAPI{}
suite.assertHandlersAreNil(api)
registerKMSHandlers(api)
suite.assertHandlersAreNotNil(api)
}
func (suite *KMSTestSuite) assertHandlersAreNil(api *operations.ConsoleAPI) {
suite.assert.Nil(api.KmsKMSStatusHandler)
suite.assert.Nil(api.KmsKMSMetricsHandler)
suite.assert.Nil(api.KmsKMSAPIsHandler)
suite.assert.Nil(api.KmsKMSVersionHandler)
suite.assert.Nil(api.KmsKMSCreateKeyHandler)
suite.assert.Nil(api.KmsKMSListKeysHandler)
suite.assert.Nil(api.KmsKMSKeyStatusHandler)
}
func (suite *KMSTestSuite) assertHandlersAreNotNil(api *operations.ConsoleAPI) {
suite.assert.NotNil(api.KmsKMSStatusHandler)
suite.assert.NotNil(api.KmsKMSMetricsHandler)
suite.assert.NotNil(api.KmsKMSAPIsHandler)
suite.assert.NotNil(api.KmsKMSVersionHandler)
suite.assert.NotNil(api.KmsKMSCreateKeyHandler)
suite.assert.NotNil(api.KmsKMSListKeysHandler)
suite.assert.NotNil(api.KmsKMSKeyStatusHandler)
}
func (suite *KMSTestSuite) TestKMSStatusHandlerWithError() {
params, api := suite.initKMSStatusRequest()
response := api.KmsKMSStatusHandler.Handle(params, &models.Principal{})
_, ok := response.(*kmsAPI.KMSStatusDefault)
suite.assert.True(ok)
}
func (suite *KMSTestSuite) initKMSStatusRequest() (params kmsAPI.KMSStatusParams, api operations.ConsoleAPI) {
registerKMSHandlers(&api)
params.HTTPRequest = &http.Request{}
return params, api
}
func (suite *KMSTestSuite) TestKMSStatusWithoutError() {
ctx := context.Background()
res, err := kmsStatus(ctx, suite.adminClient)
suite.assert.NotNil(res)
suite.assert.Nil(err)
}
func (suite *KMSTestSuite) TestKMSMetricsHandlerWithError() {
params, api := suite.initKMSMetricsRequest()
response := api.KmsKMSMetricsHandler.Handle(params, &models.Principal{})
_, ok := response.(*kmsAPI.KMSMetricsDefault)
suite.assert.True(ok)
}
func (suite *KMSTestSuite) initKMSMetricsRequest() (params kmsAPI.KMSMetricsParams, api operations.ConsoleAPI) {
registerKMSHandlers(&api)
params.HTTPRequest = &http.Request{}
return params, api
}
func (suite *KMSTestSuite) TestKMSMetricsWithoutError() {
ctx := context.Background()
res, err := kmsMetrics(ctx, suite.adminClient)
suite.assert.NotNil(res)
suite.assert.Nil(err)
}
func (suite *KMSTestSuite) TestKMSAPIsHandlerWithError() {
params, api := suite.initKMSAPIsRequest()
response := api.KmsKMSAPIsHandler.Handle(params, &models.Principal{})
_, ok := response.(*kmsAPI.KMSAPIsDefault)
suite.assert.True(ok)
}
func (suite *KMSTestSuite) initKMSAPIsRequest() (params kmsAPI.KMSAPIsParams, api operations.ConsoleAPI) {
registerKMSHandlers(&api)
params.HTTPRequest = &http.Request{}
return params, api
}
func (suite *KMSTestSuite) TestKMSAPIsWithoutError() {
ctx := context.Background()
res, err := kmsAPIs(ctx, suite.adminClient)
suite.assert.NotNil(res)
suite.assert.Nil(err)
}
func (suite *KMSTestSuite) TestKMSVersionHandlerWithError() {
params, api := suite.initKMSVersionRequest()
response := api.KmsKMSVersionHandler.Handle(params, &models.Principal{})
_, ok := response.(*kmsAPI.KMSVersionDefault)
suite.assert.True(ok)
}
func (suite *KMSTestSuite) initKMSVersionRequest() (params kmsAPI.KMSVersionParams, api operations.ConsoleAPI) {
registerKMSHandlers(&api)
params.HTTPRequest = &http.Request{}
return params, api
}
func (suite *KMSTestSuite) TestKMSVersionWithoutError() {
ctx := context.Background()
res, err := kmsVersion(ctx, suite.adminClient)
suite.assert.NotNil(res)
suite.assert.Nil(err)
}
func (suite *KMSTestSuite) TestKMSCreateKeyHandlerWithError() {
params, api := suite.initKMSCreateKeyRequest()
response := api.KmsKMSCreateKeyHandler.Handle(params, &models.Principal{})
_, ok := response.(*kmsAPI.KMSCreateKeyDefault)
suite.assert.True(ok)
}
func (suite *KMSTestSuite) initKMSCreateKeyRequest() (params kmsAPI.KMSCreateKeyParams, api operations.ConsoleAPI) {
registerKMSHandlers(&api)
params.HTTPRequest = &http.Request{}
key := "key"
params.Body = &models.KmsCreateKeyRequest{Key: &key}
return params, api
}
func (suite *KMSTestSuite) TestKMSCreateKeyWithoutError() {
ctx := context.Background()
err := createKey(ctx, "key", suite.adminClient)
suite.assert.Nil(err)
}
func (suite *KMSTestSuite) TestKMSListKeysHandlerWithError() {
params, api := suite.initKMSListKeysRequest()
response := api.KmsKMSListKeysHandler.Handle(params, &models.Principal{})
_, ok := response.(*kmsAPI.KMSListKeysDefault)
suite.assert.True(ok)
}
func (suite *KMSTestSuite) initKMSListKeysRequest() (params kmsAPI.KMSListKeysParams, api operations.ConsoleAPI) {
registerKMSHandlers(&api)
params.HTTPRequest = &http.Request{}
return params, api
}
func (suite *KMSTestSuite) TestKMSListKeysWithoutError() {
ctx := context.Background()
res, err := listKeys(ctx, "", suite.adminClient)
suite.assert.NotNil(res)
suite.assert.Nil(err)
}
func (suite *KMSTestSuite) TestKMSKeyStatusHandlerWithError() {
params, api := suite.initKMSKeyStatusRequest()
response := api.KmsKMSKeyStatusHandler.Handle(params, &models.Principal{})
_, ok := response.(*kmsAPI.KMSKeyStatusDefault)
suite.assert.True(ok)
}
func (suite *KMSTestSuite) initKMSKeyStatusRequest() (params kmsAPI.KMSKeyStatusParams, api operations.ConsoleAPI) {
registerKMSHandlers(&api)
params.HTTPRequest = &http.Request{}
return params, api
}
func (suite *KMSTestSuite) TestKMSKeyStatusWithoutError() {
ctx := context.Background()
res, err := keyStatus(ctx, "key", suite.adminClient)
suite.assert.NotNil(res)
suite.assert.Nil(err)
}
func TestKMS(t *testing.T) {
suite.Run(t, new(KMSTestSuite))
}

55
api/admin_nodes.go Normal file
View File

@@ -0,0 +1,55 @@
// This file is part of MinIO Console Server
// Copyright (c) 2022 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package api
import (
"context"
"github.com/go-openapi/runtime/middleware"
"github.com/minio/console/api/operations"
systemApi "github.com/minio/console/api/operations/system"
"github.com/minio/console/models"
)
func registerNodesHandler(api *operations.ConsoleAPI) {
api.SystemListNodesHandler = systemApi.ListNodesHandlerFunc(func(params systemApi.ListNodesParams, session *models.Principal) middleware.Responder {
listNodesResponse, err := getListNodesResponse(session, params)
if err != nil {
return systemApi.NewListNodesDefault(err.Code).WithPayload(err.APIError)
}
return systemApi.NewListNodesOK().WithPayload(listNodesResponse)
})
}
// getListNodesResponse returns a list of available node endpoints .
func getListNodesResponse(session *models.Principal, params systemApi.ListNodesParams) ([]string, *CodedAPIError) {
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
defer cancel()
mAdmin, err := NewMinioAdminClient(params.HTTPRequest.Context(), session)
if err != nil {
return nil, ErrorWithContext(ctx, err)
}
var nodeList []string
adminResources, _ := mAdmin.ServerInfo(ctx)
for _, n := range adminResources.Servers {
nodeList = append(nodeList, n.Endpoint)
}
return nodeList, nil
}

View File

@@ -0,0 +1,162 @@
// This file is part of MinIO Console Server
// Copyright (c) 2021 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package api
import (
"context"
"errors"
"github.com/go-openapi/runtime/middleware"
"github.com/minio/console/api/operations"
configurationApi "github.com/minio/console/api/operations/configuration"
"github.com/minio/console/models"
)
func registerAdminNotificationEndpointsHandlers(api *operations.ConsoleAPI) {
// return a list of notification endpoints
api.ConfigurationNotificationEndpointListHandler = configurationApi.NotificationEndpointListHandlerFunc(func(params configurationApi.NotificationEndpointListParams, session *models.Principal) middleware.Responder {
notifEndpoints, err := getNotificationEndpointsResponse(session, params)
if err != nil {
return configurationApi.NewNotificationEndpointListDefault(err.Code).WithPayload(err.APIError)
}
return configurationApi.NewNotificationEndpointListOK().WithPayload(notifEndpoints)
})
// add a new notification endpoints
api.ConfigurationAddNotificationEndpointHandler = configurationApi.AddNotificationEndpointHandlerFunc(func(params configurationApi.AddNotificationEndpointParams, session *models.Principal) middleware.Responder {
notifEndpoints, err := getAddNotificationEndpointResponse(session, params)
if err != nil {
return configurationApi.NewAddNotificationEndpointDefault(err.Code).WithPayload(err.APIError)
}
return configurationApi.NewAddNotificationEndpointCreated().WithPayload(notifEndpoints)
})
}
// getNotificationEndpoints invokes admin info and returns a list of notification endpoints
func getNotificationEndpoints(ctx context.Context, client MinioAdmin) (*models.NotifEndpointResponse, error) {
serverInfo, err := client.serverInfo(ctx)
if err != nil {
return nil, err
}
var listEndpoints []*models.NotificationEndpointItem
for i := range serverInfo.Services.Notifications {
for service, endpointStatus := range serverInfo.Services.Notifications[i] {
for j := range endpointStatus {
for account, status := range endpointStatus[j] {
listEndpoints = append(listEndpoints, &models.NotificationEndpointItem{
Service: models.NofiticationService(service),
AccountID: account,
Status: status.Status,
})
}
}
}
}
// build response
return &models.NotifEndpointResponse{
NotificationEndpoints: listEndpoints,
}, nil
}
// getNotificationEndpointsResponse returns a list of notification endpoints in the instance
func getNotificationEndpointsResponse(session *models.Principal, params configurationApi.NotificationEndpointListParams) (*models.NotifEndpointResponse, *CodedAPIError) {
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
defer cancel()
mAdmin, err := NewMinioAdminClient(params.HTTPRequest.Context(), session)
if err != nil {
return nil, ErrorWithContext(ctx, err)
}
// create a minioClient interface implementation
// defining the client to be used
adminClient := AdminClient{Client: mAdmin}
// serialize output
notfEndpointResp, err := getNotificationEndpoints(ctx, adminClient)
if err != nil {
return nil, ErrorWithContext(ctx, err)
}
return notfEndpointResp, nil
}
func addNotificationEndpoint(ctx context.Context, client MinioAdmin, params *configurationApi.AddNotificationEndpointParams) (*models.SetNotificationEndpointResponse, error) {
configs := []*models.ConfigurationKV{}
var configName string
// we have different add validations for each service
switch *params.Body.Service {
case models.NofiticationServiceAmqp:
configName = "notify_amqp"
case models.NofiticationServiceMqtt:
configName = "notify_mqtt"
case models.NofiticationServiceElasticsearch:
configName = "notify_elasticsearch"
case models.NofiticationServiceRedis:
configName = "notify_redis"
case models.NofiticationServiceNats:
configName = "notify_nats"
case models.NofiticationServicePostgres:
configName = "notify_postgres"
case models.NofiticationServiceMysql:
configName = "notify_mysql"
case models.NofiticationServiceKafka:
configName = "notify_kafka"
case models.NofiticationServiceWebhook:
configName = "notify_webhook"
case models.NofiticationServiceNsq:
configName = "notify_nsq"
default:
return nil, errors.New("provided service is not supported")
}
// set all the config values if found on the param.Body.Properties
for k, val := range params.Body.Properties {
configs = append(configs, &models.ConfigurationKV{
Key: k,
Value: val,
})
}
needsRestart, err := setConfigWithARNAccountID(ctx, client, &configName, configs, *params.Body.AccountID)
if err != nil {
return nil, err
}
return &models.SetNotificationEndpointResponse{
AccountID: params.Body.AccountID,
Properties: params.Body.Properties,
Service: params.Body.Service,
Restart: needsRestart,
}, nil
}
// getNotificationEndpointsResponse returns a list of notification endpoints in the instance
func getAddNotificationEndpointResponse(session *models.Principal, params configurationApi.AddNotificationEndpointParams) (*models.SetNotificationEndpointResponse, *CodedAPIError) {
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
defer cancel()
mAdmin, err := NewMinioAdminClient(params.HTTPRequest.Context(), session)
if err != nil {
return nil, ErrorWithContext(ctx, err)
}
// create a minioClient interface implementation
// defining the client to be used
adminClient := AdminClient{Client: mAdmin}
// serialize output
notfEndpointResp, err := addNotificationEndpoint(ctx, adminClient, &params)
if err != nil {
return nil, ErrorWithContext(ctx, err)
}
return notfEndpointResp, nil
}

View File

@@ -14,7 +14,7 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package restapi
package api
import (
"context"
@@ -24,17 +24,17 @@ import (
"github.com/go-openapi/swag"
cfgApi "github.com/minio/console/api/operations/configuration"
"github.com/minio/console/models"
"github.com/minio/console/restapi/operations/admin_api"
)
func Test_addNotificationEndpoint(t *testing.T) {
client := adminClientMock{}
client := AdminClientMock{}
type args struct {
ctx context.Context
client MinioAdmin
params *admin_api.AddNotificationEndpointParams
params *cfgApi.AddNotificationEndpointParams
}
tests := []struct {
name string
@@ -48,7 +48,7 @@ func Test_addNotificationEndpoint(t *testing.T) {
args: args{
ctx: context.Background(),
client: client,
params: &admin_api.AddNotificationEndpointParams{
params: &cfgApi.AddNotificationEndpointParams{
HTTPRequest: nil,
Body: &models.NotificationEndpoint{
AccountID: swag.String("1"),
@@ -61,7 +61,7 @@ func Test_addNotificationEndpoint(t *testing.T) {
},
},
},
mockSetConfig: func(kv string) (restart bool, err error) {
mockSetConfig: func(_ string) (restart bool, err error) {
return false, nil
},
want: &models.SetNotificationEndpointResponse{
@@ -81,7 +81,7 @@ func Test_addNotificationEndpoint(t *testing.T) {
args: args{
ctx: context.Background(),
client: client,
params: &admin_api.AddNotificationEndpointParams{
params: &cfgApi.AddNotificationEndpointParams{
HTTPRequest: nil,
Body: &models.NotificationEndpoint{
AccountID: swag.String("1"),
@@ -94,7 +94,7 @@ func Test_addNotificationEndpoint(t *testing.T) {
},
},
},
mockSetConfig: func(kv string) (restart bool, err error) {
mockSetConfig: func(_ string) (restart bool, err error) {
return false, errors.New("error")
},
want: nil,
@@ -105,7 +105,7 @@ func Test_addNotificationEndpoint(t *testing.T) {
args: args{
ctx: context.Background(),
client: client,
params: &admin_api.AddNotificationEndpointParams{
params: &cfgApi.AddNotificationEndpointParams{
HTTPRequest: nil,
Body: &models.NotificationEndpoint{
AccountID: swag.String("1"),
@@ -118,7 +118,7 @@ func Test_addNotificationEndpoint(t *testing.T) {
},
},
},
mockSetConfig: func(kv string) (restart bool, err error) {
mockSetConfig: func(_ string) (restart bool, err error) {
return false, nil
},
want: &models.SetNotificationEndpointResponse{
@@ -138,7 +138,7 @@ func Test_addNotificationEndpoint(t *testing.T) {
args: args{
ctx: context.Background(),
client: client,
params: &admin_api.AddNotificationEndpointParams{
params: &cfgApi.AddNotificationEndpointParams{
HTTPRequest: nil,
Body: &models.NotificationEndpoint{
AccountID: swag.String("1"),
@@ -149,7 +149,7 @@ func Test_addNotificationEndpoint(t *testing.T) {
},
},
},
mockSetConfig: func(kv string) (restart bool, err error) {
mockSetConfig: func(_ string) (restart bool, err error) {
return false, nil
},
want: &models.SetNotificationEndpointResponse{
@@ -167,7 +167,7 @@ func Test_addNotificationEndpoint(t *testing.T) {
args: args{
ctx: context.Background(),
client: client,
params: &admin_api.AddNotificationEndpointParams{
params: &cfgApi.AddNotificationEndpointParams{
HTTPRequest: nil,
Body: &models.NotificationEndpoint{
AccountID: swag.String("1"),
@@ -178,7 +178,7 @@ func Test_addNotificationEndpoint(t *testing.T) {
},
},
},
mockSetConfig: func(kv string) (restart bool, err error) {
mockSetConfig: func(_ string) (restart bool, err error) {
return false, nil
},
want: &models.SetNotificationEndpointResponse{
@@ -196,7 +196,7 @@ func Test_addNotificationEndpoint(t *testing.T) {
args: args{
ctx: context.Background(),
client: client,
params: &admin_api.AddNotificationEndpointParams{
params: &cfgApi.AddNotificationEndpointParams{
HTTPRequest: nil,
Body: &models.NotificationEndpoint{
AccountID: swag.String("1"),
@@ -208,7 +208,7 @@ func Test_addNotificationEndpoint(t *testing.T) {
},
},
},
mockSetConfig: func(kv string) (restart bool, err error) {
mockSetConfig: func(_ string) (restart bool, err error) {
return false, nil
},
want: &models.SetNotificationEndpointResponse{
@@ -227,7 +227,7 @@ func Test_addNotificationEndpoint(t *testing.T) {
args: args{
ctx: context.Background(),
client: client,
params: &admin_api.AddNotificationEndpointParams{
params: &cfgApi.AddNotificationEndpointParams{
HTTPRequest: nil,
Body: &models.NotificationEndpoint{
AccountID: swag.String("1"),
@@ -240,7 +240,7 @@ func Test_addNotificationEndpoint(t *testing.T) {
},
},
},
mockSetConfig: func(kv string) (restart bool, err error) {
mockSetConfig: func(_ string) (restart bool, err error) {
return false, nil
},
want: &models.SetNotificationEndpointResponse{
@@ -260,7 +260,7 @@ func Test_addNotificationEndpoint(t *testing.T) {
args: args{
ctx: context.Background(),
client: client,
params: &admin_api.AddNotificationEndpointParams{
params: &cfgApi.AddNotificationEndpointParams{
HTTPRequest: nil,
Body: &models.NotificationEndpoint{
AccountID: swag.String("1"),
@@ -273,7 +273,7 @@ func Test_addNotificationEndpoint(t *testing.T) {
},
},
},
mockSetConfig: func(kv string) (restart bool, err error) {
mockSetConfig: func(_ string) (restart bool, err error) {
return false, nil
},
want: &models.SetNotificationEndpointResponse{
@@ -293,7 +293,7 @@ func Test_addNotificationEndpoint(t *testing.T) {
args: args{
ctx: context.Background(),
client: client,
params: &admin_api.AddNotificationEndpointParams{
params: &cfgApi.AddNotificationEndpointParams{
HTTPRequest: nil,
Body: &models.NotificationEndpoint{
AccountID: swag.String("1"),
@@ -305,7 +305,7 @@ func Test_addNotificationEndpoint(t *testing.T) {
},
},
},
mockSetConfig: func(kv string) (restart bool, err error) {
mockSetConfig: func(_ string) (restart bool, err error) {
return false, nil
},
want: &models.SetNotificationEndpointResponse{
@@ -324,7 +324,7 @@ func Test_addNotificationEndpoint(t *testing.T) {
args: args{
ctx: context.Background(),
client: client,
params: &admin_api.AddNotificationEndpointParams{
params: &cfgApi.AddNotificationEndpointParams{
HTTPRequest: nil,
Body: &models.NotificationEndpoint{
AccountID: swag.String("1"),
@@ -335,7 +335,7 @@ func Test_addNotificationEndpoint(t *testing.T) {
},
},
},
mockSetConfig: func(kv string) (restart bool, err error) {
mockSetConfig: func(_ string) (restart bool, err error) {
return false, nil
},
want: &models.SetNotificationEndpointResponse{
@@ -353,7 +353,7 @@ func Test_addNotificationEndpoint(t *testing.T) {
args: args{
ctx: context.Background(),
client: client,
params: &admin_api.AddNotificationEndpointParams{
params: &cfgApi.AddNotificationEndpointParams{
HTTPRequest: nil,
Body: &models.NotificationEndpoint{
AccountID: swag.String("1"),
@@ -365,7 +365,7 @@ func Test_addNotificationEndpoint(t *testing.T) {
},
},
},
mockSetConfig: func(kv string) (restart bool, err error) {
mockSetConfig: func(_ string) (restart bool, err error) {
return false, nil
},
want: &models.SetNotificationEndpointResponse{
@@ -384,7 +384,7 @@ func Test_addNotificationEndpoint(t *testing.T) {
args: args{
ctx: context.Background(),
client: client,
params: &admin_api.AddNotificationEndpointParams{
params: &cfgApi.AddNotificationEndpointParams{
HTTPRequest: nil,
Body: &models.NotificationEndpoint{
AccountID: swag.String("1"),
@@ -397,7 +397,7 @@ func Test_addNotificationEndpoint(t *testing.T) {
},
},
},
mockSetConfig: func(kv string) (restart bool, err error) {
mockSetConfig: func(_ string) (restart bool, err error) {
return false, errors.New("invalid config")
},
want: nil,
@@ -408,7 +408,7 @@ func Test_addNotificationEndpoint(t *testing.T) {
args: args{
ctx: context.Background(),
client: client,
params: &admin_api.AddNotificationEndpointParams{
params: &cfgApi.AddNotificationEndpointParams{
HTTPRequest: nil,
Body: &models.NotificationEndpoint{
AccountID: swag.String("1"),
@@ -421,7 +421,7 @@ func Test_addNotificationEndpoint(t *testing.T) {
},
},
},
mockSetConfig: func(kv string) (restart bool, err error) {
mockSetConfig: func(_ string) (restart bool, err error) {
return true, nil
},
want: &models.SetNotificationEndpointResponse{
@@ -438,7 +438,7 @@ func Test_addNotificationEndpoint(t *testing.T) {
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
t.Run(tt.name, func(_ *testing.T) {
// mock function response from setConfig()
minioSetConfigKVMock = tt.mockSetConfig
got, err := addNotificationEndpoint(tt.args.ctx, tt.args.client, tt.args.params)

90
api/admin_objects.go Normal file
View File

@@ -0,0 +1,90 @@
// This file is part of MinIO Console Server
// Copyright (c) 2022 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package api
import (
"context"
"time"
"github.com/minio/mc/cmd"
"github.com/minio/minio-go/v7"
)
type objectsListOpts struct {
BucketName string
Prefix string
Date time.Time
}
type ObjectsRequest struct {
Mode string `json:"mode,omitempty"`
BucketName string `json:"bucket_name"`
Prefix string `json:"prefix"`
Date string `json:"date"`
RequestID int64 `json:"request_id"`
}
type WSResponse struct {
RequestID int64 `json:"request_id,omitempty"`
Error *CodedAPIError `json:"error,omitempty"`
RequestEnd bool `json:"request_end,omitempty"`
Prefix string `json:"prefix,omitempty"`
BucketName string `json:"bucketName,omitempty"`
Data []ObjectResponse `json:"data,omitempty"`
}
type ObjectResponse struct {
Name string `json:"name,omitempty"`
LastModified string `json:"last_modified,omitempty"`
Size int64 `json:"size,omitempty"`
VersionID string `json:"version_id,omitempty"`
DeleteMarker bool `json:"delete_flag,omitempty"`
IsLatest bool `json:"is_latest,omitempty"`
}
func getObjectsOptionsFromReq(request ObjectsRequest) (*objectsListOpts, error) {
pOptions := objectsListOpts{
BucketName: request.BucketName,
Prefix: request.Prefix,
}
if request.Mode == "rewind" {
parsedDate, errDate := time.Parse(time.RFC3339, request.Date)
if errDate != nil {
return nil, errDate
}
pOptions.Date = parsedDate
}
return &pOptions, nil
}
func startObjectsListing(ctx context.Context, client MinioClient, objOpts *objectsListOpts) <-chan minio.ObjectInfo {
opts := minio.ListObjectsOptions{
Prefix: objOpts.Prefix,
}
return client.listObjects(ctx, objOpts.BucketName, opts)
}
func startRewindListing(ctx context.Context, client MCClient, objOpts *objectsListOpts) <-chan *cmd.ClientContent {
lsRewind := client.list(ctx, cmd.ListOptions{TimeRef: objOpts.Date, WithDeleteMarkers: true})
return lsRewind
}

236
api/admin_objects_test.go Normal file
View File

@@ -0,0 +1,236 @@
// This file is part of MinIO Console Server
// Copyright (c) 2022 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package api
import (
"context"
"testing"
"time"
mc "github.com/minio/mc/cmd"
"github.com/minio/minio-go/v7"
"github.com/stretchr/testify/assert"
)
func TestWSRewindObjects(t *testing.T) {
assert := assert.New(t)
client := s3ClientMock{}
tests := []struct {
name string
testOptions objectsListOpts
testMessages []*mc.ClientContent
}{
{
name: "Get list with multiple elements",
testOptions: objectsListOpts{
BucketName: "buckettest",
Prefix: "/",
Date: time.Now(),
},
testMessages: []*mc.ClientContent{
{
BucketName: "buckettest",
URL: mc.ClientURL{Path: "/file1.txt"},
},
{
BucketName: "buckettest",
URL: mc.ClientURL{Path: "/file2.txt"},
},
{
BucketName: "buckettest",
URL: mc.ClientURL{Path: "/path1"},
},
},
},
{
name: "Empty list of elements",
testOptions: objectsListOpts{
BucketName: "emptybucket",
Prefix: "/",
Date: time.Now(),
},
testMessages: []*mc.ClientContent{},
},
{
name: "Get list with one element",
testOptions: objectsListOpts{
BucketName: "buckettest",
Prefix: "/",
Date: time.Now(),
},
testMessages: []*mc.ClientContent{
{
BucketName: "buckettestsingle",
URL: mc.ClientURL{Path: "/file12.txt"},
},
},
},
{
name: "Get data from subpaths",
testOptions: objectsListOpts{
BucketName: "buckettest",
Prefix: "/path1/path2",
Date: time.Now(),
},
testMessages: []*mc.ClientContent{
{
BucketName: "buckettestsingle",
URL: mc.ClientURL{Path: "/path1/path2/file12.txt"},
},
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(_ *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
mcListMock = func(_ context.Context, _ mc.ListOptions) <-chan *mc.ClientContent {
ch := make(chan *mc.ClientContent)
go func() {
defer close(ch)
for _, m := range tt.testMessages {
ch <- m
}
}()
return ch
}
rewindList := startRewindListing(ctx, client, &tt.testOptions)
// check that the rewindList got the same number of data from Console.
totalItems := 0
for data := range rewindList {
// Compare elements as we are defining the channel responses
assert.Equal(tt.testMessages[totalItems].URL.Path, data.URL.Path)
totalItems++
}
assert.Equal(len(tt.testMessages), totalItems)
})
}
}
func TestWSListObjects(t *testing.T) {
assert := assert.New(t)
client := minioClientMock{}
tests := []struct {
name string
wantErr bool
testOptions objectsListOpts
testMessages []minio.ObjectInfo
}{
{
name: "Get list with multiple elements",
wantErr: false,
testOptions: objectsListOpts{
BucketName: "buckettest",
Prefix: "/",
},
testMessages: []minio.ObjectInfo{
{
Key: "/file1.txt",
Size: 500,
IsLatest: true,
LastModified: time.Now(),
},
{
Key: "/file2.txt",
Size: 500,
IsLatest: true,
LastModified: time.Now(),
},
{
Key: "/path1",
},
},
},
{
name: "Empty list of elements",
wantErr: false,
testOptions: objectsListOpts{
BucketName: "emptybucket",
Prefix: "/",
},
testMessages: []minio.ObjectInfo{},
},
{
name: "Get list with one element",
wantErr: false,
testOptions: objectsListOpts{
BucketName: "buckettest",
Prefix: "/",
},
testMessages: []minio.ObjectInfo{
{
Key: "/file2.txt",
Size: 500,
IsLatest: true,
LastModified: time.Now(),
},
},
},
{
name: "Get data from subpaths",
wantErr: false,
testOptions: objectsListOpts{
BucketName: "buckettest",
Prefix: "/path1/path2",
},
testMessages: []minio.ObjectInfo{
{
Key: "/path1/path2/file1.txt",
Size: 500,
IsLatest: true,
LastModified: time.Now(),
},
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(_ *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
minioListObjectsMock = func(_ context.Context, _ string, _ minio.ListObjectsOptions) <-chan minio.ObjectInfo {
ch := make(chan minio.ObjectInfo)
go func() {
defer close(ch)
for _, m := range tt.testMessages {
ch <- m
}
}()
return ch
}
objectsListing := startObjectsListing(ctx, client, &tt.testOptions)
// check that the TestReceiver got the same number of data from Console
totalItems := 0
for data := range objectsListing {
// Compare elements as we are defining the channel responses
assert.Equal(tt.testMessages[totalItems].Key, data.Key)
totalItems++
}
assert.Equal(len(tt.testMessages), totalItems)
})
}
}

698
api/admin_policies.go Normal file
View File

@@ -0,0 +1,698 @@
// This file is part of MinIO Console Server
// Copyright (c) 2021 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package api
import (
"bytes"
"context"
"encoding/json"
"fmt"
"sort"
"strings"
bucketApi "github.com/minio/console/api/operations/bucket"
policyApi "github.com/minio/console/api/operations/policy"
s3 "github.com/minio/minio-go/v7"
"github.com/go-openapi/runtime/middleware"
"github.com/minio/console/api/operations"
"github.com/minio/console/models"
iampolicy "github.com/minio/pkg/v3/policy"
policies "github.com/minio/console/api/policy"
)
func registersPoliciesHandler(api *operations.ConsoleAPI) {
// List Policies
api.PolicyListPoliciesHandler = policyApi.ListPoliciesHandlerFunc(func(params policyApi.ListPoliciesParams, session *models.Principal) middleware.Responder {
listPoliciesResponse, err := getListPoliciesResponse(session, params)
if err != nil {
return policyApi.NewListPoliciesDefault(err.Code).WithPayload(err.APIError)
}
return policyApi.NewListPoliciesOK().WithPayload(listPoliciesResponse)
})
// Policy Info
api.PolicyPolicyInfoHandler = policyApi.PolicyInfoHandlerFunc(func(params policyApi.PolicyInfoParams, session *models.Principal) middleware.Responder {
policyInfo, err := getPolicyInfoResponse(session, params)
if err != nil {
return policyApi.NewPolicyInfoDefault(err.Code).WithPayload(err.APIError)
}
return policyApi.NewPolicyInfoOK().WithPayload(policyInfo)
})
// Add Policy
api.PolicyAddPolicyHandler = policyApi.AddPolicyHandlerFunc(func(params policyApi.AddPolicyParams, session *models.Principal) middleware.Responder {
policyResponse, err := getAddPolicyResponse(session, params)
if err != nil {
return policyApi.NewAddPolicyDefault(err.Code).WithPayload(err.APIError)
}
return policyApi.NewAddPolicyCreated().WithPayload(policyResponse)
})
// Remove Policy
api.PolicyRemovePolicyHandler = policyApi.RemovePolicyHandlerFunc(func(params policyApi.RemovePolicyParams, session *models.Principal) middleware.Responder {
if err := getRemovePolicyResponse(session, params); err != nil {
return policyApi.NewRemovePolicyDefault(err.Code).WithPayload(err.APIError)
}
return policyApi.NewRemovePolicyNoContent()
})
// Set Policy
api.PolicySetPolicyHandler = policyApi.SetPolicyHandlerFunc(func(params policyApi.SetPolicyParams, session *models.Principal) middleware.Responder {
if err := getSetPolicyResponse(session, params); err != nil {
return policyApi.NewSetPolicyDefault(err.Code).WithPayload(err.APIError)
}
return policyApi.NewSetPolicyNoContent()
})
// Set Policy Multiple User/Groups
api.PolicySetPolicyMultipleHandler = policyApi.SetPolicyMultipleHandlerFunc(func(params policyApi.SetPolicyMultipleParams, session *models.Principal) middleware.Responder {
if err := getSetPolicyMultipleResponse(session, params); err != nil {
return policyApi.NewSetPolicyMultipleDefault(err.Code).WithPayload(err.APIError)
}
return policyApi.NewSetPolicyMultipleNoContent()
})
api.BucketListPoliciesWithBucketHandler = bucketApi.ListPoliciesWithBucketHandlerFunc(func(params bucketApi.ListPoliciesWithBucketParams, session *models.Principal) middleware.Responder {
policyResponse, err := getListPoliciesWithBucketResponse(session, params)
if err != nil {
return bucketApi.NewListPoliciesWithBucketDefault(err.Code).WithPayload(err.APIError)
}
return bucketApi.NewListPoliciesWithBucketOK().WithPayload(policyResponse)
})
api.BucketListAccessRulesWithBucketHandler = bucketApi.ListAccessRulesWithBucketHandlerFunc(func(params bucketApi.ListAccessRulesWithBucketParams, session *models.Principal) middleware.Responder {
policyResponse, err := getListAccessRulesWithBucketResponse(session, params)
if err != nil {
return bucketApi.NewListAccessRulesWithBucketDefault(err.Code).WithPayload(err.APIError)
}
return bucketApi.NewListAccessRulesWithBucketOK().WithPayload(policyResponse)
})
api.BucketSetAccessRuleWithBucketHandler = bucketApi.SetAccessRuleWithBucketHandlerFunc(func(params bucketApi.SetAccessRuleWithBucketParams, session *models.Principal) middleware.Responder {
policyResponse, err := getSetAccessRuleWithBucketResponse(session, params)
if err != nil {
return bucketApi.NewSetAccessRuleWithBucketDefault(err.Code).WithPayload(err.APIError)
}
return bucketApi.NewSetAccessRuleWithBucketOK().WithPayload(policyResponse)
})
api.BucketDeleteAccessRuleWithBucketHandler = bucketApi.DeleteAccessRuleWithBucketHandlerFunc(func(params bucketApi.DeleteAccessRuleWithBucketParams, session *models.Principal) middleware.Responder {
policyResponse, err := getDeleteAccessRuleWithBucketResponse(session, params)
if err != nil {
return bucketApi.NewDeleteAccessRuleWithBucketDefault(err.Code).WithPayload(err.APIError)
}
return bucketApi.NewDeleteAccessRuleWithBucketOK().WithPayload(policyResponse)
})
api.PolicyListUsersForPolicyHandler = policyApi.ListUsersForPolicyHandlerFunc(func(params policyApi.ListUsersForPolicyParams, session *models.Principal) middleware.Responder {
policyUsersResponse, err := getListUsersForPolicyResponse(session, params)
if err != nil {
return policyApi.NewListUsersForPolicyDefault(err.Code).WithPayload(err.APIError)
}
return policyApi.NewListUsersForPolicyOK().WithPayload(policyUsersResponse)
})
api.PolicyListGroupsForPolicyHandler = policyApi.ListGroupsForPolicyHandlerFunc(func(params policyApi.ListGroupsForPolicyParams, session *models.Principal) middleware.Responder {
policyGroupsResponse, err := getListGroupsForPolicyResponse(session, params)
if err != nil {
return policyApi.NewListGroupsForPolicyDefault(err.Code).WithPayload(err.APIError)
}
return policyApi.NewListGroupsForPolicyOK().WithPayload(policyGroupsResponse)
})
// Gets policies for currently logged in user
api.PolicyGetUserPolicyHandler = policyApi.GetUserPolicyHandlerFunc(func(params policyApi.GetUserPolicyParams, session *models.Principal) middleware.Responder {
userPolicyResponse, err := getUserPolicyResponse(params.HTTPRequest.Context(), session)
if err != nil {
return policyApi.NewGetUserPolicyDefault(err.Code).WithPayload(err.APIError)
}
return policyApi.NewGetUserPolicyOK().WithPayload(userPolicyResponse)
})
// Gets policies for specified user
api.PolicyGetSAUserPolicyHandler = policyApi.GetSAUserPolicyHandlerFunc(func(params policyApi.GetSAUserPolicyParams, session *models.Principal) middleware.Responder {
userPolicyResponse, err := getSAUserPolicyResponse(session, params)
if err != nil {
return policyApi.NewGetSAUserPolicyDefault(err.Code).WithPayload(err.APIError)
}
return policyApi.NewGetSAUserPolicyOK().WithPayload(userPolicyResponse)
})
}
func getListAccessRulesWithBucketResponse(session *models.Principal, params bucketApi.ListAccessRulesWithBucketParams) (*models.ListAccessRulesResponse, *CodedAPIError) {
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
defer cancel()
bucket := params.Bucket
client, err := newS3BucketClient(session, bucket, "", getClientIP(params.HTTPRequest))
if err != nil {
return nil, ErrorWithContext(ctx, err)
}
accessRules, _ := client.GetAccessRules(ctx)
var accessRuleList []*models.AccessRule
for k, v := range accessRules {
accessRuleList = append(accessRuleList, &models.AccessRule{Prefix: k[len(bucket)+1 : len(k)-1], Access: v})
}
return &models.ListAccessRulesResponse{AccessRules: accessRuleList}, nil
}
func getSetAccessRuleWithBucketResponse(session *models.Principal, params bucketApi.SetAccessRuleWithBucketParams) (bool, *CodedAPIError) {
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
defer cancel()
prefixAccess := params.Prefixaccess
client, err := newS3BucketClient(session, params.Bucket, prefixAccess.Prefix, getClientIP(params.HTTPRequest))
if err != nil {
return false, ErrorWithContext(ctx, err)
}
errorVal := client.SetAccess(ctx, prefixAccess.Access, false)
if errorVal != nil {
returnError := ErrorWithContext(ctx, errorVal.Cause)
minioError := s3.ToErrorResponse(errorVal.Cause)
if minioError.Code == "NoSuchBucket" {
returnError.Code = 404
}
return false, returnError
}
return true, nil
}
func getDeleteAccessRuleWithBucketResponse(session *models.Principal, params bucketApi.DeleteAccessRuleWithBucketParams) (bool, *CodedAPIError) {
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
defer cancel()
bucket := params.Bucket
prefix := params.Prefix
client, err := newS3BucketClient(session, bucket, prefix.Prefix, getClientIP(params.HTTPRequest))
if err != nil {
return false, ErrorWithContext(ctx, err)
}
errorVal := client.SetAccess(ctx, "none", false)
if errorVal != nil {
return false, ErrorWithContext(ctx, errorVal.Cause)
}
return true, nil
}
func getListPoliciesWithBucketResponse(session *models.Principal, params bucketApi.ListPoliciesWithBucketParams) (*models.ListPoliciesResponse, *CodedAPIError) {
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
defer cancel()
mAdmin, err := NewMinioAdminClient(params.HTTPRequest.Context(), session)
if err != nil {
return nil, ErrorWithContext(ctx, err)
}
// create a MinIO Admin Client interface implementation
// defining the client to be used
adminClient := AdminClient{Client: mAdmin}
policies, err := listPoliciesWithBucket(ctx, params.Bucket, adminClient)
if err != nil {
return nil, ErrorWithContext(ctx, err)
}
// serialize output
listPoliciesResponse := &models.ListPoliciesResponse{
Policies: policies,
Total: int64(len(policies)),
}
return listPoliciesResponse, nil
}
// listPoliciesWithBucket calls MinIO server to list all policy names present on the server that apply to a particular bucket.
// listPoliciesWithBucket() converts the map[string][]byte returned by client.listPolicies()
// to []*models.Policy by iterating over each key in policyRawMap and
// then using Unmarshal on the raw bytes to create a *models.Policy
func listPoliciesWithBucket(ctx context.Context, bucket string, client MinioAdmin) ([]*models.Policy, error) {
policyMap, err := client.listPolicies(ctx)
var policies []*models.Policy
if err != nil {
return nil, err
}
for name, policy := range policyMap {
policy, err := parsePolicy(name, policy)
if err != nil {
return nil, err
}
if policyMatchesBucket(ctx, policy, bucket) {
policies = append(policies, policy)
}
}
return policies, nil
}
func policyMatchesBucket(ctx context.Context, policy *models.Policy, bucket string) bool {
policyData := &iampolicy.Policy{}
err := json.Unmarshal([]byte(policy.Policy), policyData)
if err != nil {
ErrorWithContext(ctx, fmt.Errorf("error parsing policy: %v", err))
return false
}
policyStatements := policyData.Statements
for i := 0; i < len(policyStatements); i++ {
resources := policyStatements[i].Resources
if resources.Match(bucket, map[string][]string{}) {
return true
}
if resources.Match(fmt.Sprintf("%s/*", bucket), map[string][]string{}) {
return true
}
}
return false
}
// listPolicies calls MinIO server to list all policy names present on the server.
// listPolicies() converts the map[string][]byte returned by client.listPolicies()
// to []*models.Policy by iterating over each key in policyRawMap and
// then using Unmarshal on the raw bytes to create a *models.Policy
func listPolicies(ctx context.Context, client MinioAdmin) ([]*models.Policy, error) {
policyMap, err := client.listPolicies(ctx)
var policies []*models.Policy
if err != nil {
return nil, err
}
for name, policy := range policyMap {
policy, err := parsePolicy(name, policy)
if err != nil {
return nil, err
}
policies = append(policies, policy)
}
return policies, nil
}
// getListPoliciesResponse performs listPolicies() and serializes it to the handler's output
func getListPoliciesResponse(session *models.Principal, params policyApi.ListPoliciesParams) (*models.ListPoliciesResponse, *CodedAPIError) {
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
defer cancel()
mAdmin, err := NewMinioAdminClient(params.HTTPRequest.Context(), session)
if err != nil {
return nil, ErrorWithContext(ctx, err)
}
// create a MinIO Admin Client interface implementation
// defining the client to be used
adminClient := AdminClient{Client: mAdmin}
policies, err := listPolicies(ctx, adminClient)
if err != nil {
return nil, ErrorWithContext(ctx, err)
}
// serialize output
listPoliciesResponse := &models.ListPoliciesResponse{
Policies: policies,
Total: int64(len(policies)),
}
return listPoliciesResponse, nil
}
// getListUsersForPoliciesResponse performs lists users affected by a given policy.
func getListUsersForPolicyResponse(session *models.Principal, params policyApi.ListUsersForPolicyParams) ([]string, *CodedAPIError) {
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
defer cancel()
mAdmin, err := NewMinioAdminClient(params.HTTPRequest.Context(), session)
if err != nil {
return nil, ErrorWithContext(ctx, err)
}
// create a minioClient interface implementation
// defining the client to be used
adminClient := AdminClient{Client: mAdmin}
policies, err := listPolicies(ctx, adminClient)
if err != nil {
return nil, ErrorWithContext(ctx, err)
}
found := false
for i := range policies {
if policies[i].Name == params.Policy {
found = true
}
}
if !found {
return nil, ErrorWithContext(ctx, ErrPolicyNotFound, fmt.Errorf("the policy %s does not exist", params.Policy))
}
users, err := listUsers(ctx, adminClient)
if err != nil {
return nil, ErrorWithContext(ctx, err)
}
var filteredUsers []string
for _, user := range users {
for _, upolicy := range user.Policy {
if upolicy == params.Policy {
filteredUsers = append(filteredUsers, user.AccessKey)
break
}
}
}
sort.Strings(filteredUsers)
return filteredUsers, nil
}
func getUserPolicyResponse(ctx context.Context, session *models.Principal) (string, *CodedAPIError) {
ctx, cancel := context.WithCancel(ctx)
defer cancel()
// serialize output
if session == nil {
return "nil", ErrorWithContext(ctx, ErrPolicyNotFound)
}
tokenClaims, _ := getClaimsFromToken(session.STSSessionToken)
// initialize admin client
mAdminClient, err := NewMinioAdminClient(ctx, &models.Principal{
STSAccessKeyID: session.STSAccessKeyID,
STSSecretAccessKey: session.STSSecretAccessKey,
STSSessionToken: session.STSSessionToken,
})
if err != nil {
return "nil", ErrorWithContext(ctx, err)
}
userAdminClient := AdminClient{Client: mAdminClient}
// Obtain the current policy assigned to this user
// necessary for generating the list of allowed endpoints
accountInfo, err := getAccountInfo(ctx, userAdminClient)
if err != nil {
return "nil", ErrorWithContext(ctx, err)
}
rawPolicy := policies.ReplacePolicyVariables(tokenClaims, accountInfo)
return string(rawPolicy), nil
}
func getSAUserPolicyResponse(session *models.Principal, params policyApi.GetSAUserPolicyParams) (*models.AUserPolicyResponse, *CodedAPIError) {
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
defer cancel()
// serialize output
if session == nil {
return nil, ErrorWithContext(ctx, ErrPolicyNotFound)
}
// initialize admin client
mAdminClient, err := NewMinioAdminClient(params.HTTPRequest.Context(), &models.Principal{
STSAccessKeyID: session.STSAccessKeyID,
STSSecretAccessKey: session.STSSecretAccessKey,
STSSessionToken: session.STSSessionToken,
})
if err != nil {
return nil, ErrorWithContext(ctx, err)
}
userAdminClient := AdminClient{Client: mAdminClient}
user, err := getUserInfo(ctx, userAdminClient, params.Name)
if err != nil {
return nil, ErrorWithContext(ctx, err)
}
var userPolicies []string
if len(user.PolicyName) > 0 {
userPolicies = strings.Split(user.PolicyName, ",")
}
for _, group := range user.MemberOf {
groupDesc, err := groupInfo(ctx, userAdminClient, group)
if err != nil {
return nil, ErrorWithContext(ctx, err)
}
if groupDesc.Policy != "" {
userPolicies = append(userPolicies, strings.Split(groupDesc.Policy, ",")...)
}
}
allKeys := make(map[string]bool)
var userPolicyList []string
for _, item := range userPolicies {
if _, value := allKeys[item]; !value {
allKeys[item] = true
userPolicyList = append(userPolicyList, item)
}
}
var userStatements []iampolicy.Statement
for _, pol := range userPolicyList {
policy, err := getPolicyStatements(ctx, userAdminClient, pol)
if err != nil {
return nil, ErrorWithContext(ctx, err)
}
userStatements = append(userStatements, policy...)
}
combinedPolicy := iampolicy.Policy{
Version: "2012-10-17",
Statements: userStatements,
}
stringPolicy, err := json.Marshal(combinedPolicy)
if err != nil {
return nil, ErrorWithContext(ctx, err)
}
parsedPolicy := string(stringPolicy)
getUserPoliciesResponse := &models.AUserPolicyResponse{
Policy: parsedPolicy,
}
return getUserPoliciesResponse, nil
}
func getListGroupsForPolicyResponse(session *models.Principal, params policyApi.ListGroupsForPolicyParams) ([]string, *CodedAPIError) {
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
defer cancel()
mAdmin, err := NewMinioAdminClient(params.HTTPRequest.Context(), session)
if err != nil {
return nil, ErrorWithContext(ctx, err)
}
// create a minioClient interface implementation
// defining the client to be used
adminClient := AdminClient{Client: mAdmin}
policies, err := listPolicies(ctx, adminClient)
if err != nil {
return nil, ErrorWithContext(ctx, err)
}
found := false
for i := range policies {
if policies[i].Name == params.Policy {
found = true
}
}
if !found {
return nil, ErrorWithContext(ctx, ErrPolicyNotFound, fmt.Errorf("the policy %s does not exist", params.Policy))
}
groups, err := adminClient.listGroups(ctx)
if err != nil {
return nil, ErrorWithContext(ctx, err)
}
var filteredGroups []string
for _, group := range groups {
info, err := groupInfo(ctx, adminClient, group)
if err != nil {
return nil, ErrorWithContext(ctx, err)
}
groupPolicies := strings.Split(info.Policy, ",")
for _, groupPolicy := range groupPolicies {
if groupPolicy == params.Policy {
filteredGroups = append(filteredGroups, group)
}
}
}
sort.Strings(filteredGroups)
return filteredGroups, nil
}
// removePolicy() calls MinIO server to remove a policy based on name.
func removePolicy(ctx context.Context, client MinioAdmin, name string) error {
err := client.removePolicy(ctx, name)
if err != nil {
return err
}
return nil
}
// getRemovePolicyResponse() performs removePolicy() and serializes it to the handler's output
func getRemovePolicyResponse(session *models.Principal, params policyApi.RemovePolicyParams) *CodedAPIError {
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
defer cancel()
if params.Name == "" {
return ErrorWithContext(ctx, ErrPolicyNameNotInRequest)
}
mAdmin, err := NewMinioAdminClient(params.HTTPRequest.Context(), session)
if err != nil {
return ErrorWithContext(ctx, err)
}
// create a MinIO Admin Client interface implementation
// defining the client to be used
adminClient := AdminClient{Client: mAdmin}
if err := removePolicy(ctx, adminClient, params.Name); err != nil {
return ErrorWithContext(ctx, err)
}
return nil
}
// addPolicy calls MinIO server to add a canned policy.
// addPolicy() takes name and policy in string format, policy
// policy must be string in json format, in the future this will change
// to a Policy struct{} - https://github.com/minio/minio/issues/9171
func addPolicy(ctx context.Context, client MinioAdmin, name, policy string) (*models.Policy, error) {
iamp, err := iampolicy.ParseConfig(bytes.NewReader([]byte(policy)))
if err != nil {
return nil, err
}
if err := client.addPolicy(ctx, name, iamp); err != nil {
return nil, err
}
policyObject, err := policyInfo(ctx, client, name)
if err != nil {
return nil, err
}
return policyObject, nil
}
// getAddPolicyResponse performs addPolicy() and serializes it to the handler's output
func getAddPolicyResponse(session *models.Principal, params policyApi.AddPolicyParams) (*models.Policy, *CodedAPIError) {
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
defer cancel()
if params.Body == nil {
return nil, ErrorWithContext(ctx, ErrPolicyBodyNotInRequest)
}
if strings.Contains(*params.Body.Name, " ") {
return nil, ErrorWithContext(ctx, ErrPolicyNameContainsSpace)
}
mAdmin, err := NewMinioAdminClient(params.HTTPRequest.Context(), session)
if err != nil {
return nil, ErrorWithContext(ctx, err)
}
// create a MinIO Admin Client interface implementation
// defining the client to be used
adminClient := AdminClient{Client: mAdmin}
policy, err := addPolicy(ctx, adminClient, *params.Body.Name, *params.Body.Policy)
if err != nil {
return nil, ErrorWithContext(ctx, err)
}
return policy, nil
}
// policyInfo calls MinIO server to retrieve information of a canned policy.
// policyInfo() takes a policy name, obtains the []byte (represents a string in JSON format)
// and return it as *models.Policy , in the future this will change
// to a Policy struct{} - https://github.com/minio/minio/issues/9171
func policyInfo(ctx context.Context, client MinioAdmin, name string) (*models.Policy, error) {
policyRaw, err := client.getPolicy(ctx, name)
if err != nil {
return nil, err
}
policy, err := parsePolicy(name, policyRaw)
if err != nil {
return nil, err
}
return policy, nil
}
// getPolicy Statements calls MinIO server to retrieve information of a canned policy.
// and returns the associated Statements
func getPolicyStatements(ctx context.Context, client MinioAdmin, name string) ([]iampolicy.Statement, error) {
policyRaw, err := client.getPolicy(ctx, name)
if err != nil {
return nil, err
}
return policyRaw.Statements, nil
}
// getPolicyInfoResponse performs policyInfo() and serializes it to the handler's output
func getPolicyInfoResponse(session *models.Principal, params policyApi.PolicyInfoParams) (*models.Policy, *CodedAPIError) {
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
defer cancel()
mAdmin, err := NewMinioAdminClient(params.HTTPRequest.Context(), session)
if err != nil {
return nil, ErrorWithContext(ctx, err)
}
// create a MinIO Admin Client interface implementation
// defining the client to be used
adminClient := AdminClient{Client: mAdmin}
policy, err := policyInfo(ctx, adminClient, params.Name)
if err != nil {
return nil, ErrorWithContext(ctx, err)
}
return policy, nil
}
// SetPolicy calls MinIO server to assign policy to a group or user.
func SetPolicy(ctx context.Context, client MinioAdmin, name, entityName string, entityType models.PolicyEntity) error {
isGroup := false
if entityType == models.PolicyEntityGroup {
isGroup = true
}
return client.setPolicy(ctx, name, entityName, isGroup)
}
// getSetPolicyResponse() performs SetPolicy() and serializes it to the handler's output
func getSetPolicyResponse(session *models.Principal, params policyApi.SetPolicyParams) *CodedAPIError {
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
defer cancel()
// Removing this section
mAdmin, err := NewMinioAdminClient(params.HTTPRequest.Context(), session)
if err != nil {
return ErrorWithContext(ctx, err)
}
// create a MinIO Admin Client interface implementation
// defining the client to be used
adminClient := AdminClient{Client: mAdmin}
if err := SetPolicy(ctx, adminClient, strings.Join(params.Body.Name, ","), *params.Body.EntityName, *params.Body.EntityType); err != nil {
return ErrorWithContext(ctx, err)
}
return nil
}
func getSetPolicyMultipleResponse(session *models.Principal, params policyApi.SetPolicyMultipleParams) *CodedAPIError {
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
defer cancel()
mAdmin, err := NewMinioAdminClient(params.HTTPRequest.Context(), session)
if err != nil {
return ErrorWithContext(ctx, err)
}
// create a MinIO Admin Client interface implementation
// defining the client to be used
adminClient := AdminClient{Client: mAdmin}
if err := setPolicyMultipleEntities(ctx, adminClient, strings.Join(params.Body.Name, ","), params.Body.Users, params.Body.Groups); err != nil {
return ErrorWithContext(ctx, err)
}
return nil
}
// setPolicyMultipleEntities sets a policy to multiple users/groups
func setPolicyMultipleEntities(ctx context.Context, client MinioAdmin, policyName string, users, groups []models.IamEntity) error {
for _, user := range users {
if err := client.setPolicy(ctx, policyName, string(user), false); err != nil {
return err
}
}
for _, group := range groups {
groupDesc, err := groupInfo(ctx, client, string(group))
if err != nil {
return err
}
allGroupPolicies := ""
if len(groups) > 1 {
allGroupPolicies = groupDesc.Policy + "," + policyName
s := strings.Split(allGroupPolicies, ",")
allGroupPolicies = strings.Join(UniqueKeys(s), ",")
} else {
allGroupPolicies = policyName
}
if err := client.setPolicy(ctx, allGroupPolicies, string(group), true); err != nil {
return err
}
}
return nil
}
// parsePolicy() converts from *rawPolicy to *models.Policy
func parsePolicy(name string, rawPolicy *iampolicy.Policy) (*models.Policy, error) {
stringPolicy, err := json.Marshal(rawPolicy)
if err != nil {
return nil, err
}
policy := &models.Policy{
Name: name,
Policy: string(stringPolicy),
}
return policy, nil
}

382
api/admin_policies_test.go Normal file
View File

@@ -0,0 +1,382 @@
// This file is part of MinIO Console Server
// Copyright (c) 2021 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package api
import (
"bytes"
"context"
"encoding/json"
"errors"
"fmt"
"reflect"
"testing"
"github.com/minio/console/models"
iampolicy "github.com/minio/pkg/v3/policy"
"github.com/stretchr/testify/assert"
)
func TestListPolicies(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
funcAssert := assert.New(t)
adminClient := AdminClientMock{}
// mock function response from listPolicies()
minioListPoliciesMock = func() (map[string]*iampolicy.Policy, error) {
var readonly iampolicy.Policy
var readwrite iampolicy.Policy
var diagnostis iampolicy.Policy
for _, p := range iampolicy.DefaultPolicies {
switch p.Name {
case "readonly":
readonly = p.Definition
case "readwrite":
readwrite = p.Definition
case "diagnostics":
diagnostis = p.Definition
}
}
return map[string]*iampolicy.Policy{
"readonly": &readonly,
"readwrite": &readwrite,
"diagnostics": &diagnostis,
}, nil
}
// Test-1 : listPolicies() Get response from minio client with three Canned Policies and return the same number on listPolicies()
function := "listPolicies()"
policiesList, err := listPolicies(ctx, adminClient)
if err != nil {
t.Errorf("Failed on %s:, error occurred: %s", function, err.Error())
}
// verify length of Policies is correct
funcAssert.Equal(3, len(policiesList), fmt.Sprintf("Failed on %s: length of Policies's lists is not the same", function))
// Test-2 : listPolicies() Return error and see that the error is handled correctly and returned
minioListPoliciesMock = func() (map[string]*iampolicy.Policy, error) {
return nil, errors.New("error")
}
_, err = listPolicies(ctx, adminClient)
if funcAssert.Error(err) {
funcAssert.Equal("error", err.Error())
}
}
func TestRemovePolicy(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
funcAssert := assert.New(t)
adminClient := AdminClientMock{}
// Test-1 : removePolicy() remove an existing policy
policyToRemove := "console-policy"
minioRemovePolicyMock = func(_ string) error {
return nil
}
function := "removePolicy()"
if err := removePolicy(ctx, adminClient, policyToRemove); err != nil {
t.Errorf("Failed on %s:, error occurred: %s", function, err.Error())
}
// Test-2 : removePolicy() Return error and see that the error is handled correctly and returned
minioRemovePolicyMock = func(_ string) error {
return errors.New("error")
}
if err := removePolicy(ctx, adminClient, policyToRemove); funcAssert.Error(err) {
funcAssert.Equal("error", err.Error())
}
}
func TestAddPolicy(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
funcAssert := assert.New(t)
adminClient := AdminClientMock{}
policyName := "new-policy"
policyDefinition := "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Effect\":\"Allow\",\"Action\":[\"s3:GetBucketLocation\",\"s3:GetObject\",\"s3:ListAllMyBuckets\"],\"Resource\":[\"arn:aws:s3:::*\"]}]}"
minioAddPolicyMock = func(_ string, _ *iampolicy.Policy) error {
return nil
}
minioGetPolicyMock = func(_ string) (*iampolicy.Policy, error) {
policy := "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Effect\":\"Allow\",\"Action\":[\"s3:GetBucketLocation\",\"s3:GetObject\",\"s3:ListAllMyBuckets\"],\"Resource\":[\"arn:aws:s3:::*\"]}]}"
iamp, err := iampolicy.ParseConfig(bytes.NewReader([]byte(policy)))
if err != nil {
return nil, err
}
return iamp, nil
}
assertPolicy := models.Policy{
Name: "new-policy",
Policy: "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Effect\":\"Allow\",\"Action\":[\"s3:GetBucketLocation\",\"s3:GetObject\",\"s3:ListAllMyBuckets\"],\"Resource\":[\"arn:aws:s3:::*\"]}]}",
}
// Test-1 : addPolicy() adds a new policy
function := "addPolicy()"
policy, err := addPolicy(ctx, adminClient, policyName, policyDefinition)
if err != nil {
t.Errorf("Failed on %s:, error occurred: %s", function, err.Error())
} else {
funcAssert.Equal(policy.Name, assertPolicy.Name)
var expectedPolicy iampolicy.Policy
var actualPolicy iampolicy.Policy
err1 := json.Unmarshal([]byte(policy.Policy), &expectedPolicy)
funcAssert.NoError(err1)
err2 := json.Unmarshal([]byte(assertPolicy.Policy), &actualPolicy)
funcAssert.NoError(err2)
funcAssert.Equal(expectedPolicy, actualPolicy)
}
// Test-2 : addPolicy() got an error while adding policy
minioAddPolicyMock = func(_ string, _ *iampolicy.Policy) error {
return errors.New("error")
}
if _, err := addPolicy(ctx, adminClient, policyName, policyDefinition); funcAssert.Error(err) {
funcAssert.Equal("error", err.Error())
}
// Test-3 : addPolicy() got an error while retrieving policy
minioAddPolicyMock = func(_ string, _ *iampolicy.Policy) error {
return nil
}
minioGetPolicyMock = func(_ string) (*iampolicy.Policy, error) {
return nil, errors.New("error")
}
if _, err := addPolicy(ctx, adminClient, policyName, policyDefinition); funcAssert.Error(err) {
funcAssert.Equal("error", err.Error())
}
}
func TestSetPolicy(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
funcAssert := assert.New(t)
adminClient := AdminClientMock{}
policyName := "readOnly"
entityName := "alevsk"
entityObject := models.PolicyEntityUser
minioSetPolicyMock = func(_, _ string, _ bool) error {
return nil
}
// Test-1 : SetPolicy() set policy to user
function := "SetPolicy()"
err := SetPolicy(ctx, adminClient, policyName, entityName, entityObject)
if err != nil {
t.Errorf("Failed on %s:, error occurred: %s", function, err.Error())
}
// Test-2 : SetPolicy() set policy to group
entityObject = models.PolicyEntityGroup
err = SetPolicy(ctx, adminClient, policyName, entityName, entityObject)
if err != nil {
t.Errorf("Failed on %s:, error occurred: %s", function, err.Error())
}
// Test-3 : SetPolicy() set policy to user and get error
entityObject = models.PolicyEntityUser
minioSetPolicyMock = func(_, _ string, _ bool) error {
return errors.New("error")
}
if err := SetPolicy(ctx, adminClient, policyName, entityName, entityObject); funcAssert.Error(err) {
funcAssert.Equal("error", err.Error())
}
// Test-4 : SetPolicy() set policy to group and get error
entityObject = models.PolicyEntityGroup
minioSetPolicyMock = func(_, _ string, _ bool) error {
return errors.New("error")
}
if err := SetPolicy(ctx, adminClient, policyName, entityName, entityObject); funcAssert.Error(err) {
funcAssert.Equal("error", err.Error())
}
}
func Test_SetPolicyMultiple(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
adminClient := AdminClientMock{}
type args struct {
policyName string
users []models.IamEntity
groups []models.IamEntity
setPolicyFunc func(policyName, entityName string, isGroup bool) error
}
tests := []struct {
name string
args args
errorExpected error
}{
{
name: "Set policy to multiple users and groups",
args: args{
policyName: "readonly",
users: []models.IamEntity{"user1", "user2"},
groups: []models.IamEntity{"group1", "group2"},
setPolicyFunc: func(_, _ string, _ bool) error {
return nil
},
},
errorExpected: nil,
},
{
name: "Return error on set policy function",
args: args{
policyName: "readonly",
users: []models.IamEntity{"user1", "user2"},
groups: []models.IamEntity{"group1", "group2"},
setPolicyFunc: func(_, _ string, _ bool) error {
return errors.New("error set")
},
},
errorExpected: errors.New("error set"),
},
{
// Description: Empty lists of users and groups are acceptable
name: "Empty lists of users and groups",
args: args{
policyName: "readonly",
users: []models.IamEntity{},
groups: []models.IamEntity{},
setPolicyFunc: func(_, _ string, _ bool) error {
return nil
},
},
errorExpected: nil,
},
}
for _, tt := range tests {
t.Run(tt.name, func(_ *testing.T) {
minioSetPolicyMock = tt.args.setPolicyFunc
got := setPolicyMultipleEntities(ctx, adminClient, tt.args.policyName, tt.args.users, tt.args.groups)
if !reflect.DeepEqual(got, tt.errorExpected) {
ji, _ := json.Marshal(got)
vi, _ := json.Marshal(tt.errorExpected)
t.Errorf("got %s want %s", ji, vi)
}
})
}
}
func Test_policyMatchesBucket(t *testing.T) {
type args struct {
ctx context.Context
policy *models.Policy
bucket string
}
tests := []struct {
name string
args args
want bool
}{
{
name: "Test1",
args: args{ctx: context.Background(), policy: &models.Policy{Name: "consoleAdmin", Policy: `{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"admin:*"
]
},
{
"Effect": "Allow",
"Action": [
"s3:*"
],
"Resource": [
"arn:aws:s3:::*"
]
}
]
}`}, bucket: "test1"},
want: true,
},
{
name: "Test2",
args: args{ctx: context.Background(), policy: &models.Policy{Name: "consoleAdmin", Policy: `{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"s3:*"
],
"Resource": [
"arn:aws:s3:::bucket1"
]
}
]
}`}, bucket: "test1"},
want: false,
},
{
name: "Test3",
args: args{ctx: context.Background(), policy: &models.Policy{Name: "consoleAdmin", Policy: `{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": [
"s3:ListStorageLensConfigurations",
"s3:GetAccessPoint",
"s3:PutAccountPublicAccessBlock",
"s3:GetAccountPublicAccessBlock",
"s3:ListAllMyBuckets",
"s3:ListAccessPoints",
"s3:ListJobs",
"s3:PutStorageLensConfiguration",
"s3:CreateJob"
],
"Resource": "*"
},
{
"Sid": "VisualEditor1",
"Effect": "Allow",
"Action": "s3:*",
"Resource": [
"arn:aws:s3:::test",
"arn:aws:s3:::test/*",
"arn:aws:s3:::lkasdkljasd090901",
"arn:aws:s3:::lkasdkljasd090901/*"
]
}
]
}`}, bucket: "test1"},
want: false,
},
{
name: "Test4",
args: args{ctx: context.Background(), policy: &models.Policy{Name: "consoleAdmin", Policy: `{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"s3:*"
],
"Resource": [
"arn:aws:s3:::bucket1"
]
}
]
}`}, bucket: "bucket1"},
want: true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(_ *testing.T) {
if got := policyMatchesBucket(tt.args.ctx, tt.args.policy, tt.args.bucket); got != tt.want {
t.Errorf("policyMatchesBucket() = %v, want %v", got, tt.want)
}
})
}
}

63
api/admin_profiling.go Normal file
View File

@@ -0,0 +1,63 @@
// This file is part of MinIO Console Server
// Copyright (c) 2021 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package api
import (
"context"
"io"
"net/http"
"github.com/minio/console/models"
"github.com/minio/madmin-go/v3"
"github.com/minio/websocket"
)
var items []*models.StartProfilingItem
type profileOptions struct {
Types string
}
func getProfileOptionsFromReq(req *http.Request) (*profileOptions, error) {
pOptions := profileOptions{}
pOptions.Types = req.FormValue("types")
return &pOptions, nil
}
func startProfiling(ctx context.Context, conn WSConn, client MinioAdmin, pOpts *profileOptions) error {
profilingResults, err := client.startProfiling(ctx, madmin.ProfilerType(pOpts.Types))
if err != nil {
return err
}
items = []*models.StartProfilingItem{}
for _, result := range profilingResults {
items = append(items, &models.StartProfilingItem{
Success: result.Success,
Error: result.Error,
NodeName: result.NodeName,
})
}
zippedData, err := client.stopProfiling(ctx)
if err != nil {
return err
}
message, err := io.ReadAll(zippedData)
if err != nil {
return err
}
return conn.writeMessage(websocket.BinaryMessage, message)
}

105
api/admin_profiling_test.go Normal file
View File

@@ -0,0 +1,105 @@
// This file is part of MinIO Console Server
// Copyright (c) 2021 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package api
import (
"bytes"
"context"
"errors"
"io"
"net/http"
"net/url"
"testing"
"github.com/minio/madmin-go/v3"
"github.com/stretchr/testify/assert"
)
// Implementing fake closingBuffer to mock stopProfiling() (io.ReadCloser, error)
type ClosingBuffer struct {
*bytes.Buffer
}
// Implementing a fake Close function for io.ReadCloser
func (cb *ClosingBuffer) Close() error {
return nil
}
func TestStartProfiling(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
assert := assert.New(t)
adminClient := AdminClientMock{}
mockWSConn := mockConn{}
function := "startProfiling()"
testOptions := &profileOptions{
Types: "cpu",
}
// Test-1 : startProfiling() Get response from MinIO server with one profiling object without errors
// mock function response from startProfiling()
minioStartProfiling = func(_ madmin.ProfilerType) ([]madmin.StartProfilingResult, error) {
return []madmin.StartProfilingResult{
{
NodeName: "http://127.0.0.1:9000/",
Success: true,
Error: "",
},
{
NodeName: "http://127.0.0.1:9001/",
Success: true,
Error: "",
},
}, nil
}
// mock function response from stopProfiling()
minioStopProfiling = func() (io.ReadCloser, error) {
return &ClosingBuffer{bytes.NewBufferString("In memory string eaeae")}, nil
}
// mock function response from mockConn.writeMessage()
connWriteMessageMock = func(_ int, _ []byte) error {
return nil
}
err := startProfiling(ctx, mockWSConn, adminClient, testOptions)
if err != nil {
t.Errorf("Failed on %s:, error occurred: %s", function, err.Error())
}
assert.Equal(err, nil)
// Test-2 : startProfiling() Correctly handles errors returned by MinIO
// mock function response from startProfiling()
minioStartProfiling = func(_ madmin.ProfilerType) ([]madmin.StartProfilingResult, error) {
return nil, errors.New("error")
}
err = startProfiling(ctx, mockWSConn, adminClient, testOptions)
if assert.Error(err) {
assert.Equal("error", err.Error())
}
// Test-3: getProfileOptionsFromReq() correctly returns profile options from request
u, _ := url.Parse("ws://localhost/ws/profile?types=cpu,mem,block,mutex,trace,threads,goroutines")
req := &http.Request{
URL: u,
}
opts, err := getProfileOptionsFromReq(req)
if assert.NoError(err) {
expectedOptions := profileOptions{
Types: "cpu,mem,block,mutex,trace,threads,goroutines",
}
assert.Equal(expectedOptions.Types, opts.Types)
}
}

116
api/admin_releases.go Normal file
View File

@@ -0,0 +1,116 @@
// This file is part of MinIO Console Server
// Copyright (c) 2023 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package api
import (
"context"
"encoding/json"
"fmt"
"net/http"
"net/url"
"time"
"github.com/minio/console/pkg/utils"
"github.com/go-openapi/runtime/middleware"
"github.com/minio/console/api/operations"
release "github.com/minio/console/api/operations/release"
"github.com/minio/console/models"
"github.com/minio/pkg/v3/env"
)
var (
releaseServiceHostEnvVar = "RELEASE_SERVICE_HOST"
defaultReleaseServiceHost = "https://enterprise-updates.ic.min.dev"
)
func registerReleasesHandlers(api *operations.ConsoleAPI) {
api.ReleaseListReleasesHandler = release.ListReleasesHandlerFunc(func(params release.ListReleasesParams, session *models.Principal) middleware.Responder {
resp, err := GetReleaseListResponse(session, params)
if err != nil {
return release.NewListReleasesDefault(err.Code).WithPayload(err.APIError)
}
return release.NewListReleasesOK().WithPayload(resp)
})
}
func GetReleaseListResponse(_ *models.Principal, params release.ListReleasesParams) (*models.ReleaseListResponse, *CodedAPIError) {
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
defer cancel()
repo := params.Repo
currentRelease := ""
if params.Current != nil {
currentRelease = *params.Current
}
search := ""
if params.Search != nil {
search = *params.Search
}
filter := ""
if params.Filter != nil {
filter = *params.Filter
}
ctx = context.WithValue(ctx, utils.ContextClientIP, getClientIP(params.HTTPRequest))
return releaseList(ctx, repo, currentRelease, search, filter)
}
func releaseList(ctx context.Context, repo, currentRelease, search, filter string) (*models.ReleaseListResponse, *CodedAPIError) {
serviceURL := getReleaseServiceURL()
clientIP := utils.ClientIPFromContext(ctx)
releases, err := getReleases(serviceURL, repo, currentRelease, search, filter, clientIP)
if err != nil {
return nil, ErrorWithContext(ctx, err)
}
return releases, nil
}
func getReleaseServiceURL() string {
host := env.Get(releaseServiceHostEnvVar, defaultReleaseServiceHost)
return fmt.Sprintf("%s/releases", host)
}
func getReleases(endpoint, repo, currentRelease, search, filter, clientIP string) (*models.ReleaseListResponse, error) {
rl := &models.ReleaseListResponse{}
req, err := http.NewRequest(http.MethodGet, endpoint, nil)
if err != nil {
return nil, err
}
q := &url.Values{}
q.Add("repo", repo)
q.Add("search", search)
q.Add("filter", filter)
q.Add("current", currentRelease)
req.URL.RawQuery = q.Encode()
req.Header.Set("Content-Type", "application/json")
client := GetConsoleHTTPClient(clientIP)
client.Timeout = time.Second * 5
resp, err := client.Do(req)
if err != nil {
return nil, err
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
return nil, fmt.Errorf("error getting releases: %s", resp.Status)
}
err = json.NewDecoder(resp.Body).Decode(&rl)
if err != nil {
return nil, err
}
return rl, nil
}

104
api/admin_releases_test.go Normal file
View File

@@ -0,0 +1,104 @@
// This file is part of MinIO Console Server
// Copyright (c) 2023 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package api
import (
"encoding/json"
"fmt"
"net/http"
"net/http/httptest"
"os"
"testing"
"github.com/minio/console/api/operations"
release "github.com/minio/console/api/operations/release"
"github.com/minio/console/models"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/suite"
)
type ReleasesTestSuite struct {
suite.Suite
assert *assert.Assertions
currentServer string
isServerSet bool
getServer *httptest.Server
withError bool
}
func (suite *ReleasesTestSuite) SetupSuite() {
suite.assert = assert.New(suite.T())
suite.getServer = httptest.NewServer(http.HandlerFunc(suite.getHandler))
suite.currentServer, suite.isServerSet = os.LookupEnv(releaseServiceHostEnvVar)
os.Setenv(releaseServiceHostEnvVar, suite.getServer.URL)
}
func (suite *ReleasesTestSuite) TearDownSuite() {
if suite.isServerSet {
os.Setenv(releaseServiceHostEnvVar, suite.currentServer)
} else {
os.Unsetenv(releaseServiceHostEnvVar)
}
}
func (suite *ReleasesTestSuite) getHandler(
w http.ResponseWriter, _ *http.Request,
) {
if suite.withError {
w.WriteHeader(400)
} else {
w.WriteHeader(200)
response := &models.ReleaseListResponse{}
bytes, _ := json.Marshal(response)
fmt.Fprint(w, string(bytes))
}
}
func (suite *ReleasesTestSuite) TestRegisterReleasesHandlers() {
api := &operations.ConsoleAPI{}
suite.assert.Nil(api.ReleaseListReleasesHandler)
registerReleasesHandlers(api)
suite.assert.NotNil(api.ReleaseListReleasesHandler)
}
func (suite *ReleasesTestSuite) TestGetReleasesWithError() {
api := &operations.ConsoleAPI{}
current := "mock"
registerReleasesHandlers(api)
params := release.NewListReleasesParams()
params.Current = &current
params.HTTPRequest = &http.Request{}
suite.withError = true
response := api.ReleaseListReleasesHandler.Handle(params, &models.Principal{})
_, ok := response.(*release.ListReleasesDefault)
suite.assert.True(ok)
}
func (suite *ReleasesTestSuite) TestGetReleasesWithoutError() {
api := &operations.ConsoleAPI{}
registerReleasesHandlers(api)
params := release.NewListReleasesParams()
params.HTTPRequest = &http.Request{}
suite.withError = false
response := api.ReleaseListReleasesHandler.Handle(params, &models.Principal{})
_, ok := response.(*release.ListReleasesOK)
suite.assert.True(ok)
}
func TestReleases(t *testing.T) {
suite.Run(t, new(ReleasesTestSuite))
}

810
api/admin_remote_buckets.go Normal file
View File

@@ -0,0 +1,810 @@
// This file is part of MinIO Console Server
// Copyright (c) 2021 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package api
import (
"context"
"errors"
"fmt"
"net/url"
"strconv"
"time"
"github.com/minio/console/pkg/utils"
"github.com/minio/madmin-go/v3"
"github.com/go-openapi/runtime/middleware"
"github.com/go-openapi/swag"
"github.com/minio/console/api/operations"
bucketApi "github.com/minio/console/api/operations/bucket"
"github.com/minio/console/models"
"github.com/minio/minio-go/v7/pkg/replication"
)
type RemoteBucketResult struct {
OriginBucket string
TargetBucket string
Error string
}
func registerAdminBucketRemoteHandlers(api *operations.ConsoleAPI) {
// return list of remote buckets
api.BucketListRemoteBucketsHandler = bucketApi.ListRemoteBucketsHandlerFunc(func(params bucketApi.ListRemoteBucketsParams, session *models.Principal) middleware.Responder {
listResp, err := getListRemoteBucketsResponse(session, params)
if err != nil {
return bucketApi.NewListRemoteBucketsDefault(err.Code).WithPayload(err.APIError)
}
return bucketApi.NewListRemoteBucketsOK().WithPayload(listResp)
})
// return information about a specific bucket
api.BucketRemoteBucketDetailsHandler = bucketApi.RemoteBucketDetailsHandlerFunc(func(params bucketApi.RemoteBucketDetailsParams, session *models.Principal) middleware.Responder {
response, err := getRemoteBucketDetailsResponse(session, params)
if err != nil {
return bucketApi.NewRemoteBucketDetailsDefault(err.Code).WithPayload(err.APIError)
}
return bucketApi.NewRemoteBucketDetailsOK().WithPayload(response)
})
// delete remote bucket
api.BucketDeleteRemoteBucketHandler = bucketApi.DeleteRemoteBucketHandlerFunc(func(params bucketApi.DeleteRemoteBucketParams, session *models.Principal) middleware.Responder {
err := getDeleteRemoteBucketResponse(session, params)
if err != nil {
return bucketApi.NewDeleteRemoteBucketDefault(err.Code).WithPayload(err.APIError)
}
return bucketApi.NewDeleteRemoteBucketNoContent()
})
// set remote bucket
api.BucketAddRemoteBucketHandler = bucketApi.AddRemoteBucketHandlerFunc(func(params bucketApi.AddRemoteBucketParams, session *models.Principal) middleware.Responder {
err := getAddRemoteBucketResponse(session, params)
if err != nil {
return bucketApi.NewAddRemoteBucketDefault(err.Code).WithPayload(err.APIError)
}
return bucketApi.NewAddRemoteBucketCreated()
})
// set multi-bucket replication
api.BucketSetMultiBucketReplicationHandler = bucketApi.SetMultiBucketReplicationHandlerFunc(func(params bucketApi.SetMultiBucketReplicationParams, session *models.Principal) middleware.Responder {
response, err := setMultiBucketReplicationResponse(session, params)
if err != nil {
return bucketApi.NewSetMultiBucketReplicationDefault(err.Code).WithPayload(err.APIError)
}
return bucketApi.NewSetMultiBucketReplicationOK().WithPayload(response)
})
// list external buckets
api.BucketListExternalBucketsHandler = bucketApi.ListExternalBucketsHandlerFunc(func(params bucketApi.ListExternalBucketsParams, _ *models.Principal) middleware.Responder {
response, err := listExternalBucketsResponse(params)
if err != nil {
return bucketApi.NewListExternalBucketsDefault(err.Code).WithPayload(err.APIError)
}
return bucketApi.NewListExternalBucketsOK().WithPayload(response)
})
// delete replication rule
api.BucketDeleteBucketReplicationRuleHandler = bucketApi.DeleteBucketReplicationRuleHandlerFunc(func(params bucketApi.DeleteBucketReplicationRuleParams, session *models.Principal) middleware.Responder {
err := deleteReplicationRuleResponse(session, params)
if err != nil {
return bucketApi.NewDeleteBucketReplicationRuleDefault(err.Code).WithPayload(err.APIError)
}
return bucketApi.NewDeleteBucketReplicationRuleNoContent()
})
// delete all replication rules for a bucket
api.BucketDeleteAllReplicationRulesHandler = bucketApi.DeleteAllReplicationRulesHandlerFunc(func(params bucketApi.DeleteAllReplicationRulesParams, session *models.Principal) middleware.Responder {
err := deleteBucketReplicationRulesResponse(session, params)
if err != nil {
if err.Code == 500 && err.APIError.DetailedMessage == "The remote target does not exist" {
// We should ignore this MinIO error when deleting all replication rules
return bucketApi.NewDeleteAllReplicationRulesNoContent() // This will return 204 as per swagger spec
}
// If there is a different error, then we should handle it
// This will return a generic error with err.Code (likely a 500 or 404) and its *err.DetailedMessage
return bucketApi.NewDeleteAllReplicationRulesDefault(err.Code).WithPayload(err.APIError)
}
return bucketApi.NewDeleteAllReplicationRulesNoContent()
})
// delete selected replication rules for a bucket
api.BucketDeleteSelectedReplicationRulesHandler = bucketApi.DeleteSelectedReplicationRulesHandlerFunc(func(params bucketApi.DeleteSelectedReplicationRulesParams, session *models.Principal) middleware.Responder {
err := deleteSelectedReplicationRulesResponse(session, params)
if err != nil {
return bucketApi.NewDeleteSelectedReplicationRulesDefault(err.Code).WithPayload(err.APIError)
}
return bucketApi.NewDeleteSelectedReplicationRulesNoContent()
})
// update local bucket replication config item
api.BucketUpdateMultiBucketReplicationHandler = bucketApi.UpdateMultiBucketReplicationHandlerFunc(func(params bucketApi.UpdateMultiBucketReplicationParams, session *models.Principal) middleware.Responder {
err := updateBucketReplicationResponse(session, params)
if err != nil {
return bucketApi.NewUpdateMultiBucketReplicationDefault(err.Code).WithPayload(err.APIError)
}
return bucketApi.NewUpdateMultiBucketReplicationCreated()
})
}
func getListRemoteBucketsResponse(session *models.Principal, params bucketApi.ListRemoteBucketsParams) (*models.ListRemoteBucketsResponse, *CodedAPIError) {
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
defer cancel()
mAdmin, err := NewMinioAdminClient(params.HTTPRequest.Context(), session)
if err != nil {
return nil, ErrorWithContext(ctx, fmt.Errorf("error creating Madmin Client: %v", err))
}
adminClient := AdminClient{Client: mAdmin}
return listRemoteBuckets(ctx, adminClient)
}
func getRemoteBucketDetailsResponse(session *models.Principal, params bucketApi.RemoteBucketDetailsParams) (*models.RemoteBucket, *CodedAPIError) {
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
defer cancel()
mAdmin, err := NewMinioAdminClient(params.HTTPRequest.Context(), session)
if err != nil {
return nil, ErrorWithContext(ctx, fmt.Errorf("error creating Madmin Client: %v", err))
}
adminClient := AdminClient{Client: mAdmin}
return getRemoteBucket(ctx, adminClient, params.Name)
}
func getDeleteRemoteBucketResponse(session *models.Principal, params bucketApi.DeleteRemoteBucketParams) *CodedAPIError {
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
defer cancel()
mAdmin, err := NewMinioAdminClient(params.HTTPRequest.Context(), session)
if err != nil {
return ErrorWithContext(ctx, fmt.Errorf("error creating Madmin Client: %v", err))
}
adminClient := AdminClient{Client: mAdmin}
err = deleteRemoteBucket(ctx, adminClient, params.SourceBucketName, params.Arn)
if err != nil {
return ErrorWithContext(ctx, fmt.Errorf("error deleting remote bucket: %v", err))
}
return nil
}
func getAddRemoteBucketResponse(session *models.Principal, params bucketApi.AddRemoteBucketParams) *CodedAPIError {
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
defer cancel()
mAdmin, err := NewMinioAdminClient(params.HTTPRequest.Context(), session)
if err != nil {
return ErrorWithContext(ctx, fmt.Errorf("error creating Madmin Client: %v", err))
}
adminClient := AdminClient{Client: mAdmin}
_, err = addRemoteBucket(ctx, adminClient, *params.Body)
if err != nil {
return ErrorWithContext(ctx, fmt.Errorf("error adding remote bucket: %v", err))
}
return nil
}
func listRemoteBuckets(ctx context.Context, client MinioAdmin) (*models.ListRemoteBucketsResponse, *CodedAPIError) {
var remoteBuckets []*models.RemoteBucket
buckets, err := client.listRemoteBuckets(ctx, "", "")
if err != nil {
return nil, ErrorWithContext(ctx, fmt.Errorf("error listing remote buckets: %v", err))
}
for _, bucket := range buckets {
remoteBucket := &models.RemoteBucket{
AccessKey: swag.String(bucket.Credentials.AccessKey),
RemoteARN: swag.String(bucket.Arn),
SecretKey: bucket.Credentials.SecretKey,
Service: "replication",
SourceBucket: swag.String(bucket.SourceBucket),
Status: "",
TargetBucket: bucket.TargetBucket,
TargetURL: bucket.Endpoint,
SyncMode: "async",
Bandwidth: bucket.BandwidthLimit,
HealthCheckPeriod: int64(bucket.HealthCheckDuration.Seconds()),
}
if bucket.ReplicationSync {
remoteBucket.SyncMode = "sync"
}
remoteBuckets = append(remoteBuckets, remoteBucket)
}
return &models.ListRemoteBucketsResponse{
Buckets: remoteBuckets,
Total: int64(len(remoteBuckets)),
}, nil
}
func getRemoteBucket(ctx context.Context, client MinioAdmin, name string) (*models.RemoteBucket, *CodedAPIError) {
remoteBucket, err := client.getRemoteBucket(ctx, name, "")
if err != nil {
return nil, ErrorWithContext(ctx, fmt.Errorf("error getting remote bucket details: %v", err))
}
if remoteBucket == nil {
return nil, ErrorWithContext(ctx, "error getting remote bucket details: bucket not found")
}
return &models.RemoteBucket{
AccessKey: &remoteBucket.Credentials.AccessKey,
RemoteARN: &remoteBucket.Arn,
SecretKey: remoteBucket.Credentials.SecretKey,
Service: "replication",
SourceBucket: &remoteBucket.SourceBucket,
Status: "",
TargetBucket: remoteBucket.TargetBucket,
TargetURL: remoteBucket.Endpoint,
}, nil
}
func deleteRemoteBucket(ctx context.Context, client MinioAdmin, sourceBucketName, arn string) error {
return client.removeRemoteBucket(ctx, sourceBucketName, arn)
}
func addRemoteBucket(ctx context.Context, client MinioAdmin, params models.CreateRemoteBucket) (string, error) {
TargetURL := *params.TargetURL
accessKey := *params.AccessKey
secretKey := *params.SecretKey
u, err := url.Parse(TargetURL)
if err != nil {
return "", errors.New("malformed Remote target URL")
}
secure := u.Scheme == "https"
host := u.Host
if u.Port() == "" {
port := 80
if secure {
port = 443
}
host = host + ":" + strconv.Itoa(port)
}
creds := &madmin.Credentials{AccessKey: accessKey, SecretKey: secretKey}
remoteBucket := &madmin.BucketTarget{
TargetBucket: *params.TargetBucket,
Secure: secure,
Credentials: creds,
Endpoint: host,
Path: "",
API: "s3v4",
Type: "replication",
Region: params.Region,
ReplicationSync: *params.SyncMode == "sync",
}
if *params.SyncMode == "async" {
remoteBucket.BandwidthLimit = params.Bandwidth
}
if params.HealthCheckPeriod > 0 {
remoteBucket.HealthCheckDuration = time.Duration(params.HealthCheckPeriod) * time.Second
}
bucketARN, err := client.addRemoteBucket(ctx, *params.SourceBucket, remoteBucket)
return bucketARN, err
}
func addBucketReplicationItem(ctx context.Context, session *models.Principal, minClient minioClient, bucketName, prefix, destinationARN string, repExistingObj, repDelMark, repDels, repMeta bool, tags string, priority int32, storageClass string) error {
// we will tolerate this call failing
cfg, err := minClient.getBucketReplication(ctx, bucketName)
if err != nil {
ErrorWithContext(ctx, fmt.Errorf("error fetching replication configuration for bucket %s: %v", bucketName, err))
}
// add rule
maxPrio := 0
if priority <= 0 { // We pick next priority by default
for _, r := range cfg.Rules {
if r.Priority > maxPrio {
maxPrio = r.Priority
}
}
maxPrio++
} else { // User picked priority, we try to set this manually
maxPrio = int(priority)
}
clientIP := utils.ClientIPFromContext(ctx)
s3Client, err := newS3BucketClient(session, bucketName, prefix, clientIP)
if err != nil {
ErrorWithContext(ctx, fmt.Errorf("error creating S3Client: %v", err))
return err
}
// create a mc S3Client interface implementation
// defining the client to be used
mcClient := mcClient{client: s3Client}
repDelMarkStatus := "disable"
if repDelMark {
repDelMarkStatus = "enable"
}
repDelsStatus := "disable"
if repDels {
repDelsStatus = "enable"
}
repMetaStatus := "disable"
if repMeta {
repMetaStatus = "enable"
}
existingRepStatus := "disable"
if repExistingObj {
existingRepStatus = "enable"
}
opts := replication.Options{
Priority: fmt.Sprintf("%d", maxPrio),
RuleStatus: "enable",
DestBucket: destinationARN,
Op: replication.AddOption,
TagString: tags,
ExistingObjectReplicate: existingRepStatus,
ReplicateDeleteMarkers: repDelMarkStatus,
ReplicateDeletes: repDelsStatus,
ReplicaSync: repMetaStatus,
StorageClass: storageClass,
}
err2 := mcClient.setReplication(ctx, &cfg, opts)
if err2 != nil {
ErrorWithContext(ctx, fmt.Errorf("error creating replication for bucket: %v", err2.Cause))
return err2.Cause
}
return nil
}
func editBucketReplicationItem(ctx context.Context, session *models.Principal, minClient minioClient, ruleID, bucketName, prefix, destinationARN string, ruleStatus, repDelMark, repDels, repMeta, existingObjectRep bool, tags string, priority int32, storageClass string) error {
// we will tolerate this call failing
cfg, err := minClient.getBucketReplication(ctx, bucketName)
if err != nil {
ErrorWithContext(ctx, fmt.Errorf("error fetching replication configuration for bucket %s: %v", bucketName, err))
}
maxPrio := int(priority)
clientIP := utils.ClientIPFromContext(ctx)
s3Client, err := newS3BucketClient(session, bucketName, prefix, clientIP)
if err != nil {
return fmt.Errorf("error creating S3Client: %v", err)
}
// create a mc S3Client interface implementation
// defining the client to be used
mcClient := mcClient{client: s3Client}
ruleState := "disable"
if ruleStatus {
ruleState = "enable"
}
repDelMarkStatus := "disable"
if repDelMark {
repDelMarkStatus = "enable"
}
repDelsStatus := "disable"
if repDels {
repDelsStatus = "enable"
}
repMetaStatus := "disable"
if repMeta {
repMetaStatus = "enable"
}
existingRepStatus := "disable"
if existingObjectRep {
existingRepStatus = "enable"
}
opts := replication.Options{
ID: ruleID,
Priority: fmt.Sprintf("%d", maxPrio),
RuleStatus: ruleState,
DestBucket: destinationARN,
Op: replication.SetOption,
TagString: tags,
IsTagSet: true,
ExistingObjectReplicate: existingRepStatus,
ReplicateDeleteMarkers: repDelMarkStatus,
ReplicateDeletes: repDelsStatus,
ReplicaSync: repMetaStatus,
StorageClass: storageClass,
IsSCSet: true,
}
err2 := mcClient.setReplication(ctx, &cfg, opts)
if err2 != nil {
return fmt.Errorf("error modifying replication for bucket: %v", err2.Cause)
}
return nil
}
func setMultiBucketReplication(ctx context.Context, session *models.Principal, client MinioAdmin, minClient minioClient, params bucketApi.SetMultiBucketReplicationParams) []RemoteBucketResult {
bucketsRelation := params.Body.BucketsRelation
// Parallel remote bucket adding
parallelRemoteBucket := func(bucketRelationData *models.MultiBucketsRelation) chan RemoteBucketResult {
remoteProc := make(chan RemoteBucketResult)
sourceBucket := bucketRelationData.OriginBucket
targetBucket := bucketRelationData.DestinationBucket
go func() {
defer close(remoteProc)
createRemoteBucketParams := models.CreateRemoteBucket{
AccessKey: params.Body.AccessKey,
SecretKey: params.Body.SecretKey,
SourceBucket: &sourceBucket,
TargetBucket: &targetBucket,
Region: params.Body.Region,
TargetURL: params.Body.TargetURL,
SyncMode: params.Body.SyncMode,
Bandwidth: params.Body.Bandwidth,
HealthCheckPeriod: params.Body.HealthCheckPeriod,
}
// We add the remote bucket reference & store the arn or errors returned
arn, err := addRemoteBucket(ctx, client, createRemoteBucketParams)
if err == nil {
err = addBucketReplicationItem(
ctx,
session,
minClient,
sourceBucket,
params.Body.Prefix,
arn,
params.Body.ReplicateExistingObjects,
params.Body.ReplicateDeleteMarkers,
params.Body.ReplicateDeletes,
params.Body.ReplicateMetadata,
params.Body.Tags,
params.Body.Priority,
params.Body.StorageClass)
}
errorReturn := ""
if err != nil {
deleteRemoteBucket(ctx, client, sourceBucket, arn)
errorReturn = err.Error()
}
retParams := RemoteBucketResult{
OriginBucket: sourceBucket,
TargetBucket: targetBucket,
Error: errorReturn,
}
remoteProc <- retParams
}()
return remoteProc
}
var bucketsManagement []chan RemoteBucketResult
for _, bucketName := range bucketsRelation {
// We generate the ARNs for each bucket
rBucket := parallelRemoteBucket(bucketName)
bucketsManagement = append(bucketsManagement, rBucket)
}
resultsList := []RemoteBucketResult{}
for _, result := range bucketsManagement {
res := <-result
resultsList = append(resultsList, res)
}
return resultsList
}
func setMultiBucketReplicationResponse(session *models.Principal, params bucketApi.SetMultiBucketReplicationParams) (*models.MultiBucketResponseState, *CodedAPIError) {
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
defer cancel()
mAdmin, err := NewMinioAdminClient(params.HTTPRequest.Context(), session)
if err != nil {
return nil, ErrorWithContext(ctx, fmt.Errorf("error creating Madmin Client: %v", err))
}
adminClient := AdminClient{Client: mAdmin}
mClient, err := newMinioClient(session, getClientIP(params.HTTPRequest))
if err != nil {
return nil, ErrorWithContext(ctx, fmt.Errorf("error creating MinIO Client: %v", err))
}
// create a minioClient interface implementation
// defining the client to be used
mnClient := minioClient{client: mClient}
replicationResults := setMultiBucketReplication(ctx, session, adminClient, mnClient, params)
if replicationResults == nil {
return nil, ErrorWithContext(ctx, errors.New("error setting buckets replication"))
}
resParsed := []*models.MultiBucketResponseItem{}
for _, repResult := range replicationResults {
responseItem := models.MultiBucketResponseItem{
ErrorString: repResult.Error,
OriginBucket: repResult.OriginBucket,
TargetBucket: repResult.TargetBucket,
}
resParsed = append(resParsed, &responseItem)
}
resultsParsed := models.MultiBucketResponseState{
ReplicationState: resParsed,
}
return &resultsParsed, nil
}
func listExternalBucketsResponse(params bucketApi.ListExternalBucketsParams) (*models.ListBucketsResponse, *CodedAPIError) {
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
defer cancel()
remoteAdmin, err := newAdminFromCreds(*params.Body.AccessKey, *params.Body.SecretKey, *params.Body.TargetURL, *params.Body.UseTLS)
if err != nil {
return nil, ErrorWithContext(ctx, err)
}
return listExternalBuckets(ctx, AdminClient{Client: remoteAdmin})
}
func listExternalBuckets(ctx context.Context, client MinioAdmin) (*models.ListBucketsResponse, *CodedAPIError) {
buckets, err := getAccountBuckets(ctx, client)
if err != nil {
return nil, ErrorWithContext(ctx, err)
}
return &models.ListBucketsResponse{
Buckets: buckets,
Total: int64(len(buckets)),
}, nil
}
func getARNFromID(conf *replication.Config, rule string) string {
for i := range conf.Rules {
if conf.Rules[i].ID == rule {
return conf.Rules[i].Destination.Bucket
}
}
return ""
}
func getARNsFromIDs(conf *replication.Config, rules []string) []string {
temp := make(map[string]string)
for i := range conf.Rules {
temp[conf.Rules[i].ID] = conf.Rules[i].Destination.Bucket
}
var retval []string
for i := range rules {
if val, ok := temp[rules[i]]; ok {
retval = append(retval, val)
}
}
return retval
}
func deleteReplicationRule(ctx context.Context, session *models.Principal, bucketName, ruleID string) error {
clientIP := utils.ClientIPFromContext(ctx)
mClient, err := newMinioClient(session, clientIP)
if err != nil {
return fmt.Errorf("error creating MinIO Client: %v", err)
}
// create a minioClient interface implementation
// defining the client to be used
minClient := minioClient{client: mClient}
cfg, err := minClient.getBucketReplication(ctx, bucketName)
if err != nil {
ErrorWithContext(ctx, fmt.Errorf("error versioning bucket: %v", err))
}
s3Client, err := newS3BucketClient(session, bucketName, "", clientIP)
if err != nil {
return fmt.Errorf("error creating S3Client: %v", err)
}
mAdmin, err := NewMinioAdminClient(ctx, session)
if err != nil {
return fmt.Errorf("error creating Admin Client: %v", err)
}
admClient := AdminClient{Client: mAdmin}
// create a mc S3Client interface implementation
// defining the client to be used
mcClient := mcClient{client: s3Client}
opts := replication.Options{
ID: ruleID,
Op: replication.RemoveOption,
}
err2 := mcClient.setReplication(ctx, &cfg, opts)
if err2 != nil {
return err2.Cause
}
// Replication rule was successfully deleted. We remove remote bucket
err3 := deleteRemoteBucket(ctx, admClient, bucketName, getARNFromID(&cfg, ruleID))
if err3 != nil {
return err3
}
return nil
}
func deleteAllReplicationRules(ctx context.Context, session *models.Principal, bucketName string) error {
clientIP := utils.ClientIPFromContext(ctx)
s3Client, err := newS3BucketClient(session, bucketName, "", clientIP)
if err != nil {
return fmt.Errorf("error creating S3Client: %v", err)
}
// create a mc S3Client interface implementation
// defining the client to be used
mcClient := mcClient{client: s3Client}
mClient, err := newMinioClient(session, clientIP)
if err != nil {
return fmt.Errorf("error creating MinIO Client: %v", err)
}
// create a minioClient interface implementation
// defining the client to be used
minClient := minioClient{client: mClient}
cfg, err := minClient.getBucketReplication(ctx, bucketName)
if err != nil {
ErrorWithContext(ctx, fmt.Errorf("error versioning bucket: %v", err))
}
mAdmin, err := NewMinioAdminClient(ctx, session)
if err != nil {
return fmt.Errorf("error creating Admin Client: %v", err)
}
admClient := AdminClient{Client: mAdmin}
err2 := mcClient.deleteAllReplicationRules(ctx)
if err2 != nil {
return err2.ToGoError()
}
for i := range cfg.Rules {
err3 := deleteRemoteBucket(ctx, admClient, bucketName, cfg.Rules[i].Destination.Bucket)
if err3 != nil {
return err3
}
}
return nil
}
func deleteSelectedReplicationRules(ctx context.Context, session *models.Principal, bucketName string, rules []string) error {
clientIP := utils.ClientIPFromContext(ctx)
mClient, err := newMinioClient(session, clientIP)
if err != nil {
return fmt.Errorf("error creating MinIO Client: %v", err)
}
// create a minioClient interface implementation
// defining the client to be used
minClient := minioClient{client: mClient}
cfg, err := minClient.getBucketReplication(ctx, bucketName)
if err != nil {
ErrorWithContext(ctx, fmt.Errorf("error versioning bucket: %v", err))
}
s3Client, err := newS3BucketClient(session, bucketName, "", clientIP)
if err != nil {
return fmt.Errorf("error creating S3Client: %v", err)
}
// create a mc S3Client interface implementation
// defining the client to be used
mcClient := mcClient{client: s3Client}
mAdmin, err := NewMinioAdminClient(ctx, session)
if err != nil {
return fmt.Errorf("error creating Admin Client: %v", err)
}
admClient := AdminClient{Client: mAdmin}
ARNs := getARNsFromIDs(&cfg, rules)
for i := range rules {
opts := replication.Options{
ID: rules[i],
Op: replication.RemoveOption,
}
err2 := mcClient.setReplication(ctx, &cfg, opts)
if err2 != nil {
return err2.Cause
}
// In case replication rule was deleted successfully, we remove the remote bucket ARN
err3 := deleteRemoteBucket(ctx, admClient, bucketName, ARNs[i])
if err3 != nil {
return err3
}
}
return nil
}
func deleteReplicationRuleResponse(session *models.Principal, params bucketApi.DeleteBucketReplicationRuleParams) *CodedAPIError {
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
defer cancel()
ctx = context.WithValue(ctx, utils.ContextClientIP, getClientIP(params.HTTPRequest))
err := deleteReplicationRule(ctx, session, params.BucketName, params.RuleID)
if err != nil {
return ErrorWithContext(ctx, err)
}
return nil
}
func deleteBucketReplicationRulesResponse(session *models.Principal, params bucketApi.DeleteAllReplicationRulesParams) *CodedAPIError {
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
defer cancel()
ctx = context.WithValue(ctx, utils.ContextClientIP, getClientIP(params.HTTPRequest))
err := deleteAllReplicationRules(ctx, session, params.BucketName)
if err != nil {
return ErrorWithContext(ctx, err)
}
return nil
}
func deleteSelectedReplicationRulesResponse(session *models.Principal, params bucketApi.DeleteSelectedReplicationRulesParams) *CodedAPIError {
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
defer cancel()
ctx = context.WithValue(ctx, utils.ContextClientIP, getClientIP(params.HTTPRequest))
err := deleteSelectedReplicationRules(ctx, session, params.BucketName, params.Rules.Rules)
if err != nil {
return ErrorWithContext(ctx, err)
}
return nil
}
func updateBucketReplicationResponse(session *models.Principal, params bucketApi.UpdateMultiBucketReplicationParams) *CodedAPIError {
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
defer cancel()
mClient, err := newMinioClient(session, getClientIP(params.HTTPRequest))
if err != nil {
return ErrorWithContext(ctx, err)
}
// create a minioClient interface implementation
// defining the client to be used
minClient := minioClient{client: mClient}
err = editBucketReplicationItem(
ctx,
session,
minClient,
params.RuleID,
params.BucketName,
params.Body.Prefix,
params.Body.Arn,
params.Body.RuleState,
params.Body.ReplicateDeleteMarkers,
params.Body.ReplicateDeletes,
params.Body.ReplicateMetadata,
params.Body.ReplicateExistingObjects,
params.Body.Tags,
params.Body.Priority,
params.Body.StorageClass)
if err != nil {
return ErrorWithContext(ctx, err)
}
return nil
}

View File

@@ -0,0 +1,386 @@
// This file is part of MinIO Console Server
// Copyright (c) 2023 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package api
import (
"context"
"errors"
"net/http"
"net/http/httptest"
"os"
"testing"
"github.com/minio/console/pkg/utils"
"github.com/go-openapi/swag"
"github.com/minio/console/api/operations"
bucketApi "github.com/minio/console/api/operations/bucket"
"github.com/minio/console/models"
"github.com/minio/madmin-go/v3"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/suite"
)
type RemoteBucketsTestSuite struct {
suite.Suite
assert *assert.Assertions
currentServer string
isServerSet bool
server *httptest.Server
adminClient AdminClientMock
minioClient minioClientMock
mockRemoteBucket *models.RemoteBucket
mockBucketTarget *madmin.BucketTarget
mockListBuckets *models.ListBucketsResponse
}
func (suite *RemoteBucketsTestSuite) SetupSuite() {
suite.assert = assert.New(suite.T())
suite.adminClient = AdminClientMock{}
suite.minioClient = minioClientMock{}
suite.mockObjects()
}
func (suite *RemoteBucketsTestSuite) mockObjects() {
suite.mockListBuckets = &models.ListBucketsResponse{
Buckets: []*models.Bucket{},
Total: 0,
}
suite.mockRemoteBucket = &models.RemoteBucket{
AccessKey: swag.String("accessKey"),
SecretKey: "secretKey",
RemoteARN: swag.String("remoteARN"),
Service: "replication",
SourceBucket: swag.String("sourceBucket"),
TargetBucket: "targetBucket",
TargetURL: "targetURL",
Status: "",
}
suite.mockBucketTarget = &madmin.BucketTarget{
Credentials: &madmin.Credentials{
AccessKey: *suite.mockRemoteBucket.AccessKey,
SecretKey: suite.mockRemoteBucket.SecretKey,
},
Arn: *suite.mockRemoteBucket.RemoteARN,
SourceBucket: *suite.mockRemoteBucket.SourceBucket,
TargetBucket: suite.mockRemoteBucket.TargetBucket,
Endpoint: suite.mockRemoteBucket.TargetURL,
}
}
func (suite *RemoteBucketsTestSuite) SetupTest() {
suite.server = httptest.NewServer(http.HandlerFunc(suite.serverHandler))
suite.currentServer, suite.isServerSet = os.LookupEnv(ConsoleMinIOServer)
os.Setenv(ConsoleMinIOServer, suite.server.URL)
}
func (suite *RemoteBucketsTestSuite) serverHandler(w http.ResponseWriter, _ *http.Request) {
w.WriteHeader(400)
}
func (suite *RemoteBucketsTestSuite) TearDownSuite() {
}
func (suite *RemoteBucketsTestSuite) TearDownTest() {
if suite.isServerSet {
os.Setenv(ConsoleMinIOServer, suite.currentServer)
} else {
os.Unsetenv(ConsoleMinIOServer)
}
}
func (suite *RemoteBucketsTestSuite) TestRegisterRemoteBucketsHandlers() {
api := &operations.ConsoleAPI{}
suite.assertHandlersAreNil(api)
registerAdminBucketRemoteHandlers(api)
suite.assertHandlersAreNotNil(api)
}
func (suite *RemoteBucketsTestSuite) assertHandlersAreNil(api *operations.ConsoleAPI) {
suite.assert.Nil(api.BucketListRemoteBucketsHandler)
suite.assert.Nil(api.BucketRemoteBucketDetailsHandler)
suite.assert.Nil(api.BucketDeleteRemoteBucketHandler)
suite.assert.Nil(api.BucketAddRemoteBucketHandler)
suite.assert.Nil(api.BucketSetMultiBucketReplicationHandler)
suite.assert.Nil(api.BucketListExternalBucketsHandler)
suite.assert.Nil(api.BucketDeleteBucketReplicationRuleHandler)
suite.assert.Nil(api.BucketDeleteAllReplicationRulesHandler)
suite.assert.Nil(api.BucketDeleteSelectedReplicationRulesHandler)
suite.assert.Nil(api.BucketUpdateMultiBucketReplicationHandler)
}
func (suite *RemoteBucketsTestSuite) assertHandlersAreNotNil(api *operations.ConsoleAPI) {
suite.assert.NotNil(api.BucketListRemoteBucketsHandler)
suite.assert.NotNil(api.BucketRemoteBucketDetailsHandler)
suite.assert.NotNil(api.BucketDeleteRemoteBucketHandler)
suite.assert.NotNil(api.BucketAddRemoteBucketHandler)
suite.assert.NotNil(api.BucketSetMultiBucketReplicationHandler)
suite.assert.NotNil(api.BucketListExternalBucketsHandler)
suite.assert.NotNil(api.BucketDeleteBucketReplicationRuleHandler)
suite.assert.NotNil(api.BucketDeleteAllReplicationRulesHandler)
suite.assert.NotNil(api.BucketDeleteSelectedReplicationRulesHandler)
suite.assert.NotNil(api.BucketUpdateMultiBucketReplicationHandler)
}
func (suite *RemoteBucketsTestSuite) TestListRemoteBucketsHandlerWithError() {
params, api := suite.initListRemoteBucketsRequest()
response := api.BucketListRemoteBucketsHandler.Handle(params, &models.Principal{})
_, ok := response.(*bucketApi.ListRemoteBucketsDefault)
suite.assert.True(ok)
}
func (suite *RemoteBucketsTestSuite) initListRemoteBucketsRequest() (params bucketApi.ListRemoteBucketsParams, api operations.ConsoleAPI) {
registerAdminBucketRemoteHandlers(&api)
params.HTTPRequest = &http.Request{}
return params, api
}
func (suite *RemoteBucketsTestSuite) TestListRemoteBucketsWithoutError() {
ctx := context.Background()
minioListRemoteBucketsMock = func(_ context.Context, _, _ string) (targets []madmin.BucketTarget, err error) {
return []madmin.BucketTarget{{
Credentials: &madmin.Credentials{
AccessKey: "accessKey",
SecretKey: "secretKey",
},
}}, nil
}
res, err := listRemoteBuckets(ctx, &suite.adminClient)
suite.assert.NotNil(res)
suite.assert.Nil(err)
}
func (suite *RemoteBucketsTestSuite) TestRemoteBucketDetailsHandlerWithError() {
params, api := suite.initRemoteBucketDetailsRequest()
response := api.BucketRemoteBucketDetailsHandler.Handle(params, &models.Principal{})
_, ok := response.(*bucketApi.RemoteBucketDetailsDefault)
suite.assert.True(ok)
}
func (suite *RemoteBucketsTestSuite) initRemoteBucketDetailsRequest() (params bucketApi.RemoteBucketDetailsParams, api operations.ConsoleAPI) {
registerAdminBucketRemoteHandlers(&api)
params.HTTPRequest = &http.Request{}
return params, api
}
func (suite *RemoteBucketsTestSuite) TestGetRemoteBucketWithoutError() {
ctx := context.Background()
minioGetRemoteBucketMock = func(_ context.Context, _, _ string) (targets *madmin.BucketTarget, err error) {
return suite.mockBucketTarget, nil
}
res, err := getRemoteBucket(ctx, &suite.adminClient, "bucketName")
suite.assert.Nil(err)
suite.assert.NotNil(res)
suite.assert.Equal(suite.mockRemoteBucket, res)
}
func (suite *RemoteBucketsTestSuite) TestDeleteRemoteBucketHandlerWithError() {
params, api := suite.initDeleteRemoteBucketRequest()
response := api.BucketDeleteRemoteBucketHandler.Handle(params, &models.Principal{})
_, ok := response.(*bucketApi.DeleteRemoteBucketDefault)
suite.assert.True(ok)
}
func (suite *RemoteBucketsTestSuite) initDeleteRemoteBucketRequest() (params bucketApi.DeleteRemoteBucketParams, api operations.ConsoleAPI) {
registerAdminBucketRemoteHandlers(&api)
params.HTTPRequest = &http.Request{}
return params, api
}
func (suite *RemoteBucketsTestSuite) TestAddRemoteBucketHandlerWithError() {
params, api := suite.initAddRemoteBucketRequest()
response := api.BucketAddRemoteBucketHandler.Handle(params, &models.Principal{})
_, ok := response.(*bucketApi.AddRemoteBucketDefault)
suite.assert.True(ok)
}
func (suite *RemoteBucketsTestSuite) initAddRemoteBucketRequest() (params bucketApi.AddRemoteBucketParams, api operations.ConsoleAPI) {
registerAdminBucketRemoteHandlers(&api)
url := "^&*&^%^"
accessKey := "accessKey"
secretKey := "secretKey"
params.HTTPRequest = &http.Request{}
params.Body = &models.CreateRemoteBucket{
TargetURL: &url,
AccessKey: &accessKey,
SecretKey: &secretKey,
}
return params, api
}
func (suite *RemoteBucketsTestSuite) TestAddRemoteBucketWithoutError() {
ctx := context.Background()
minioAddRemoteBucketMock = func(_ context.Context, _ string, _ *madmin.BucketTarget) (string, error) {
return "bucketName", nil
}
url := "https://localhost"
accessKey := "accessKey"
secretKey := "secretKey"
targetBucket := "targetBucket"
syncMode := "async"
sourceBucket := "sourceBucket"
data := models.CreateRemoteBucket{
TargetURL: &url,
TargetBucket: &targetBucket,
AccessKey: &accessKey,
SecretKey: &secretKey,
SyncMode: &syncMode,
HealthCheckPeriod: 10,
SourceBucket: &sourceBucket,
}
res, err := addRemoteBucket(ctx, &suite.adminClient, data)
suite.assert.NotNil(res)
suite.assert.Nil(err)
}
func (suite *RemoteBucketsTestSuite) TestSetMultiBucketReplicationHandlerWithError() {
params, api := suite.initSetMultiBucketReplicationRequest()
response := api.BucketSetMultiBucketReplicationHandler.Handle(params, &models.Principal{})
_, ok := response.(*bucketApi.SetMultiBucketReplicationOK)
suite.assert.True(ok)
}
func (suite *RemoteBucketsTestSuite) initSetMultiBucketReplicationRequest() (params bucketApi.SetMultiBucketReplicationParams, api operations.ConsoleAPI) {
registerAdminBucketRemoteHandlers(&api)
accessKey := "accessKey"
secretKey := "secretKey"
targetURL := "https://localhost"
syncMode := "async"
params.HTTPRequest = &http.Request{}
params.Body = &models.MultiBucketReplication{
BucketsRelation: []*models.MultiBucketsRelation{{}},
AccessKey: &accessKey,
SecretKey: &secretKey,
Region: "region",
TargetURL: &targetURL,
SyncMode: &syncMode,
Bandwidth: 10,
HealthCheckPeriod: 10,
}
return params, api
}
func (suite *RemoteBucketsTestSuite) TestListExternalBucketsHandlerWithError() {
params, api := suite.initListExternalBucketsRequest()
response := api.BucketListExternalBucketsHandler.Handle(params, &models.Principal{})
_, ok := response.(*bucketApi.ListExternalBucketsDefault)
suite.assert.True(ok)
}
func (suite *RemoteBucketsTestSuite) initListExternalBucketsRequest() (params bucketApi.ListExternalBucketsParams, api operations.ConsoleAPI) {
registerAdminBucketRemoteHandlers(&api)
url := "http://localhost:9000"
accessKey := "accessKey"
secretKey := "secretKey"
tls := false
params.HTTPRequest = &http.Request{}
params.Body = &models.ListExternalBucketsParams{
TargetURL: &url,
AccessKey: &accessKey,
SecretKey: &secretKey,
UseTLS: &tls,
}
return params, api
}
func (suite *RemoteBucketsTestSuite) TestListExternalBucketsWithError() {
ctx := context.Background()
minioAccountInfoMock = func(_ context.Context) (madmin.AccountInfo, error) {
return madmin.AccountInfo{}, errors.New("error")
}
res, err := listExternalBuckets(ctx, &suite.adminClient)
suite.assert.NotNil(err)
suite.assert.Nil(res)
}
func (suite *RemoteBucketsTestSuite) TestListExternalBucketsWithoutError() {
ctx := context.Background()
minioAccountInfoMock = func(_ context.Context) (madmin.AccountInfo, error) {
return madmin.AccountInfo{
Buckets: []madmin.BucketAccessInfo{},
}, nil
}
res, err := listExternalBuckets(ctx, &suite.adminClient)
suite.assert.Nil(err)
suite.assert.NotNil(res)
suite.assert.Equal(suite.mockListBuckets, res)
}
func (suite *RemoteBucketsTestSuite) TestDeleteBucketReplicationRuleHandlerWithError() {
params, api := suite.initDeleteBucketReplicationRuleRequest()
response := api.BucketDeleteBucketReplicationRuleHandler.Handle(params, &models.Principal{})
_, ok := response.(*bucketApi.DeleteBucketReplicationRuleDefault)
suite.assert.True(ok)
}
func (suite *RemoteBucketsTestSuite) initDeleteBucketReplicationRuleRequest() (params bucketApi.DeleteBucketReplicationRuleParams, api operations.ConsoleAPI) {
registerAdminBucketRemoteHandlers(&api)
params.HTTPRequest = &http.Request{}
return params, api
}
func (suite *RemoteBucketsTestSuite) TestDeleteAllReplicationRulesHandlerWithError() {
params, api := suite.initDeleteAllReplicationRulesRequest()
response := api.BucketDeleteAllReplicationRulesHandler.Handle(params, &models.Principal{})
_, ok := response.(*bucketApi.DeleteAllReplicationRulesDefault)
suite.assert.True(ok)
}
func (suite *RemoteBucketsTestSuite) initDeleteAllReplicationRulesRequest() (params bucketApi.DeleteAllReplicationRulesParams, api operations.ConsoleAPI) {
registerAdminBucketRemoteHandlers(&api)
params.HTTPRequest = &http.Request{}
return params, api
}
func (suite *RemoteBucketsTestSuite) TestDeleteSelectedReplicationRulesHandlerWithError() {
params, api := suite.initDeleteSelectedReplicationRulesRequest()
response := api.BucketDeleteSelectedReplicationRulesHandler.Handle(params, &models.Principal{})
_, ok := response.(*bucketApi.DeleteSelectedReplicationRulesDefault)
suite.assert.True(ok)
}
func (suite *RemoteBucketsTestSuite) initDeleteSelectedReplicationRulesRequest() (params bucketApi.DeleteSelectedReplicationRulesParams, api operations.ConsoleAPI) {
registerAdminBucketRemoteHandlers(&api)
params.HTTPRequest = &http.Request{}
params.BucketName = "bucketName"
params.Rules = &models.BucketReplicationRuleList{
Rules: []string{"rule1", "rule2"},
}
return params, api
}
func (suite *RemoteBucketsTestSuite) TestUpdateMultiBucketReplicationHandlerWithError() {
params, api := suite.initUpdateMultiBucketReplicationRequest()
response := api.BucketUpdateMultiBucketReplicationHandler.Handle(params, &models.Principal{})
_, ok := response.(*bucketApi.UpdateMultiBucketReplicationDefault)
suite.assert.True(ok)
}
func (suite *RemoteBucketsTestSuite) initUpdateMultiBucketReplicationRequest() (params bucketApi.UpdateMultiBucketReplicationParams, api operations.ConsoleAPI) {
registerAdminBucketRemoteHandlers(&api)
r := &http.Request{}
ctx := context.WithValue(context.Background(), utils.ContextClientIP, "127.0.0.1")
rc := r.WithContext(ctx)
params.HTTPRequest = rc
params.Body = &models.MultiBucketReplicationEdit{}
return params, api
}
func TestRemoteBuckets(t *testing.T) {
suite.Run(t, new(RemoteBucketsTestSuite))
}

View File

@@ -0,0 +1,86 @@
// This file is part of MinIO Console Server
// Copyright (c) 2022 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package api
import (
"context"
"github.com/go-openapi/runtime/middleware"
"github.com/minio/console/api/operations"
siteRepApi "github.com/minio/console/api/operations/site_replication"
"github.com/minio/console/models"
"github.com/minio/madmin-go/v3"
)
func registerSiteReplicationStatusHandler(api *operations.ConsoleAPI) {
api.SiteReplicationGetSiteReplicationStatusHandler = siteRepApi.GetSiteReplicationStatusHandlerFunc(func(params siteRepApi.GetSiteReplicationStatusParams, session *models.Principal) middleware.Responder {
rInfo, err := getSRStatusResponse(session, params)
if err != nil {
return siteRepApi.NewGetSiteReplicationStatusDefault(err.Code).WithPayload(err.APIError)
}
return siteRepApi.NewGetSiteReplicationStatusOK().WithPayload(rInfo)
})
}
func getSRStatusResponse(session *models.Principal, params siteRepApi.GetSiteReplicationStatusParams) (*models.SiteReplicationStatusResponse, *CodedAPIError) {
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
defer cancel()
mAdmin, err := NewMinioAdminClient(params.HTTPRequest.Context(), session)
if err != nil {
return nil, ErrorWithContext(ctx, err)
}
adminClient := AdminClient{Client: mAdmin}
res, err := getSRStats(ctx, adminClient, params)
if err != nil {
return nil, ErrorWithContext(ctx, err)
}
return res, nil
}
func getSRStats(ctx context.Context, client MinioAdmin, params siteRepApi.GetSiteReplicationStatusParams) (info *models.SiteReplicationStatusResponse, err error) {
srParams := madmin.SRStatusOptions{
Buckets: *params.Buckets,
Policies: *params.Policies,
Users: *params.Users,
Groups: *params.Groups,
}
if params.EntityType != nil && params.EntityValue != nil {
srParams.Entity = madmin.GetSREntityType(*params.EntityType)
srParams.EntityValue = *params.EntityValue
}
srInfo, err := client.getSiteReplicationStatus(ctx, srParams)
retInfo := models.SiteReplicationStatusResponse{
BucketStats: &srInfo.BucketStats,
Enabled: srInfo.Enabled,
GroupStats: srInfo.GroupStats,
MaxBuckets: int64(srInfo.MaxBuckets),
MaxGroups: int64(srInfo.MaxGroups),
MaxPolicies: int64(srInfo.MaxPolicies),
MaxUsers: int64(srInfo.MaxUsers),
PolicyStats: &srInfo.PolicyStats,
Sites: &srInfo.Sites,
StatsSummary: srInfo.StatsSummary,
UserStats: &srInfo.UserStats,
}
if err != nil {
return nil, err
}
return &retInfo, nil
}

77
api/admin_service.go Normal file
View File

@@ -0,0 +1,77 @@
// This file is part of MinIO Console Server
// Copyright (c) 2021 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package api
import (
"context"
"time"
"github.com/go-openapi/runtime/middleware"
"github.com/minio/console/api/operations"
"github.com/minio/console/models"
svcApi "github.com/minio/console/api/operations/service"
)
func registerServiceHandlers(api *operations.ConsoleAPI) {
// Restart Service
api.ServiceRestartServiceHandler = svcApi.RestartServiceHandlerFunc(func(params svcApi.RestartServiceParams, session *models.Principal) middleware.Responder {
if err := getRestartServiceResponse(session, params); err != nil {
return svcApi.NewRestartServiceDefault(err.Code).WithPayload(err.APIError)
}
return svcApi.NewRestartServiceNoContent()
})
}
// serviceRestart - restarts the MinIO cluster
func serviceRestart(ctx context.Context, client MinioAdmin) error {
if err := client.serviceRestart(ctx); err != nil {
return err
}
// copy behavior from minio/mc mainAdminServiceRestart()
//
// Max. time taken by the server to shutdown is 5 seconds.
// This can happen when there are lot of s3 requests pending when the server
// receives a restart command.
// Sleep for 6 seconds and then check if the server is online.
time.Sleep(6 * time.Second)
// Fetch the service status of the specified MinIO server
_, err := client.serverInfo(ctx)
if err != nil {
return err
}
return nil
}
// getRestartServiceResponse performs serviceRestart()
func getRestartServiceResponse(session *models.Principal, params svcApi.RestartServiceParams) *CodedAPIError {
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
defer cancel()
mAdmin, err := NewMinioAdminClient(params.HTTPRequest.Context(), session)
if err != nil {
return ErrorWithContext(ctx, err)
}
// create a MinIO Admin Client interface implementation
// defining the client to be used
adminClient := AdminClient{Client: mAdmin}
if err := serviceRestart(ctx, adminClient); err != nil {
return ErrorWithContext(ctx, err)
}
return nil
}

68
api/admin_service_test.go Normal file
View File

@@ -0,0 +1,68 @@
// This file is part of MinIO Console Server
// Copyright (c) 2021 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package api
import (
"context"
"errors"
"testing"
"github.com/minio/madmin-go/v3"
"github.com/stretchr/testify/assert"
)
func TestServiceRestart(t *testing.T) {
assert := assert.New(t)
adminClient := AdminClientMock{}
ctx := context.Background()
function := "serviceRestart()"
// Test-1 : serviceRestart() restart services no errors
// mock function response from listGroups()
minioServiceRestartMock = func(_ context.Context) error {
return nil
}
MinioServerInfoMock = func(_ context.Context) (madmin.InfoMessage, error) {
return madmin.InfoMessage{}, nil
}
if err := serviceRestart(ctx, adminClient); err != nil {
t.Errorf("Failed on %s:, errors occurred: %s", function, err.Error())
}
// Test-2 : serviceRestart() returns errors on client.serviceRestart call
// and see that the errors is handled correctly and returned
minioServiceRestartMock = func(_ context.Context) error {
return errors.New("error")
}
MinioServerInfoMock = func(_ context.Context) (madmin.InfoMessage, error) {
return madmin.InfoMessage{}, nil
}
if err := serviceRestart(ctx, adminClient); assert.Error(err) {
assert.Equal("error", err.Error())
}
// Test-3 : serviceRestart() returns errors on client.serverInfo() call
// and see that the errors is handled correctly and returned
minioServiceRestartMock = func(_ context.Context) error {
return nil
}
MinioServerInfoMock = func(_ context.Context) (madmin.InfoMessage, error) {
return madmin.InfoMessage{}, errors.New("error on server info")
}
if err := serviceRestart(ctx, adminClient); assert.Error(err) {
assert.Equal("error on server info", err.Error())
}
}

View File

@@ -0,0 +1,242 @@
// This file is part of MinIO Console Server
// Copyright (c) 2022 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package api
import (
"context"
"github.com/go-openapi/runtime"
"github.com/go-openapi/runtime/middleware"
"github.com/minio/console/api/operations"
siteRepApi "github.com/minio/console/api/operations/site_replication"
"github.com/minio/console/models"
"github.com/minio/madmin-go/v3"
)
func registerSiteReplicationHandler(api *operations.ConsoleAPI) {
api.SiteReplicationGetSiteReplicationInfoHandler = siteRepApi.GetSiteReplicationInfoHandlerFunc(func(params siteRepApi.GetSiteReplicationInfoParams, session *models.Principal) middleware.Responder {
rInfo, err := getSRInfoResponse(session, params)
if err != nil {
return siteRepApi.NewGetSiteReplicationInfoDefault(err.Code).WithPayload(err.APIError)
}
return siteRepApi.NewGetSiteReplicationInfoOK().WithPayload(rInfo)
})
api.SiteReplicationSiteReplicationInfoAddHandler = siteRepApi.SiteReplicationInfoAddHandlerFunc(func(params siteRepApi.SiteReplicationInfoAddParams, session *models.Principal) middleware.Responder {
eInfo, err := getSRAddResponse(session, params)
if err != nil {
return siteRepApi.NewSiteReplicationInfoAddDefault(err.Code).WithPayload(err.APIError)
}
return siteRepApi.NewSiteReplicationInfoAddOK().WithPayload(eInfo)
})
api.SiteReplicationSiteReplicationRemoveHandler = siteRepApi.SiteReplicationRemoveHandlerFunc(func(params siteRepApi.SiteReplicationRemoveParams, session *models.Principal) middleware.Responder {
remRes, err := getSRRemoveResponse(session, params)
if err != nil {
return siteRepApi.NewSiteReplicationRemoveDefault(err.Code).WithPayload(err.APIError)
}
return siteRepApi.NewSiteReplicationRemoveNoContent().WithPayload(remRes)
})
api.SiteReplicationSiteReplicationEditHandler = siteRepApi.SiteReplicationEditHandlerFunc(func(params siteRepApi.SiteReplicationEditParams, session *models.Principal) middleware.Responder {
eInfo, err := getSREditResponse(session, params)
if err != nil {
return siteRepApi.NewSiteReplicationRemoveDefault(err.Code).WithPayload(err.APIError)
}
return siteRepApi.NewSiteReplicationEditOK().WithPayload(eInfo)
})
}
func getSRInfoResponse(session *models.Principal, params siteRepApi.GetSiteReplicationInfoParams) (*models.SiteReplicationInfoResponse, *CodedAPIError) {
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
defer cancel()
mAdmin, err := NewMinioAdminClient(params.HTTPRequest.Context(), session)
if err != nil {
return nil, ErrorWithContext(ctx, err)
}
adminClient := AdminClient{Client: mAdmin}
res, err := getSRConfig(ctx, adminClient)
if err != nil {
return nil, ErrorWithContext(ctx, err)
}
return res, nil
}
func getSRAddResponse(session *models.Principal, params siteRepApi.SiteReplicationInfoAddParams) (*models.SiteReplicationAddResponse, *CodedAPIError) {
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
defer cancel()
mAdmin, err := NewMinioAdminClient(params.HTTPRequest.Context(), session)
if err != nil {
return nil, ErrorWithContext(ctx, err)
}
adminClient := AdminClient{Client: mAdmin}
res, err := addSiteReplication(ctx, adminClient, &params)
if err != nil {
return nil, ErrorWithContext(ctx, err)
}
return res, nil
}
func getSREditResponse(session *models.Principal, params siteRepApi.SiteReplicationEditParams) (*models.PeerSiteEditResponse, *CodedAPIError) {
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
defer cancel()
mAdmin, err := NewMinioAdminClient(params.HTTPRequest.Context(), session)
if err != nil {
return nil, ErrorWithContext(ctx, err)
}
adminClient := AdminClient{Client: mAdmin}
eRes, err := editSiteReplication(ctx, adminClient, &params)
if err != nil {
return nil, ErrorWithContext(ctx, err)
}
return eRes, nil
}
func getSRRemoveResponse(session *models.Principal, params siteRepApi.SiteReplicationRemoveParams) (*models.PeerSiteRemoveResponse, *CodedAPIError) {
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
defer cancel()
mAdmin, err := NewMinioAdminClient(params.HTTPRequest.Context(), session)
if err != nil {
return nil, ErrorWithContext(ctx, err)
}
adminClient := AdminClient{Client: mAdmin}
rRes, err := removeSiteReplication(ctx, adminClient, &params)
if err != nil {
return nil, ErrorWithContext(ctx, err)
}
return rRes, nil
}
func getSRConfig(ctx context.Context, client MinioAdmin) (info *models.SiteReplicationInfoResponse, err error) {
srInfo, err := client.getSiteReplicationInfo(ctx)
if err != nil {
return nil, err
}
var sites []*models.PeerInfo
if len(srInfo.Sites) > 0 {
for _, s := range srInfo.Sites {
pInfo := &models.PeerInfo{
DeploymentID: s.DeploymentID,
Endpoint: s.Endpoint,
Name: s.Name,
}
sites = append(sites, pInfo)
}
}
res := &models.SiteReplicationInfoResponse{
Enabled: srInfo.Enabled,
Name: srInfo.Name,
ServiceAccountAccessKey: srInfo.ServiceAccountAccessKey,
Sites: sites,
}
return res, nil
}
func addSiteReplication(ctx context.Context, client MinioAdmin, params *siteRepApi.SiteReplicationInfoAddParams) (info *models.SiteReplicationAddResponse, err error) {
var rSites []madmin.PeerSite
if len(params.Body) > 0 {
for _, aSite := range params.Body {
pInfo := &madmin.PeerSite{
AccessKey: aSite.AccessKey,
Name: aSite.Name,
SecretKey: aSite.SecretKey,
Endpoint: aSite.Endpoint,
}
rSites = append(rSites, *pInfo)
}
}
qs := runtime.Values(params.HTTPRequest.URL.Query())
_, qhkReplicateILMExpiry, _ := qs.GetOK("replicate-ilm-expiry")
var opts madmin.SRAddOptions
if qhkReplicateILMExpiry {
opts.ReplicateILMExpiry = true
}
cc, err := client.addSiteReplicationInfo(ctx, rSites, opts)
if err != nil {
return nil, err
}
res := &models.SiteReplicationAddResponse{
ErrorDetail: cc.ErrDetail,
InitialSyncErrorMessage: cc.InitialSyncErrorMessage,
Status: cc.Status,
Success: cc.Success,
}
return res, nil
}
func editSiteReplication(ctx context.Context, client MinioAdmin, params *siteRepApi.SiteReplicationEditParams) (info *models.PeerSiteEditResponse, err error) {
peerSiteInfo := &madmin.PeerInfo{
Endpoint: params.Body.Endpoint, // only endpoint can be edited.
Name: params.Body.Name, // does not get updated.
DeploymentID: params.Body.DeploymentID, // readonly
}
qs := runtime.Values(params.HTTPRequest.URL.Query())
_, qhkDisableILMExpiryReplication, _ := qs.GetOK("disable-ilm-expiry-replication")
_, qhkEnableILMExpiryReplication, _ := qs.GetOK("enable-ilm-expiry-replication")
var opts madmin.SREditOptions
if qhkDisableILMExpiryReplication {
opts.DisableILMExpiryReplication = true
}
if qhkEnableILMExpiryReplication {
opts.EnableILMExpiryReplication = true
}
eRes, err := client.editSiteReplicationInfo(ctx, *peerSiteInfo, opts)
if err != nil {
return nil, err
}
editRes := &models.PeerSiteEditResponse{
ErrorDetail: eRes.ErrDetail,
Status: eRes.Status,
Success: eRes.Success,
}
return editRes, nil
}
func removeSiteReplication(ctx context.Context, client MinioAdmin, params *siteRepApi.SiteReplicationRemoveParams) (info *models.PeerSiteRemoveResponse, err error) {
delAll := params.Body.All
siteNames := params.Body.Sites
var req *madmin.SRRemoveReq
if delAll {
req = &madmin.SRRemoveReq{
RemoveAll: delAll,
}
} else {
req = &madmin.SRRemoveReq{
SiteNames: siteNames,
RemoveAll: delAll,
}
}
rRes, err := client.deleteSiteReplicationInfo(ctx, *req)
if err != nil {
return nil, err
}
removeRes := &models.PeerSiteRemoveResponse{
ErrorDetail: rRes.ErrDetail,
Status: rRes.Status,
}
return removeRes, nil
}

View File

@@ -0,0 +1,255 @@
// This file is part of MinIO Console Server
// Copyright (c) 2022 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// These tests are for AdminAPI Tag based on swagger-console.yml
package api
import (
"context"
"fmt"
"testing"
"github.com/minio/madmin-go/v3"
"github.com/stretchr/testify/assert"
)
func TestGetSiteReplicationInfo(t *testing.T) {
assert := assert.New(t)
// mock minIO client
adminClient := AdminClientMock{}
function := "getSiteReplicationInfo()"
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
retValueMock := madmin.SiteReplicationInfo{
Enabled: true,
Name: "site1",
Sites: []madmin.PeerInfo{
{
Endpoint: "http://localhost:9000",
Name: "site1",
DeploymentID: "12345",
},
{
Endpoint: "http://localhost:9001",
Name: "site2",
DeploymentID: "123456",
},
},
ServiceAccountAccessKey: "test-key",
}
expValueMock := &madmin.SiteReplicationInfo{
Enabled: true,
Name: "site1",
Sites: []madmin.PeerInfo{
{
Endpoint: "http://localhost:9000",
Name: "site1",
DeploymentID: "12345",
},
{
Endpoint: "http://localhost:9001",
Name: "site2",
DeploymentID: "123456",
},
},
ServiceAccountAccessKey: "test-key",
}
getSiteReplicationInfo = func(_ context.Context) (info *madmin.SiteReplicationInfo, err error) {
return &retValueMock, nil
}
srInfo, err := adminClient.getSiteReplicationInfo(ctx)
assert.Nil(err)
assert.Equal(expValueMock, srInfo, fmt.Sprintf("Failed on %s: length of lists is not the same", function))
}
func TestAddSiteReplicationInfo(t *testing.T) {
assert := assert.New(t)
// mock minIO client
adminClient := AdminClientMock{}
function := "addSiteReplicationInfo()"
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
retValueMock := &madmin.ReplicateAddStatus{
Success: true,
Status: "success",
ErrDetail: "",
InitialSyncErrorMessage: "",
}
expValueMock := &madmin.ReplicateAddStatus{
Success: true,
Status: "success",
ErrDetail: "",
InitialSyncErrorMessage: "",
}
addSiteReplicationInfo = func(_ context.Context, _ []madmin.PeerSite) (res *madmin.ReplicateAddStatus, err error) {
return retValueMock, nil
}
sites := []madmin.PeerSite{
{
Name: "site1",
Endpoint: "http://localhost:9000",
AccessKey: "test",
SecretKey: "test",
},
{
Name: "site2",
Endpoint: "http://localhost:9001",
AccessKey: "test",
SecretKey: "test",
},
}
srInfo, err := adminClient.addSiteReplicationInfo(ctx, sites, madmin.SRAddOptions{})
assert.Nil(err)
assert.Equal(expValueMock, srInfo, fmt.Sprintf("Failed on %s: length of lists is not the same", function))
}
func TestEditSiteReplicationInfo(t *testing.T) {
assert := assert.New(t)
// mock minIO client
adminClient := AdminClientMock{}
function := "editSiteReplicationInfo()"
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
retValueMock := &madmin.ReplicateEditStatus{
Success: true,
Status: "success",
ErrDetail: "",
}
expValueMock := &madmin.ReplicateEditStatus{
Success: true,
Status: "success",
ErrDetail: "",
}
editSiteReplicationInfo = func(_ context.Context, _ madmin.PeerInfo) (res *madmin.ReplicateEditStatus, err error) {
return retValueMock, nil
}
site := madmin.PeerInfo{
Name: "",
Endpoint: "",
DeploymentID: "12345",
}
srInfo, err := adminClient.editSiteReplicationInfo(ctx, site, madmin.SREditOptions{})
assert.Nil(err)
assert.Equal(expValueMock, srInfo, fmt.Sprintf("Failed on %s: length of lists is not the same", function))
}
func TestDeleteSiteReplicationInfo(t *testing.T) {
assert := assert.New(t)
// mock minIO client
adminClient := AdminClientMock{}
function := "deleteSiteReplicationInfo()"
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
retValueMock := &madmin.ReplicateRemoveStatus{
Status: "success",
ErrDetail: "",
}
expValueMock := &madmin.ReplicateRemoveStatus{
Status: "success",
ErrDetail: "",
}
deleteSiteReplicationInfoMock = func(_ context.Context, _ madmin.SRRemoveReq) (res *madmin.ReplicateRemoveStatus, err error) {
return retValueMock, nil
}
remReq := madmin.SRRemoveReq{
SiteNames: []string{
"test1",
},
RemoveAll: false,
}
srInfo, err := adminClient.deleteSiteReplicationInfo(ctx, remReq)
assert.Nil(err)
assert.Equal(expValueMock, srInfo, fmt.Sprintf("Failed on %s: length of lists is not the same", function))
}
func TestSiteReplicationStatus(t *testing.T) {
assert := assert.New(t)
// mock minIO client
adminClient := AdminClientMock{}
function := "getSiteReplicationStatus()"
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
retValueMock := madmin.SRStatusInfo{
Enabled: true,
MaxBuckets: 0,
MaxUsers: 0,
MaxGroups: 0,
MaxPolicies: 0,
Sites: nil,
StatsSummary: nil,
BucketStats: nil,
PolicyStats: nil,
UserStats: nil,
GroupStats: nil,
}
expValueMock := &madmin.SRStatusInfo{
Enabled: true,
MaxBuckets: 0,
MaxUsers: 0,
MaxGroups: 0,
MaxPolicies: 0,
Sites: nil,
StatsSummary: nil,
BucketStats: nil,
PolicyStats: nil,
UserStats: nil,
GroupStats: nil,
}
getSiteReplicationStatus = func(_ context.Context, _ madmin.SRStatusOptions) (info *madmin.SRStatusInfo, err error) {
return &retValueMock, nil
}
reqValues := madmin.SRStatusOptions{
Buckets: true,
Policies: true,
Users: true,
Groups: true,
}
srInfo, err := adminClient.getSiteReplicationStatus(ctx, reqValues)
if err != nil {
assert.Error(err)
}
assert.Equal(expValueMock, srInfo, fmt.Sprintf("Failed on %s: expected result is not same", function))
}

View File

@@ -14,7 +14,7 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package restapi
package api
import (
"context"
@@ -25,8 +25,8 @@ import (
"time"
"github.com/dustin/go-humanize"
"github.com/gorilla/websocket"
"github.com/minio/madmin-go"
"github.com/minio/madmin-go/v3"
"github.com/minio/websocket"
)
// getSpeedtesthOptionsFromReq gets duration, size & concurrent requests from a websocket
@@ -60,15 +60,10 @@ func getSpeedtestOptionsFromReq(req *http.Request) (*madmin.SpeedtestOpts, error
}
size, err := humanize.ParseBytes(paramSize)
if err != nil {
return nil, fmt.Errorf("unable to parse object size")
}
if size < 0 {
return nil, fmt.Errorf("size is expected to be atleast 0 bytes")
}
optionsSet.Size = int(size)
paramConcurrent := queryPairs.Get("concurrent")
@@ -78,7 +73,6 @@ func getSpeedtestOptionsFromReq(req *http.Request) (*madmin.SpeedtestOpts, error
}
concurrent, err := strconv.Atoi(paramConcurrent)
if err != nil {
return nil, fmt.Errorf("invalid concurrent value: %s", paramConcurrent)
}
@@ -100,7 +94,6 @@ func getSpeedtestOptionsFromReq(req *http.Request) (*madmin.SpeedtestOpts, error
func startSpeedtest(ctx context.Context, conn WSConn, client MinioAdmin, speedtestOpts *madmin.SpeedtestOpts) error {
speedtestRes, err := client.speedtest(ctx, *speedtestOpts)
if err != nil {
LogError("error initializing speedtest: %v", err)
return err

435
api/admin_subnet.go Normal file
View File

@@ -0,0 +1,435 @@
// This file is part of MinIO Console Server
// Copyright (c) 2021 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
package api
import (
"context"
"errors"
"fmt"
"net/http"
"net/url"
"os"
"github.com/minio/console/pkg/utils"
xhttp "github.com/minio/console/pkg/http"
"github.com/go-openapi/runtime/middleware"
"github.com/minio/console/api/operations"
subnetApi "github.com/minio/console/api/operations/subnet"
"github.com/minio/console/models"
"github.com/minio/console/pkg/subnet"
"github.com/minio/madmin-go/v3"
)
func registerSubnetHandlers(api *operations.ConsoleAPI) {
// Get subnet login handler
api.SubnetSubnetLoginHandler = subnetApi.SubnetLoginHandlerFunc(func(params subnetApi.SubnetLoginParams, session *models.Principal) middleware.Responder {
resp, err := GetSubnetLoginResponse(session, params)
if err != nil {
return subnetApi.NewSubnetLoginDefault(err.Code).WithPayload(err.APIError)
}
return subnetApi.NewSubnetLoginOK().WithPayload(resp)
})
// Get subnet login with MFA handler
api.SubnetSubnetLoginMFAHandler = subnetApi.SubnetLoginMFAHandlerFunc(func(params subnetApi.SubnetLoginMFAParams, session *models.Principal) middleware.Responder {
resp, err := GetSubnetLoginWithMFAResponse(session, params)
if err != nil {
return subnetApi.NewSubnetLoginMFADefault(err.Code).WithPayload(err.APIError)
}
return subnetApi.NewSubnetLoginMFAOK().WithPayload(resp)
})
// Get subnet register
api.SubnetSubnetRegisterHandler = subnetApi.SubnetRegisterHandlerFunc(func(params subnetApi.SubnetRegisterParams, session *models.Principal) middleware.Responder {
err := GetSubnetRegisterResponse(session, params)
if err != nil {
return subnetApi.NewSubnetRegisterDefault(err.Code).WithPayload(err.APIError)
}
return subnetApi.NewSubnetRegisterOK()
})
// Get subnet info
api.SubnetSubnetInfoHandler = subnetApi.SubnetInfoHandlerFunc(func(params subnetApi.SubnetInfoParams, session *models.Principal) middleware.Responder {
resp, err := GetSubnetInfoResponse(session, params)
if err != nil {
return subnetApi.NewSubnetInfoDefault(err.Code).WithPayload(err.APIError)
}
return subnetApi.NewSubnetInfoOK().WithPayload(resp)
})
// Get subnet registration token
api.SubnetSubnetRegTokenHandler = subnetApi.SubnetRegTokenHandlerFunc(func(params subnetApi.SubnetRegTokenParams, session *models.Principal) middleware.Responder {
resp, err := GetSubnetRegTokenResponse(session, params)
if err != nil {
return subnetApi.NewSubnetRegTokenDefault(err.Code).WithPayload(err.APIError)
}
return subnetApi.NewSubnetRegTokenOK().WithPayload(resp)
})
api.SubnetSubnetAPIKeyHandler = subnetApi.SubnetAPIKeyHandlerFunc(func(params subnetApi.SubnetAPIKeyParams, session *models.Principal) middleware.Responder {
resp, err := GetSubnetAPIKeyResponse(session, params)
if err != nil {
return subnetApi.NewSubnetAPIKeyDefault(err.Code).WithPayload(err.APIError)
}
return subnetApi.NewSubnetAPIKeyOK().WithPayload(resp)
})
}
const EnvSubnetLicense = "CONSOLE_SUBNET_LICENSE"
func SubnetRegisterWithAPIKey(ctx context.Context, minioClient MinioAdmin, apiKey string) (bool, error) {
serverInfo, err := minioClient.serverInfo(ctx)
if err != nil {
return false, err
}
clientIP := utils.ClientIPFromContext(ctx)
registerResult, err := subnet.Register(GetConsoleHTTPClient(clientIP), serverInfo, apiKey, "", "")
if err != nil {
return false, err
}
// Keep existing subnet proxy if exists
subnetKey, err := GetSubnetKeyFromMinIOConfig(ctx, minioClient)
if err != nil {
return false, err
}
configStr := fmt.Sprintf("subnet license=%s api_key=%s proxy=%s", registerResult.License, registerResult.APIKey, subnetKey.Proxy)
_, err = minioClient.setConfigKV(ctx, configStr)
if err != nil {
return false, err
}
// cluster registered correctly
return true, nil
}
func SubnetLogin(client xhttp.ClientI, username, password string) (string, string, error) {
tokens, err := subnet.Login(client, username, password)
if err != nil {
return "", "", err
}
if tokens.MfaToken != "" {
// user needs to complete login flow using mfa
return "", tokens.MfaToken, nil
}
if tokens.AccessToken != "" {
// register token to minio
return tokens.AccessToken, "", nil
}
return "", "", errors.New("something went wrong")
}
func GetSubnetLoginResponse(session *models.Principal, params subnetApi.SubnetLoginParams) (*models.SubnetLoginResponse, *CodedAPIError) {
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
defer cancel()
mAdmin, err := NewMinioAdminClient(params.HTTPRequest.Context(), session)
if err != nil {
return nil, ErrorWithContext(ctx, err)
}
return subnetLoginResponse(ctx, AdminClient{Client: mAdmin}, params)
}
func subnetLoginResponse(ctx context.Context, minioClient MinioAdmin, params subnetApi.SubnetLoginParams) (*models.SubnetLoginResponse, *CodedAPIError) {
subnetHTTPClient, err := GetSubnetHTTPClient(ctx, minioClient)
if err != nil {
return nil, ErrorWithContext(ctx, err)
}
apiKey := params.Body.APIKey
if apiKey != "" {
registered, err := SubnetRegisterWithAPIKey(ctx, minioClient, apiKey)
if err != nil {
return nil, ErrorWithContext(ctx, err)
}
return &models.SubnetLoginResponse{
Registered: registered,
Organizations: []*models.SubnetOrganization{},
}, nil
}
username := params.Body.Username
password := params.Body.Password
if username != "" && password != "" {
token, mfa, err := SubnetLogin(subnetHTTPClient, username, password)
if err != nil {
return nil, ErrorWithContext(ctx, err)
}
return &models.SubnetLoginResponse{
MfaToken: mfa,
AccessToken: token,
Organizations: []*models.SubnetOrganization{},
}, nil
}
return nil, ErrorWithContext(ctx, ErrDefault)
}
type SubnetRegistration struct {
AccessToken string
MFAToken string
Organizations []models.SubnetOrganization
}
func SubnetLoginWithMFA(client xhttp.ClientI, username, mfaToken, otp string) (*models.SubnetLoginResponse, error) {
tokens, err := subnet.LoginWithMFA(client, username, mfaToken, otp)
if err != nil {
return nil, err
}
if tokens.AccessToken != "" {
organizations, errOrg := subnet.GetOrganizations(client, tokens.AccessToken)
if errOrg != nil {
return nil, errOrg
}
return &models.SubnetLoginResponse{
AccessToken: tokens.AccessToken,
Organizations: organizations,
}, nil
}
return nil, errors.New("something went wrong")
}
// GetSubnetHTTPClient will return a client with proxy if configured, otherwise will return the default console http client
func GetSubnetHTTPClient(ctx context.Context, minioClient MinioAdmin) (*xhttp.Client, error) {
clientIP := utils.ClientIPFromContext(ctx)
subnetKey, err := GetSubnetKeyFromMinIOConfig(ctx, minioClient)
if err != nil {
return nil, err
}
proxy := getSubnetProxy()
if subnetKey.Proxy != "" {
proxy = subnetKey.Proxy
}
tr := GlobalTransport.Clone()
if proxy != "" {
u, err := url.Parse(proxy)
if err != nil {
return nil, err
}
tr.Proxy = http.ProxyURL(u)
}
return &xhttp.Client{
Client: &http.Client{
Transport: &ConsoleTransport{
Transport: tr,
ClientIP: clientIP,
},
},
}, nil
}
func GetSubnetLoginWithMFAResponse(session *models.Principal, params subnetApi.SubnetLoginMFAParams) (*models.SubnetLoginResponse, *CodedAPIError) {
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
defer cancel()
mAdmin, err := NewMinioAdminClient(params.HTTPRequest.Context(), session)
if err != nil {
return nil, ErrorWithContext(ctx, err)
}
minioClient := AdminClient{Client: mAdmin}
return subnetLoginWithMFAResponse(ctx, minioClient, params)
}
func subnetLoginWithMFAResponse(ctx context.Context, minioClient MinioAdmin, params subnetApi.SubnetLoginMFAParams) (*models.SubnetLoginResponse, *CodedAPIError) {
subnetHTTPClient, err := GetSubnetHTTPClient(ctx, minioClient)
if err != nil {
return nil, ErrorWithContext(ctx, err)
}
resp, err := SubnetLoginWithMFA(subnetHTTPClient, *params.Body.Username, *params.Body.MfaToken, *params.Body.Otp)
if err != nil {
return nil, ErrorWithContext(ctx, err)
}
return resp, nil
}
func GetSubnetKeyFromMinIOConfig(ctx context.Context, minioClient MinioAdmin) (*subnet.LicenseTokenConfig, error) {
buf, err := minioClient.getConfigKV(ctx, madmin.SubnetSubSys)
if err != nil {
return nil, err
}
subSysConfigs, err := madmin.ParseServerConfigOutput(string(buf))
if err != nil {
return nil, err
}
for _, scfg := range subSysConfigs {
if scfg.Target == "" {
res := subnet.LicenseTokenConfig{}
res.APIKey, _ = scfg.Lookup("api_key")
res.License, _ = scfg.Lookup("license")
res.Proxy, _ = scfg.Lookup("proxy")
return &res, nil
}
}
return nil, errors.New("unable to find subnet configuration")
}
func GetSubnetRegister(ctx context.Context, minioClient MinioAdmin, httpClient xhttp.ClientI, params subnetApi.SubnetRegisterParams) error {
serverInfo, err := minioClient.serverInfo(ctx)
if err != nil {
return err
}
registerResult, err := subnet.Register(httpClient, serverInfo, "", *params.Body.Token, *params.Body.AccountID)
if err != nil {
return err
}
// Keep existing subnet proxy if exists
subnetKey, err := GetSubnetKeyFromMinIOConfig(ctx, minioClient)
if err != nil {
return err
}
configStr := fmt.Sprintf("subnet license=%s api_key=%s proxy=%s", registerResult.License, registerResult.APIKey, subnetKey.Proxy)
_, err = minioClient.setConfigKV(ctx, configStr)
if err != nil {
return err
}
return nil
}
func GetSubnetRegisterResponse(session *models.Principal, params subnetApi.SubnetRegisterParams) *CodedAPIError {
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
defer cancel()
mAdmin, err := NewMinioAdminClient(params.HTTPRequest.Context(), session)
if err != nil {
return ErrorWithContext(ctx, err)
}
adminClient := AdminClient{Client: mAdmin}
return subnetRegisterResponse(ctx, adminClient, params)
}
func subnetRegisterResponse(ctx context.Context, minioClient MinioAdmin, params subnetApi.SubnetRegisterParams) *CodedAPIError {
subnetHTTPClient, err := GetSubnetHTTPClient(ctx, minioClient)
if err != nil {
return ErrorWithContext(ctx, err)
}
err = GetSubnetRegister(ctx, minioClient, subnetHTTPClient, params)
if err != nil {
return ErrorWithContext(ctx, err)
}
return nil
}
var ErrSubnetLicenseNotFound = errors.New("license not found")
func GetSubnetInfoResponse(session *models.Principal, params subnetApi.SubnetInfoParams) (*models.License, *CodedAPIError) {
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
defer cancel()
clientIP := utils.ClientIPFromContext(ctx)
client := &xhttp.Client{
Client: GetConsoleHTTPClient(clientIP),
}
// license gets seeded to us by MinIO
seededLicense := os.Getenv(EnvSubnetLicense)
// if it's missing, we will gracefully fallback to attempt to fetch it from MinIO
if seededLicense == "" {
mAdmin, err := NewMinioAdminClient(params.HTTPRequest.Context(), session)
if err != nil {
return nil, ErrorWithContext(ctx, err)
}
adminClient := AdminClient{Client: mAdmin}
configBytes, err := adminClient.getConfigKV(params.HTTPRequest.Context(), "subnet")
if err != nil {
return nil, ErrorWithContext(ctx, err)
}
subSysConfigs, err := madmin.ParseServerConfigOutput(string(configBytes))
if err != nil {
return nil, ErrorWithContext(ctx, err)
}
// search for licese
for _, v := range subSysConfigs {
for _, sv := range v.KV {
if sv.Key == "license" {
seededLicense = sv.Value
}
}
}
}
// still empty means not found
if seededLicense == "" {
return nil, ErrorWithContext(ctx, ErrSubnetLicenseNotFound)
}
licenseInfo, err := getLicenseInfo(*client.Client, seededLicense)
if err != nil {
return nil, ErrorWithContext(ctx, err)
}
license := &models.License{
Email: licenseInfo.Email,
AccountID: licenseInfo.AccountID,
StorageCapacity: licenseInfo.StorageCapacity,
Plan: licenseInfo.Plan,
ExpiresAt: licenseInfo.ExpiresAt.String(),
Organization: licenseInfo.Organization,
}
return license, nil
}
func GetSubnetRegToken(ctx context.Context, minioClient MinioAdmin) (string, error) {
serverInfo, err := minioClient.serverInfo(ctx)
if err != nil {
return "", err
}
regInfo := subnet.GetClusterRegInfo(serverInfo)
regToken, err := subnet.GenerateRegToken(regInfo)
if err != nil {
return "", err
}
return regToken, nil
}
func GetSubnetRegTokenResponse(session *models.Principal, params subnetApi.SubnetRegTokenParams) (*models.SubnetRegTokenResponse, *CodedAPIError) {
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
defer cancel()
mAdmin, err := NewMinioAdminClient(params.HTTPRequest.Context(), session)
if err != nil {
return nil, ErrorWithContext(ctx, err)
}
adminClient := AdminClient{Client: mAdmin}
return subnetRegTokenResponse(ctx, adminClient)
}
func subnetRegTokenResponse(ctx context.Context, minioClient MinioAdmin) (*models.SubnetRegTokenResponse, *CodedAPIError) {
token, err := GetSubnetRegToken(ctx, minioClient)
if err != nil {
return nil, ErrorWithContext(ctx, err)
}
return &models.SubnetRegTokenResponse{
RegToken: token,
}, nil
}
func GetSubnetAPIKeyResponse(session *models.Principal, params subnetApi.SubnetAPIKeyParams) (*models.APIKey, *CodedAPIError) {
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
defer cancel()
mAdmin, err := NewMinioAdminClient(params.HTTPRequest.Context(), session)
if err != nil {
return nil, ErrorWithContext(ctx, err)
}
adminClient := AdminClient{Client: mAdmin}
return subnetAPIKeyResponse(ctx, adminClient, params)
}
func subnetAPIKeyResponse(ctx context.Context, minioClient MinioAdmin, params subnetApi.SubnetAPIKeyParams) (*models.APIKey, *CodedAPIError) {
subnetHTTPClient, err := GetSubnetHTTPClient(ctx, minioClient)
if err != nil {
return nil, ErrorWithContext(ctx, err)
}
token := params.HTTPRequest.URL.Query().Get("token")
apiKey, err := subnet.GetAPIKey(subnetHTTPClient, token)
if err != nil {
return nil, ErrorWithContext(ctx, err)
}
return &models.APIKey{APIKey: apiKey}, nil
}

233
api/admin_subnet_test.go Normal file
View File

@@ -0,0 +1,233 @@
// This file is part of MinIO Console Server
// Copyright (c) 2022 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package api
import (
"context"
"net/http"
"net/http/httptest"
"net/url"
"os"
"testing"
"github.com/minio/console/api/operations"
subnetApi "github.com/minio/console/api/operations/subnet"
"github.com/minio/console/models"
"github.com/minio/madmin-go/v3"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/suite"
)
type AdminSubnetTestSuite struct {
suite.Suite
assert *assert.Assertions
currentServer string
isServerSet bool
server *httptest.Server
adminClient AdminClientMock
}
func (suite *AdminSubnetTestSuite) SetupSuite() {
suite.assert = assert.New(suite.T())
suite.adminClient = AdminClientMock{}
minioGetConfigKVMock = func(_ string) ([]byte, error) {
return []byte("subnet license=mock api_key=mock proxy=http://mock.com"), nil
}
MinioServerInfoMock = func(_ context.Context) (madmin.InfoMessage, error) {
return madmin.InfoMessage{Servers: []madmin.ServerProperties{{}}}, nil
}
}
func (suite *AdminSubnetTestSuite) SetupTest() {
suite.server = httptest.NewServer(http.HandlerFunc(suite.serverHandler))
suite.currentServer, suite.isServerSet = os.LookupEnv(ConsoleMinIOServer)
os.Setenv(ConsoleMinIOServer, suite.server.URL)
}
func (suite *AdminSubnetTestSuite) serverHandler(w http.ResponseWriter, _ *http.Request) {
w.WriteHeader(400)
}
func (suite *AdminSubnetTestSuite) TearDownSuite() {
}
func (suite *AdminSubnetTestSuite) TearDownTest() {
if suite.isServerSet {
os.Setenv(ConsoleMinIOServer, suite.currentServer)
} else {
os.Unsetenv(ConsoleMinIOServer)
}
}
func (suite *AdminSubnetTestSuite) TestRegisterSubnetHandlers() {
api := &operations.ConsoleAPI{}
suite.assertHandlersAreNil(api)
registerSubnetHandlers(api)
suite.assertHandlersAreNotNil(api)
}
func (suite *AdminSubnetTestSuite) assertHandlersAreNil(api *operations.ConsoleAPI) {
suite.assert.Nil(api.SubnetSubnetLoginHandler)
suite.assert.Nil(api.SubnetSubnetLoginMFAHandler)
suite.assert.Nil(api.SubnetSubnetRegisterHandler)
suite.assert.Nil(api.SubnetSubnetInfoHandler)
suite.assert.Nil(api.SubnetSubnetRegTokenHandler)
suite.assert.Nil(api.SubnetSubnetAPIKeyHandler)
}
func (suite *AdminSubnetTestSuite) assertHandlersAreNotNil(api *operations.ConsoleAPI) {
suite.assert.NotNil(api.SubnetSubnetLoginHandler)
suite.assert.NotNil(api.SubnetSubnetLoginMFAHandler)
suite.assert.NotNil(api.SubnetSubnetRegisterHandler)
suite.assert.NotNil(api.SubnetSubnetInfoHandler)
suite.assert.NotNil(api.SubnetSubnetRegTokenHandler)
suite.assert.NotNil(api.SubnetSubnetAPIKeyHandler)
}
func (suite *AdminSubnetTestSuite) TestSubnetLoginWithSubnetClientError() {
params, api := suite.initSubnetLoginRequest("", "", "")
response := api.SubnetSubnetLoginHandler.Handle(params, &models.Principal{})
_, ok := response.(*subnetApi.SubnetLoginDefault)
suite.assert.True(ok)
}
func (suite *AdminSubnetTestSuite) TestSubnetLoginResponseWithApiKeyError() {
params, _ := suite.initSubnetLoginRequest("mock", "", "")
res, err := subnetLoginResponse(context.TODO(), suite.adminClient, params)
suite.assert.NotNil(err)
suite.assert.Nil(res)
}
func (suite *AdminSubnetTestSuite) TestSubnetLoginResponseWithCredentialsError() {
params, _ := suite.initSubnetLoginRequest("", "mock", "mock")
res, err := subnetLoginResponse(context.TODO(), suite.adminClient, params)
suite.assert.NotNil(err)
suite.assert.Nil(res)
}
func (suite *AdminSubnetTestSuite) initSubnetLoginRequest(apiKey, username, password string) (params subnetApi.SubnetLoginParams, api operations.ConsoleAPI) {
registerSubnetHandlers(&api)
params.HTTPRequest = &http.Request{}
params.Body = &models.SubnetLoginRequest{}
params.Body.APIKey = apiKey
params.Body.Username = username
params.Body.Password = password
return params, api
}
func (suite *AdminSubnetTestSuite) TestSubnetLoginMFAWithSubnetClientError() {
params, api := suite.initSubnetLoginMFARequest("", "", "")
response := api.SubnetSubnetLoginMFAHandler.Handle(params, &models.Principal{})
_, ok := response.(*subnetApi.SubnetLoginMFADefault)
suite.assert.True(ok)
}
func (suite *AdminSubnetTestSuite) TestSubnetLoginWithMFAResponseError() {
params, _ := suite.initSubnetLoginMFARequest("mock", "mock", "mock")
res, err := subnetLoginWithMFAResponse(context.TODO(), suite.adminClient, params)
suite.assert.NotNil(err)
suite.assert.Nil(res)
}
func (suite *AdminSubnetTestSuite) initSubnetLoginMFARequest(username, mfaToken, otp string) (params subnetApi.SubnetLoginMFAParams, api operations.ConsoleAPI) {
registerSubnetHandlers(&api)
params.HTTPRequest = &http.Request{}
params.Body = &models.SubnetLoginMFARequest{}
params.Body.Username = &username
params.Body.MfaToken = &mfaToken
params.Body.Otp = &otp
return params, api
}
func (suite *AdminSubnetTestSuite) TestSubnetRegisterClientError() {
params, api := suite.initSubnetRegisterRequest("", "")
response := api.SubnetSubnetRegisterHandler.Handle(params, &models.Principal{})
_, ok := response.(*subnetApi.SubnetRegisterDefault)
suite.assert.True(ok)
}
func (suite *AdminSubnetTestSuite) TestSubnetRegisterResponseError() {
params, _ := suite.initSubnetRegisterRequest("mock", "mock")
err := subnetRegisterResponse(context.TODO(), suite.adminClient, params)
suite.assert.NotNil(err)
}
func (suite *AdminSubnetTestSuite) initSubnetRegisterRequest(token, accountID string) (params subnetApi.SubnetRegisterParams, api operations.ConsoleAPI) {
registerSubnetHandlers(&api)
params.HTTPRequest = &http.Request{}
params.Body = &models.SubnetRegisterRequest{}
params.Body.Token = &token
params.Body.AccountID = &accountID
return params, api
}
func (suite *AdminSubnetTestSuite) TestSubnetInfoError() {
params, api := suite.initSubnetInfoRequest()
response := api.SubnetSubnetInfoHandler.Handle(params, &models.Principal{})
_, ok := response.(*subnetApi.SubnetInfoDefault)
suite.assert.True(ok)
}
func (suite *AdminSubnetTestSuite) initSubnetInfoRequest() (params subnetApi.SubnetInfoParams, api operations.ConsoleAPI) {
registerSubnetHandlers(&api)
params.HTTPRequest = &http.Request{}
return params, api
}
func (suite *AdminSubnetTestSuite) TestSubnetRegTokenError() {
params, api := suite.initSubnetRegTokenRequest()
response := api.SubnetSubnetRegTokenHandler.Handle(params, &models.Principal{})
_, ok := response.(*subnetApi.SubnetRegTokenDefault)
suite.assert.True(ok)
}
func (suite *AdminSubnetTestSuite) TestSubnetRegTokenResponse() {
res, err := subnetRegTokenResponse(context.TODO(), suite.adminClient)
suite.assert.Nil(err)
suite.assert.NotEqual("", res)
}
func (suite *AdminSubnetTestSuite) initSubnetRegTokenRequest() (params subnetApi.SubnetRegTokenParams, api operations.ConsoleAPI) {
registerSubnetHandlers(&api)
params.HTTPRequest = &http.Request{}
return params, api
}
func (suite *AdminSubnetTestSuite) TestSubnetAPIKeyWithClientError() {
params, api := suite.initSubnetAPIKeyRequest()
response := api.SubnetSubnetAPIKeyHandler.Handle(params, &models.Principal{})
_, ok := response.(*subnetApi.SubnetAPIKeyDefault)
suite.assert.True(ok)
}
func (suite *AdminSubnetTestSuite) TestSubnetAPIKeyResponseError() {
params, _ := suite.initSubnetAPIKeyRequest()
res, err := subnetAPIKeyResponse(context.TODO(), suite.adminClient, params)
suite.assert.NotNil(err)
suite.assert.Nil(res)
}
func (suite *AdminSubnetTestSuite) initSubnetAPIKeyRequest() (params subnetApi.SubnetAPIKeyParams, api operations.ConsoleAPI) {
registerSubnetHandlers(&api)
params.HTTPRequest = &http.Request{}
params.HTTPRequest.URL = &url.URL{}
return params, api
}
func TestAdminSubnet(t *testing.T) {
suite.Run(t, new(AdminSubnetTestSuite))
}

488
api/admin_tiers.go Normal file
View File

@@ -0,0 +1,488 @@
// This file is part of MinIO Console Server
// Copyright (c) 2021 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package api
import (
"context"
"encoding/base64"
"strconv"
"github.com/dustin/go-humanize"
"github.com/go-openapi/runtime/middleware"
"github.com/minio/console/api/operations"
"github.com/minio/console/api/operations/tiering"
tieringApi "github.com/minio/console/api/operations/tiering"
"github.com/minio/console/models"
"github.com/minio/madmin-go/v3"
)
func registerAdminTiersHandlers(api *operations.ConsoleAPI) {
// return a list of notification endpoints
api.TieringTiersListHandler = tieringApi.TiersListHandlerFunc(func(params tieringApi.TiersListParams, session *models.Principal) middleware.Responder {
tierList, err := getTiersResponse(session, params)
if err != nil {
return tieringApi.NewTiersListDefault(err.Code).WithPayload(err.APIError)
}
return tieringApi.NewTiersListOK().WithPayload(tierList)
})
api.TieringTiersListNamesHandler = tiering.TiersListNamesHandlerFunc(func(params tiering.TiersListNamesParams, session *models.Principal) middleware.Responder {
tierList, err := getTiersNameResponse(session, params)
if err != nil {
return tieringApi.NewTiersListDefault(err.Code).WithPayload(err.APIError)
}
return tieringApi.NewTiersListNamesOK().WithPayload(tierList)
})
// add a new tiers
api.TieringAddTierHandler = tieringApi.AddTierHandlerFunc(func(params tieringApi.AddTierParams, session *models.Principal) middleware.Responder {
err := getAddTierResponse(session, params)
if err != nil {
return tieringApi.NewAddTierDefault(err.Code).WithPayload(err.APIError)
}
return tieringApi.NewAddTierCreated()
})
// get a tier
api.TieringGetTierHandler = tieringApi.GetTierHandlerFunc(func(params tieringApi.GetTierParams, session *models.Principal) middleware.Responder {
notifEndpoints, err := getGetTierResponse(session, params)
if err != nil {
return tieringApi.NewGetTierDefault(err.Code).WithPayload(err.APIError)
}
return tieringApi.NewGetTierOK().WithPayload(notifEndpoints)
})
// edit credentials for a tier
api.TieringEditTierCredentialsHandler = tieringApi.EditTierCredentialsHandlerFunc(func(params tieringApi.EditTierCredentialsParams, session *models.Principal) middleware.Responder {
err := getEditTierCredentialsResponse(session, params)
if err != nil {
return tieringApi.NewEditTierCredentialsDefault(err.Code).WithPayload(err.APIError)
}
return tieringApi.NewEditTierCredentialsOK()
})
// remove an empty tier
api.TieringRemoveTierHandler = tieringApi.RemoveTierHandlerFunc(func(params tieringApi.RemoveTierParams, session *models.Principal) middleware.Responder {
err := getRemoveTierResponse(session, params)
if err != nil {
return tieringApi.NewRemoveTierDefault(err.Code).WithPayload(err.APIError)
}
return tieringApi.NewRemoveTierNoContent()
})
}
// getTiers returns a list of tiers with their stats
func getTiers(ctx context.Context, client MinioAdmin) (*models.TierListResponse, error) {
tiers, err := client.listTiers(ctx)
if err != nil {
return nil, err
}
tierStatsInfo, err := client.tierStats(ctx)
if err != nil {
return nil, err
}
tiersStatsMap := make(map[string]madmin.TierStats, len(tierStatsInfo))
for _, stat := range tierStatsInfo {
tiersStatsMap[stat.Name] = stat.Stats
}
var tiersList []*models.Tier
for _, tierData := range tiers {
// Default Tier Stats
tierStats := madmin.TierStats{
NumObjects: 0,
NumVersions: 0,
TotalSize: 0,
}
if stats, ok := tiersStatsMap[tierData.Name]; ok {
tierStats = stats
}
status := client.verifyTierStatus(ctx, tierData.Name) == nil
switch tierData.Type {
case madmin.S3:
tiersList = append(tiersList, &models.Tier{
Type: models.TierTypeS3,
S3: &models.TierS3{
Accesskey: tierData.S3.AccessKey,
Bucket: tierData.S3.Bucket,
Endpoint: tierData.S3.Endpoint,
Name: tierData.Name,
Prefix: tierData.S3.Prefix,
Region: tierData.S3.Region,
Secretkey: tierData.S3.SecretKey,
Storageclass: tierData.S3.StorageClass,
Usage: humanize.IBytes(tierStats.TotalSize),
Objects: strconv.Itoa(tierStats.NumObjects),
Versions: strconv.Itoa(tierStats.NumVersions),
},
Status: status,
})
case madmin.MinIO:
tiersList = append(tiersList, &models.Tier{
Type: models.TierTypeMinio,
Minio: &models.TierMinio{
Accesskey: tierData.MinIO.AccessKey,
Bucket: tierData.MinIO.Bucket,
Endpoint: tierData.MinIO.Endpoint,
Name: tierData.Name,
Prefix: tierData.MinIO.Prefix,
Region: tierData.MinIO.Region,
Secretkey: tierData.MinIO.SecretKey,
Usage: humanize.IBytes(tierStats.TotalSize),
Objects: strconv.Itoa(tierStats.NumObjects),
Versions: strconv.Itoa(tierStats.NumVersions),
},
Status: status,
})
case madmin.GCS:
tiersList = append(tiersList, &models.Tier{
Type: models.TierTypeGcs,
Gcs: &models.TierGcs{
Bucket: tierData.GCS.Bucket,
Creds: tierData.GCS.Creds,
Endpoint: tierData.GCS.Endpoint,
Name: tierData.Name,
Prefix: tierData.GCS.Prefix,
Region: tierData.GCS.Region,
Usage: humanize.IBytes(tierStats.TotalSize),
Objects: strconv.Itoa(tierStats.NumObjects),
Versions: strconv.Itoa(tierStats.NumVersions),
},
Status: status,
})
case madmin.Azure:
tiersList = append(tiersList, &models.Tier{
Type: models.TierTypeAzure,
Azure: &models.TierAzure{
Accountkey: tierData.Azure.AccountKey,
Accountname: tierData.Azure.AccountName,
Bucket: tierData.Azure.Bucket,
Endpoint: tierData.Azure.Endpoint,
Name: tierData.Name,
Prefix: tierData.Azure.Prefix,
Region: tierData.Azure.Region,
Usage: humanize.IBytes(tierStats.TotalSize),
Objects: strconv.Itoa(tierStats.NumObjects),
Versions: strconv.Itoa(tierStats.NumVersions),
},
Status: status,
})
case madmin.Unsupported:
tiersList = append(tiersList, &models.Tier{
Type: models.TierTypeUnsupported,
Status: status,
})
}
}
// build response
return &models.TierListResponse{
Items: tiersList,
}, nil
}
// getTiersResponse returns a response with a list of tiers
func getTiersResponse(session *models.Principal, params tieringApi.TiersListParams) (*models.TierListResponse, *CodedAPIError) {
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
defer cancel()
mAdmin, err := NewMinioAdminClient(params.HTTPRequest.Context(), session)
if err != nil {
return nil, ErrorWithContext(ctx, err)
}
// create a minioClient interface implementation
// defining the client to be used
adminClient := AdminClient{Client: mAdmin}
// serialize output
tiersResp, err := getTiers(ctx, adminClient)
if err != nil {
return nil, ErrorWithContext(ctx, err)
}
return tiersResp, nil
}
// getTiersNameResponse returns a response with a list of tiers' names
func getTiersNameResponse(session *models.Principal, params tieringApi.TiersListNamesParams) (*models.TiersNameListResponse, *CodedAPIError) {
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
defer cancel()
mAdmin, err := NewMinioAdminClient(params.HTTPRequest.Context(), session)
if err != nil {
return nil, ErrorWithContext(ctx, err)
}
// create a minioClient interface implementation
// defining the client to be used
adminClient := AdminClient{Client: mAdmin}
// serialize output
tiersResp, err := getTiersName(ctx, adminClient)
if err != nil {
return nil, ErrorWithContext(ctx, err)
}
return tiersResp, nil
}
// getTiersName fetches listTiers and returns a list of the tiers' names
func getTiersName(ctx context.Context, client MinioAdmin) (*models.TiersNameListResponse, error) {
tiers, err := client.listTiers(ctx)
if err != nil {
return nil, err
}
tiersNameList := make([]string, len(tiers))
for i, tierData := range tiers {
tiersNameList[i] = tierData.Name
}
return &models.TiersNameListResponse{
Items: tiersNameList,
}, nil
}
func addTier(ctx context.Context, client MinioAdmin, params *tieringApi.AddTierParams) error {
var cfg *madmin.TierConfig
var err error
switch params.Body.Type {
case models.TierTypeS3:
cfg, err = madmin.NewTierS3(
params.Body.S3.Name,
params.Body.S3.Accesskey,
params.Body.S3.Secretkey,
params.Body.S3.Bucket,
madmin.S3Region(params.Body.S3.Region),
madmin.S3Prefix(params.Body.S3.Prefix),
madmin.S3Endpoint(params.Body.S3.Endpoint),
madmin.S3StorageClass(params.Body.S3.Storageclass),
)
if err != nil {
return err
}
case models.TierTypeMinio:
cfg, err = madmin.NewTierMinIO(
params.Body.Minio.Name,
params.Body.Minio.Endpoint,
params.Body.Minio.Accesskey,
params.Body.Minio.Secretkey,
params.Body.Minio.Bucket,
madmin.MinIORegion(params.Body.Minio.Region),
madmin.MinIOPrefix(params.Body.Minio.Prefix),
)
if err != nil {
return err
}
case models.TierTypeGcs:
gcsOpts := []madmin.GCSOptions{}
prefix := params.Body.Gcs.Prefix
if prefix != "" {
gcsOpts = append(gcsOpts, madmin.GCSPrefix(prefix))
}
region := params.Body.Gcs.Region
if region != "" {
gcsOpts = append(gcsOpts, madmin.GCSRegion(region))
}
base64Text := make([]byte, base64.StdEncoding.EncodedLen(len(params.Body.Gcs.Creds)))
l, _ := base64.StdEncoding.Decode(base64Text, []byte(params.Body.Gcs.Creds))
cfg, err = madmin.NewTierGCS(
params.Body.Gcs.Name,
base64Text[:l],
params.Body.Gcs.Bucket,
gcsOpts...,
)
if err != nil {
return err
}
case models.TierTypeAzure:
cfg, err = madmin.NewTierAzure(
params.Body.Azure.Name,
params.Body.Azure.Accountname,
params.Body.Azure.Accountkey,
params.Body.Azure.Bucket,
madmin.AzurePrefix(params.Body.Azure.Prefix),
madmin.AzureEndpoint(params.Body.Azure.Endpoint),
madmin.AzureRegion(params.Body.Azure.Region),
)
if err != nil {
return err
}
case models.TierTypeUnsupported:
cfg = &madmin.TierConfig{
Type: madmin.Unsupported,
}
}
err = client.addTier(ctx, cfg)
if err != nil {
return err
}
return nil
}
// getAddTierResponse returns the response of admin tier
func getAddTierResponse(session *models.Principal, params tieringApi.AddTierParams) *CodedAPIError {
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
defer cancel()
mAdmin, err := NewMinioAdminClient(params.HTTPRequest.Context(), session)
if err != nil {
return ErrorWithContext(ctx, err)
}
// create a minioClient interface implementation
// defining the client to be used
adminClient := AdminClient{Client: mAdmin}
// serialize output
errTier := addTier(ctx, adminClient, &params)
if errTier != nil {
return ErrorWithContext(ctx, errTier)
}
return nil
}
func getTier(ctx context.Context, client MinioAdmin, params *tieringApi.GetTierParams) (*models.Tier, error) {
tiers, err := client.listTiers(ctx)
if err != nil {
return nil, err
}
for i := range tiers {
switch tiers[i].Type {
case madmin.S3:
if params.Type != models.TierTypeS3 || tiers[i].Name != params.Name {
continue
}
return &models.Tier{
Type: models.TierTypeS3,
S3: &models.TierS3{
Accesskey: tiers[i].S3.AccessKey,
Bucket: tiers[i].S3.Bucket,
Endpoint: tiers[i].S3.Endpoint,
Name: tiers[i].Name,
Prefix: tiers[i].S3.Prefix,
Region: tiers[i].S3.Region,
Secretkey: tiers[i].S3.SecretKey,
Storageclass: tiers[i].S3.StorageClass,
},
}, err
case madmin.GCS:
if params.Type != models.TierTypeGcs || tiers[i].Name != params.Name {
continue
}
return &models.Tier{
Type: models.TierTypeGcs,
Gcs: &models.TierGcs{
Bucket: tiers[i].GCS.Bucket,
Creds: tiers[i].GCS.Creds,
Endpoint: tiers[i].GCS.Endpoint,
Name: tiers[i].Name,
Prefix: tiers[i].GCS.Prefix,
Region: tiers[i].GCS.Region,
},
}, nil
case madmin.Azure:
if params.Type != models.TierTypeAzure || tiers[i].Name != params.Name {
continue
}
return &models.Tier{
Type: models.TierTypeAzure,
Azure: &models.TierAzure{
Accountkey: tiers[i].Azure.AccountKey,
Accountname: tiers[i].Azure.AccountName,
Bucket: tiers[i].Azure.Bucket,
Endpoint: tiers[i].Azure.Endpoint,
Name: tiers[i].Name,
Prefix: tiers[i].Azure.Prefix,
Region: tiers[i].Azure.Region,
},
}, nil
}
}
// build response
return nil, ErrNotFound
}
// getGetTierResponse returns a tier
func getGetTierResponse(session *models.Principal, params tieringApi.GetTierParams) (*models.Tier, *CodedAPIError) {
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
defer cancel()
mAdmin, err := NewMinioAdminClient(params.HTTPRequest.Context(), session)
if err != nil {
return nil, ErrorWithContext(ctx, err)
}
// create a minioClient interface implementation
// defining the client to be used
adminClient := AdminClient{Client: mAdmin}
// serialize output
addTierResp, err := getTier(ctx, adminClient, &params)
if err != nil {
return nil, ErrorWithContext(ctx, err)
}
return addTierResp, nil
}
func editTierCredentials(ctx context.Context, client MinioAdmin, params *tieringApi.EditTierCredentialsParams) error {
base64Text := make([]byte, base64.StdEncoding.EncodedLen(len(params.Body.Creds)))
l, err := base64.StdEncoding.Decode(base64Text, []byte(params.Body.Creds))
if err != nil {
return err
}
creds := madmin.TierCreds{
AccessKey: params.Body.AccessKey,
SecretKey: params.Body.SecretKey,
CredsJSON: base64Text[:l],
}
return client.editTierCreds(ctx, params.Name, creds)
}
// getEditTierCredentialsResponse returns the result of editing credentials for a tier
func getEditTierCredentialsResponse(session *models.Principal, params tieringApi.EditTierCredentialsParams) *CodedAPIError {
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
defer cancel()
mAdmin, err := NewMinioAdminClient(params.HTTPRequest.Context(), session)
if err != nil {
return ErrorWithContext(ctx, err)
}
// create a minioClient interface implementation
// defining the client to be used
adminClient := AdminClient{Client: mAdmin}
// serialize output
err = editTierCredentials(ctx, adminClient, &params)
if err != nil {
return ErrorWithContext(ctx, err)
}
return nil
}
func removeTier(ctx context.Context, client MinioAdmin, params *tieringApi.RemoveTierParams) error {
return client.removeTier(ctx, params.Name)
}
func getRemoveTierResponse(session *models.Principal, params tieringApi.RemoveTierParams) *CodedAPIError {
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
defer cancel()
mAdmin, err := NewMinioAdminClient(params.HTTPRequest.Context(), session)
if err != nil {
return ErrorWithContext(ctx, err)
}
// create a minioClient interface implementation
// defining the client to be used
adminClient := AdminClient{Client: mAdmin}
// serialize output
err = removeTier(ctx, adminClient, &params)
if err != nil {
return ErrorWithContext(ctx, err)
}
return nil
}

310
api/admin_tiers_test.go Normal file
View File

@@ -0,0 +1,310 @@
// This file is part of MinIO Console Server
// Copyright (c) 2021 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package api
import (
"context"
"errors"
"fmt"
"testing"
tieringApi "github.com/minio/console/api/operations/tiering"
"github.com/minio/console/models"
"github.com/minio/madmin-go/v3"
"github.com/stretchr/testify/assert"
)
func TestGetTiers(t *testing.T) {
assert := assert.New(t)
// mock minIO client
adminClient := AdminClientMock{}
function := "getTiers()"
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
// Test-1 : getTiers() get list of tiers
// mock lifecycle response from MinIO
returnListMock := []*madmin.TierConfig{
{
Version: "V1",
Type: madmin.S3,
Name: "S3 Tier",
S3: &madmin.TierS3{
Endpoint: "https://s3tier.test.com/",
AccessKey: "Access Key",
SecretKey: "Secret Key",
Bucket: "buckets3",
Prefix: "pref1",
Region: "us-west-1",
StorageClass: "TT1",
},
},
{
Version: "V1",
Type: madmin.MinIO,
Name: "MinIO Tier",
MinIO: &madmin.TierMinIO{
Endpoint: "https://minio-endpoint.test.com/",
AccessKey: "access",
SecretKey: "secret",
Bucket: "somebucket",
Prefix: "p1",
Region: "us-east-2",
},
},
}
returnStatsMock := []madmin.TierInfo{
{
Name: "STANDARD",
Type: "internal",
Stats: madmin.TierStats{NumObjects: 2, NumVersions: 2, TotalSize: 228915},
},
{
Name: "MinIO Tier",
Type: "internal",
Stats: madmin.TierStats{NumObjects: 10, NumVersions: 3, TotalSize: 132788},
},
{
Name: "S3 Tier",
Type: "s3",
Stats: madmin.TierStats{NumObjects: 0, NumVersions: 0, TotalSize: 0},
},
}
expectedOutput := &models.TierListResponse{
Items: []*models.Tier{
{
Type: models.TierTypeS3,
S3: &models.TierS3{
Accesskey: "Access Key",
Secretkey: "Secret Key",
Bucket: "buckets3",
Endpoint: "https://s3tier.test.com/",
Name: "S3 Tier",
Prefix: "pref1",
Region: "us-west-1",
Storageclass: "TT1",
Usage: "0 B",
Objects: "0",
Versions: "0",
},
Status: false,
},
{
Type: models.TierTypeMinio,
Minio: &models.TierMinio{
Accesskey: "access",
Secretkey: "secret",
Bucket: "somebucket",
Endpoint: "https://minio-endpoint.test.com/",
Name: "MinIO Tier",
Prefix: "p1",
Region: "us-east-2",
Usage: "130 KiB",
Objects: "10",
Versions: "3",
},
Status: false,
},
},
}
minioListTiersMock = func(_ context.Context) ([]*madmin.TierConfig, error) {
return returnListMock, nil
}
minioTierStatsMock = func(_ context.Context) ([]madmin.TierInfo, error) {
return returnStatsMock, nil
}
minioVerifyTierStatusMock = func(_ context.Context, _ string) error {
return fmt.Errorf("someerror")
}
tiersList, err := getTiers(ctx, adminClient)
if err != nil {
t.Errorf("Failed on %s:, error occurred: %s", function, err.Error())
}
// verify length of tiers list is correct
assert.Equal(len(tiersList.Items), len(returnListMock), fmt.Sprintf("Failed on %s: length of lists is not the same", function))
assert.Equal(expectedOutput, tiersList)
// Test-2 : getTiers() list is empty
returnListMockT2 := []*madmin.TierConfig{}
minioListTiersMock = func(_ context.Context) ([]*madmin.TierConfig, error) {
return returnListMockT2, nil
}
tiersListT2, err := getTiers(ctx, adminClient)
if err != nil {
t.Errorf("Failed on %s:, error occurred: %s", function, err.Error())
}
if len(tiersListT2.Items) != 0 {
t.Errorf("Failed on %s:, returned list was not empty", function)
}
}
func TestGetTiersName(t *testing.T) {
assert := assert.New(t)
// mock minIO client
adminClient := AdminClientMock{}
function := "getTiersName()"
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
// Test-1 : getTiersName() get list tiers' names
// mock lifecycle response from MinIO
returnListMock := []*madmin.TierConfig{
{
Version: "V1",
Type: madmin.S3,
Name: "S3 Tier",
S3: &madmin.TierS3{
Endpoint: "https://s3tier.test.com/",
AccessKey: "Access Key",
SecretKey: "Secret Key",
Bucket: "buckets3",
Prefix: "pref1",
Region: "us-west-1",
StorageClass: "TT1",
},
},
{
Version: "V1",
Type: madmin.MinIO,
Name: "MinIO Tier",
MinIO: &madmin.TierMinIO{
Endpoint: "https://minio-endpoint.test.com/",
AccessKey: "access",
SecretKey: "secret",
Bucket: "somebucket",
Prefix: "p1",
Region: "us-east-2",
},
},
}
expectedOutput := &models.TiersNameListResponse{
Items: []string{"S3 Tier", "MinIO Tier"},
}
minioListTiersMock = func(_ context.Context) ([]*madmin.TierConfig, error) {
return returnListMock, nil
}
tiersList, err := getTiersName(ctx, adminClient)
if err != nil {
t.Errorf("Failed on %s:, error occurred: %s", function, err.Error())
}
// verify length of tiers list is correct
assert.Equal(len(tiersList.Items), len(returnListMock), fmt.Sprintf("Failed on %s: length of lists is not the same", function))
assert.Equal(expectedOutput, tiersList)
// Test-2 : getTiersName() list is empty
returnListMockT2 := []*madmin.TierConfig{}
minioListTiersMock = func(_ context.Context) ([]*madmin.TierConfig, error) {
return returnListMockT2, nil
}
emptyTierList, err := getTiersName(ctx, adminClient)
if err != nil {
t.Errorf("Failed on %s:, error occurred: %s", function, err.Error())
}
if len(emptyTierList.Items) != 0 {
t.Errorf("Failed on %s:, returned list was not empty", function)
}
}
func TestAddTier(t *testing.T) {
assert := assert.New(t)
// mock minIO client
adminClient := AdminClientMock{}
function := "addTier()"
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
// Test-1: addTier() add new Tier
minioAddTiersMock = func(_ context.Context, _ *madmin.TierConfig) error {
return nil
}
paramsToAdd := tieringApi.AddTierParams{
Body: &models.Tier{
Type: "S3",
S3: &models.TierS3{
Accesskey: "TestAK",
Bucket: "bucket1",
Endpoint: "https://test.com/",
Name: "TIERS3",
Prefix: "Pr1",
Region: "us-west-1",
Secretkey: "SecretK",
Storageclass: "STCLASS",
},
},
}
err := addTier(ctx, adminClient, &paramsToAdd)
assert.Equal(nil, err, fmt.Sprintf("Failed on %s: Error returned", function))
// Test-2: addTier() error adding Tier
minioAddTiersMock = func(_ context.Context, _ *madmin.TierConfig) error {
return errors.New("error setting new tier")
}
err2 := addTier(ctx, adminClient, &paramsToAdd)
assert.Equal(errors.New("error setting new tier"), err2, fmt.Sprintf("Failed on %s: Error returned", function))
}
func TestUpdateTierCreds(t *testing.T) {
assert := assert.New(t)
// mock minIO client
adminClient := AdminClientMock{}
function := "editTierCredentials()"
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
// Test-1: editTierCredentials() update Tier configuration
minioEditTiersMock = func(_ context.Context, _ string, _ madmin.TierCreds) error {
return nil
}
params := &tieringApi.EditTierCredentialsParams{
Name: "TESTTIER",
Body: &models.TierCredentialsRequest{
AccessKey: "New Key",
SecretKey: "Secret Key",
},
}
err := editTierCredentials(ctx, adminClient, params)
assert.Equal(nil, err, fmt.Sprintf("Failed on %s: Error returned", function))
// Test-2: editTierCredentials() update Tier configuration failure
minioEditTiersMock = func(_ context.Context, _ string, _ madmin.TierCreds) error {
return errors.New("error message")
}
errT2 := editTierCredentials(ctx, adminClient, params)
assert.Equal(errors.New("error message"), errT2, fmt.Sprintf("Failed on %s: Error returned", function))
}

View File

@@ -14,7 +14,7 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package restapi
package api
import (
"context"
@@ -23,8 +23,8 @@ import (
"strings"
"time"
"github.com/gorilla/websocket"
"github.com/minio/madmin-go"
"github.com/minio/madmin-go/v3"
"github.com/minio/websocket"
)
// shortTraceMsg Short trace record
@@ -62,21 +62,21 @@ func matchTrace(opts TraceRequest, traceInfo madmin.ServiceTraceInfo) bool {
// Filter request path if passed by the user
if apiPath != "" {
pathToLookup := strings.ToLower(apiPath)
pathFromTrace := strings.ToLower(traceInfo.Trace.ReqInfo.Path)
pathFromTrace := strings.ToLower(traceInfo.Trace.Path)
return strings.Contains(pathFromTrace, pathToLookup)
}
// Filter response status codes if passed by the user
if statusCode > 0 {
statusCodeFromTrace := traceInfo.Trace.RespInfo.StatusCode
if statusCode > 0 && traceInfo.Trace.HTTP != nil {
statusCodeFromTrace := traceInfo.Trace.HTTP.RespInfo.StatusCode
return statusCodeFromTrace == statusCode
}
// Filter request method if passed by the user
if method != "" {
methodFromTrace := traceInfo.Trace.ReqInfo.Method
if method != "" && traceInfo.Trace.HTTP != nil {
methodFromTrace := traceInfo.Trace.HTTP.ReqInfo.Method
return methodFromTrace == method
}
@@ -127,26 +127,28 @@ func startTraceInfo(ctx context.Context, conn WSConn, client MinioAdmin, opts Tr
}
// shortTrace creates a shorter Trace Info message.
// Same implementation as github/minio/mc/cmd/admin-trace.go
// Same implementation as github/minio/mc/cmd/admin-trace.go
func shortTrace(info *madmin.ServiceTraceInfo) shortTraceMsg {
t := info.Trace
s := shortTraceMsg{}
s.Time = t.ReqInfo.Time.Format(time.RFC3339)
s.Path = t.ReqInfo.Path
s.Query = t.ReqInfo.RawQuery
s.Time = t.Time.Format(time.RFC3339)
s.Path = t.Path
s.FuncName = t.FuncName
s.StatusCode = t.RespInfo.StatusCode
s.StatusMsg = http.StatusText(t.RespInfo.StatusCode)
s.CallStats.Duration = t.CallStats.Latency.String()
s.CallStats.Rx = t.CallStats.InputBytes
s.CallStats.Tx = t.CallStats.OutputBytes
s.CallStats.Ttfb = t.CallStats.TimeToFirstByte.String()
if host, ok := t.ReqInfo.Headers["Host"]; ok {
s.Host = strings.Join(host, "")
s.CallStats.Duration = t.Duration.String()
if info.Trace.HTTP != nil {
s.Query = t.HTTP.ReqInfo.RawQuery
s.StatusCode = t.HTTP.RespInfo.StatusCode
s.StatusMsg = http.StatusText(t.HTTP.RespInfo.StatusCode)
s.CallStats.Rx = t.HTTP.CallStats.InputBytes
s.CallStats.Tx = t.HTTP.CallStats.OutputBytes
s.CallStats.Ttfb = t.HTTP.CallStats.TimeToFirstByte.String()
if host, ok := t.HTTP.ReqInfo.Headers["Host"]; ok {
s.Host = strings.Join(host, "")
}
cSlice := strings.Split(t.HTTP.ReqInfo.Client, ":")
s.Client = cSlice[0]
}
cSlice := strings.Split(t.ReqInfo.Client, ":")
s.Client = cSlice[0]
return s
}

View File

@@ -14,7 +14,7 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package restapi
package api
import (
"context"
@@ -22,24 +22,17 @@ import (
"fmt"
"testing"
"github.com/minio/madmin-go"
"github.com/minio/madmin-go/v3"
"github.com/stretchr/testify/assert"
)
// assigning mock at runtime instead of compile time
var minioServiceTraceMock func(ctx context.Context, threshold int64, s3, internal, storage, os, errTrace bool) <-chan madmin.ServiceTraceInfo
// mock function of listPolicies()
func (ac adminClientMock) serviceTrace(ctx context.Context, threshold int64, s3, internal, storage, os, errTrace bool) <-chan madmin.ServiceTraceInfo {
return minioServiceTraceMock(ctx, threshold, s3, internal, storage, os, errTrace)
}
func TestAdminTrace(t *testing.T) {
assert := assert.New(t)
adminClient := adminClientMock{}
adminClient := AdminClientMock{}
mockWSConn := mockConn{}
function := "startTraceInfo(ctx, )"
ctx := context.Background()
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
testReceiver := make(chan shortTraceMsg, 5)
textToReceive := "test"
@@ -48,7 +41,7 @@ func TestAdminTrace(t *testing.T) {
// Test-1: Serve Trace with no errors until trace finishes sending
// define mock function behavior for minio server Trace
minioServiceTraceMock = func(ctx context.Context, threshold int64, s3, internal, storage, os, errTrace bool) <-chan madmin.ServiceTraceInfo {
minioServiceTraceMock = func(_ context.Context, _ int64, _, _, _, _, _ bool) <-chan madmin.ServiceTraceInfo {
ch := make(chan madmin.ServiceTraceInfo)
// Only success, start a routine to start reading line by line.
go func(ch chan<- madmin.ServiceTraceInfo) {
@@ -66,7 +59,7 @@ func TestAdminTrace(t *testing.T) {
}
writesCount := 1
// mock connection WriteMessage() no error
connWriteMessageMock = func(messageType int, data []byte) error {
connWriteMessageMock = func(_ int, data []byte) error {
// emulate that receiver gets the message written
var t shortTraceMsg
_ = json.Unmarshal(data, &t)
@@ -91,7 +84,7 @@ func TestAdminTrace(t *testing.T) {
}
// Test-2: if error happens while writing, return error
connWriteMessageMock = func(messageType int, data []byte) error {
connWriteMessageMock = func(_ int, _ []byte) error {
return fmt.Errorf("error on write")
}
if err := startTraceInfo(ctx, mockWSConn, adminClient, TraceRequest{}); assert.Error(err) {
@@ -100,7 +93,7 @@ func TestAdminTrace(t *testing.T) {
// Test-3: error happens on serviceTrace Minio, trace should stop
// and error shall be returned.
minioServiceTraceMock = func(ctx context.Context, threshold int64, s3, internal, storage, os, errTrace bool) <-chan madmin.ServiceTraceInfo {
minioServiceTraceMock = func(_ context.Context, _ int64, _, _, _, _, _ bool) <-chan madmin.ServiceTraceInfo {
ch := make(chan madmin.ServiceTraceInfo)
// Only success, start a routine to start reading line by line.
go func(ch chan<- madmin.ServiceTraceInfo) {
@@ -117,7 +110,7 @@ func TestAdminTrace(t *testing.T) {
}(ch)
return ch
}
connWriteMessageMock = func(messageType int, data []byte) error {
connWriteMessageMock = func(_ int, _ []byte) error {
return nil
}
if err := startTraceInfo(ctx, mockWSConn, adminClient, TraceRequest{}); assert.Error(err) {

722
api/admin_users.go Normal file
View File

@@ -0,0 +1,722 @@
// This file is part of MinIO Console Server
// Copyright (c) 2021 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package api
import (
"context"
"fmt"
"sort"
"strings"
"github.com/go-openapi/errors"
"github.com/go-openapi/runtime/middleware"
"github.com/minio/console/api/operations"
accountApi "github.com/minio/console/api/operations/account"
bucketApi "github.com/minio/console/api/operations/bucket"
userApi "github.com/minio/console/api/operations/user"
"github.com/minio/console/models"
"github.com/minio/madmin-go/v3"
iampolicy "github.com/minio/pkg/v3/policy"
)
// Policy evaluated constants
const (
Unknown = 0
Allow = 1
Deny = -1
)
func registerUsersHandlers(api *operations.ConsoleAPI) {
// List Users
api.UserListUsersHandler = userApi.ListUsersHandlerFunc(func(params userApi.ListUsersParams, session *models.Principal) middleware.Responder {
listUsersResponse, err := getListUsersResponse(session, params)
if err != nil {
return userApi.NewListUsersDefault(err.Code).WithPayload(err.APIError)
}
return userApi.NewListUsersOK().WithPayload(listUsersResponse)
})
// Add User
api.UserAddUserHandler = userApi.AddUserHandlerFunc(func(params userApi.AddUserParams, session *models.Principal) middleware.Responder {
userResponse, err := getUserAddResponse(session, params)
if err != nil {
return userApi.NewAddUserDefault(err.Code).WithPayload(err.APIError)
}
return userApi.NewAddUserCreated().WithPayload(userResponse)
})
// Remove User
api.UserRemoveUserHandler = userApi.RemoveUserHandlerFunc(func(params userApi.RemoveUserParams, session *models.Principal) middleware.Responder {
err := getRemoveUserResponse(session, params)
if err != nil {
return userApi.NewRemoveUserDefault(err.Code).WithPayload(err.APIError)
}
return userApi.NewRemoveUserNoContent()
})
// Update User-Groups
api.UserUpdateUserGroupsHandler = userApi.UpdateUserGroupsHandlerFunc(func(params userApi.UpdateUserGroupsParams, session *models.Principal) middleware.Responder {
userUpdateResponse, err := getUpdateUserGroupsResponse(session, params)
if err != nil {
return userApi.NewUpdateUserGroupsDefault(err.Code).WithPayload(err.APIError)
}
return userApi.NewUpdateUserGroupsOK().WithPayload(userUpdateResponse)
})
// Get User
api.UserGetUserInfoHandler = userApi.GetUserInfoHandlerFunc(func(params userApi.GetUserInfoParams, session *models.Principal) middleware.Responder {
userInfoResponse, err := getUserInfoResponse(session, params)
if err != nil {
return userApi.NewGetUserInfoDefault(err.Code).WithPayload(err.APIError)
}
return userApi.NewGetUserInfoOK().WithPayload(userInfoResponse)
})
// Update User
api.UserUpdateUserInfoHandler = userApi.UpdateUserInfoHandlerFunc(func(params userApi.UpdateUserInfoParams, session *models.Principal) middleware.Responder {
userUpdateResponse, err := getUpdateUserResponse(session, params)
if err != nil {
return userApi.NewUpdateUserInfoDefault(err.Code).WithPayload(err.APIError)
}
return userApi.NewUpdateUserInfoOK().WithPayload(userUpdateResponse)
})
// Update User-Groups Bulk
api.UserBulkUpdateUsersGroupsHandler = userApi.BulkUpdateUsersGroupsHandlerFunc(func(params userApi.BulkUpdateUsersGroupsParams, session *models.Principal) middleware.Responder {
err := getAddUsersListToGroupsResponse(session, params)
if err != nil {
return userApi.NewBulkUpdateUsersGroupsDefault(err.Code).WithPayload(err.APIError)
}
return userApi.NewBulkUpdateUsersGroupsOK()
})
api.BucketListUsersWithAccessToBucketHandler = bucketApi.ListUsersWithAccessToBucketHandlerFunc(func(params bucketApi.ListUsersWithAccessToBucketParams, session *models.Principal) middleware.Responder {
response, err := getListUsersWithAccessToBucketResponse(session, params)
if err != nil {
return bucketApi.NewListUsersWithAccessToBucketDefault(err.Code).WithPayload(err.APIError)
}
return bucketApi.NewListUsersWithAccessToBucketOK().WithPayload(response)
})
// Change User Password
api.AccountChangeUserPasswordHandler = accountApi.ChangeUserPasswordHandlerFunc(func(params accountApi.ChangeUserPasswordParams, session *models.Principal) middleware.Responder {
err := getChangeUserPasswordResponse(session, params)
if err != nil {
return accountApi.NewChangeUserPasswordDefault(err.Code).WithPayload(err.APIError)
}
return accountApi.NewChangeUserPasswordCreated()
})
// Check number of Service Accounts for listed users
api.UserCheckUserServiceAccountsHandler = userApi.CheckUserServiceAccountsHandlerFunc(func(params userApi.CheckUserServiceAccountsParams, session *models.Principal) middleware.Responder {
userSAList, err := getCheckUserSAResponse(session, params)
if err != nil {
return userApi.NewCheckUserServiceAccountsDefault(err.Code).WithPayload(err.APIError)
}
return userApi.NewCheckUserServiceAccountsOK().WithPayload(userSAList)
})
}
func listUsers(ctx context.Context, client MinioAdmin) ([]*models.User, error) {
// Get list of all users in the MinIO
// This call requires explicit authentication, no anonymous requests are
// allowed for listing users.
userMap, err := client.listUsers(ctx)
if err != nil {
return []*models.User{}, err
}
var users []*models.User
for accessKey, user := range userMap {
userElem := &models.User{
AccessKey: accessKey,
Status: string(user.Status),
Policy: strings.Split(user.PolicyName, ","),
MemberOf: user.MemberOf,
}
users = append(users, userElem)
}
return users, nil
}
// getListUsersResponse performs listUsers() and serializes it to the handler's output
func getListUsersResponse(session *models.Principal, params userApi.ListUsersParams) (*models.ListUsersResponse, *CodedAPIError) {
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
defer cancel()
mAdmin, err := NewMinioAdminClient(params.HTTPRequest.Context(), session)
if err != nil {
return nil, ErrorWithContext(ctx, err)
}
// create a minioClient interface implementation
// defining the client to be used
adminClient := AdminClient{Client: mAdmin}
users, err := listUsers(ctx, adminClient)
if err != nil {
return nil, ErrorWithContext(ctx, err)
}
// serialize output
listUsersResponse := &models.ListUsersResponse{
Users: users,
}
return listUsersResponse, nil
}
// addUser invokes adding a users on `MinioAdmin` and builds the response `models.User`
func addUser(ctx context.Context, client MinioAdmin, accessKey, secretKey *string, groups []string, policies []string) (*models.User, error) {
// Calls into MinIO to add a new user if there's an errors return it
if err := client.addUser(ctx, *accessKey, *secretKey); err != nil {
return nil, err
}
// set groups for the newly created user
var userWithGroups *models.User
if len(groups) > 0 {
var errUG error
userWithGroups, errUG = updateUserGroups(ctx, client, *accessKey, groups)
if errUG != nil {
return nil, errUG
}
}
// set policies for the newly created user
if len(policies) > 0 {
policyString := strings.Join(policies, ",")
if err := SetPolicy(ctx, client, policyString, *accessKey, "user"); err != nil {
return nil, err
}
}
memberOf := []string{}
status := "enabled"
if userWithGroups != nil {
memberOf = userWithGroups.MemberOf
status = userWithGroups.Status
}
userRet := &models.User{
AccessKey: *accessKey,
MemberOf: memberOf,
Policy: policies,
Status: status,
}
return userRet, nil
}
func getUserAddResponse(session *models.Principal, params userApi.AddUserParams) (*models.User, *CodedAPIError) {
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
defer cancel()
mAdmin, err := NewMinioAdminClient(params.HTTPRequest.Context(), session)
if err != nil {
return nil, ErrorWithContext(ctx, err)
}
// create a minioClient interface implementation
// defining the client to be used
adminClient := AdminClient{Client: mAdmin}
var userExists bool
_, err = adminClient.getUserInfo(ctx, *params.Body.AccessKey)
userExists = err == nil
if userExists {
return nil, ErrorWithContext(ctx, ErrNonUniqueAccessKey)
}
user, err := addUser(
ctx,
adminClient,
params.Body.AccessKey,
params.Body.SecretKey,
params.Body.Groups,
params.Body.Policies,
)
if err != nil {
return nil, ErrorWithContext(ctx, err)
}
return user, nil
}
// removeUser invokes removing an user on `MinioAdmin`, then we return the response from API
func removeUser(ctx context.Context, client MinioAdmin, accessKey string) error {
return client.removeUser(ctx, accessKey)
}
func getRemoveUserResponse(session *models.Principal, params userApi.RemoveUserParams) *CodedAPIError {
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
defer cancel()
mAdmin, err := NewMinioAdminClient(params.HTTPRequest.Context(), session)
if err != nil {
return ErrorWithContext(ctx, err)
}
if session.AccountAccessKey == params.Name {
return ErrorWithContext(ctx, ErrAvoidSelfAccountDelete)
}
// create a minioClient interface implementation
// defining the client to be used
adminClient := AdminClient{Client: mAdmin}
if err := removeUser(ctx, adminClient, params.Name); err != nil {
return ErrorWithContext(ctx, err)
}
return nil
}
// getUserInfo calls MinIO server get the User Information
func getUserInfo(ctx context.Context, client MinioAdmin, accessKey string) (*madmin.UserInfo, error) {
userInfo, err := client.getUserInfo(ctx, accessKey)
if err != nil {
return nil, err
}
return &userInfo, nil
}
func getUserInfoResponse(session *models.Principal, params userApi.GetUserInfoParams) (*models.User, *CodedAPIError) {
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
defer cancel()
mAdmin, err := NewMinioAdminClient(params.HTTPRequest.Context(), session)
if err != nil {
return nil, ErrorWithContext(ctx, err)
}
// create a minioClient interface implementation
// defining the client to be used
adminClient := AdminClient{Client: mAdmin}
user, err := getUserInfo(ctx, adminClient, params.Name)
if err != nil {
// User doesn't exist, return 404
if madmin.ToErrorResponse(err).Code == "XMinioAdminNoSuchUser" {
errorCode := 404
errorMessage := "User doesn't exist"
return nil, &CodedAPIError{Code: errorCode, APIError: &models.APIError{Message: errorMessage, DetailedMessage: err.Error()}}
}
return nil, ErrorWithContext(ctx, err)
}
var policies []string
if user.PolicyName == "" {
policies = []string{}
} else {
policies = strings.Split(user.PolicyName, ",")
}
hasPolicy := true
if len(policies) == 0 {
hasPolicy = false
for i := 0; i < len(user.MemberOf); i++ {
group, err := adminClient.getGroupDescription(ctx, user.MemberOf[i])
if err != nil {
continue
}
if group.Policy != "" {
hasPolicy = true
break
}
}
}
userInformation := &models.User{
AccessKey: params.Name,
MemberOf: user.MemberOf,
Policy: policies,
Status: string(user.Status),
HasPolicy: hasPolicy,
}
return userInformation, nil
}
// updateUserGroups invokes getUserInfo() to get the old groups from the user,
// then we merge the list with the new groups list to have a shorter iteration between groups and we do a comparison between the current and old groups.
// We delete or update the groups according the location in each list and send the user with the new groups from `MinioAdmin` to the client
func updateUserGroups(ctx context.Context, client MinioAdmin, user string, groupsToAssign []string) (*models.User, error) {
parallelUserUpdate := func(groupName string, originGroups []string) chan error {
chProcess := make(chan error)
go func() error {
defer close(chProcess)
// Compare if groupName is in the arrays
isGroupPersistent := IsElementInArray(groupsToAssign, groupName)
isInOriginGroups := IsElementInArray(originGroups, groupName)
if isGroupPersistent && isInOriginGroups { // Group is already assigned and doesn't need to be updated
chProcess <- nil
return nil
}
isRemove := false // User is added by default
// User is deleted from the group
if !isGroupPersistent {
isRemove = true
}
userToAddRemove := []string{user}
updateReturn := updateGroupMembers(ctx, client, groupName, userToAddRemove, isRemove)
chProcess <- updateReturn
return updateReturn
}()
return chProcess
}
userInfoOr, err := getUserInfo(ctx, client, user)
if err != nil {
return nil, err
}
memberOf := userInfoOr.MemberOf
mergedGroupArray := UniqueKeys(append(memberOf, groupsToAssign...))
var listOfUpdates []chan error
// Each group must be updated individually because there is no way to update all the groups at once for a user,
// we are using the same logic as 'mc admin group add' command
for _, groupN := range mergedGroupArray {
proc := parallelUserUpdate(groupN, memberOf)
listOfUpdates = append(listOfUpdates, proc)
}
channelHasError := false
for _, chanRet := range listOfUpdates {
locError := <-chanRet
if locError != nil {
channelHasError = true
}
}
if channelHasError {
errRt := errors.New(500, "there was an error updating the groups")
return nil, errRt
}
userInfo, err := getUserInfo(ctx, client, user)
if err != nil {
return nil, err
}
policies := strings.Split(userInfo.PolicyName, ",")
userReturn := &models.User{
AccessKey: user,
MemberOf: userInfo.MemberOf,
Policy: policies,
Status: string(userInfo.Status),
}
return userReturn, nil
}
func getUpdateUserGroupsResponse(session *models.Principal, params userApi.UpdateUserGroupsParams) (*models.User, *CodedAPIError) {
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
defer cancel()
mAdmin, err := NewMinioAdminClient(params.HTTPRequest.Context(), session)
if err != nil {
return nil, ErrorWithContext(ctx, err)
}
// create a minioClient interface implementation
// defining the client to be used
adminClient := AdminClient{Client: mAdmin}
user, err := updateUserGroups(ctx, adminClient, params.Name, params.Body.Groups)
if err != nil {
return nil, ErrorWithContext(ctx, err)
}
return user, nil
}
// setUserStatus invokes setUserStatus from madmin to update user status
func setUserStatus(ctx context.Context, client MinioAdmin, user string, status string) error {
var setStatus madmin.AccountStatus
switch status {
case "enabled":
setStatus = madmin.AccountEnabled
case "disabled":
setStatus = madmin.AccountDisabled
default:
return errors.New(500, "status not valid")
}
return client.setUserStatus(ctx, user, setStatus)
}
func getUpdateUserResponse(session *models.Principal, params userApi.UpdateUserInfoParams) (*models.User, *CodedAPIError) {
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
defer cancel()
mAdmin, err := NewMinioAdminClient(params.HTTPRequest.Context(), session)
if err != nil {
return nil, ErrorWithContext(ctx, err)
}
// create a minioClient interface implementation
// defining the client to be used
adminClient := AdminClient{Client: mAdmin}
status := *params.Body.Status
groups := params.Body.Groups
if err := setUserStatus(ctx, adminClient, params.Name, status); err != nil {
return nil, ErrorWithContext(ctx, err)
}
userElem, errUG := updateUserGroups(ctx, adminClient, params.Name, groups)
if errUG != nil {
return nil, ErrorWithContext(ctx, errUG)
}
return userElem, nil
}
// addUsersListToGroups iterates over the user list & assigns the requested groups to each user.
func addUsersListToGroups(ctx context.Context, client MinioAdmin, usersToUpdate []string, groupsToAssign []string) error {
// We update each group with the complete usersList
parallelGroupsUpdate := func(groupToAssign string) chan error {
groupProcess := make(chan error)
go func() {
defer close(groupProcess)
// We add the users array to the group.
err := updateGroupMembers(ctx, client, groupToAssign, usersToUpdate, false)
groupProcess <- err
}()
return groupProcess
}
var groupsUpdateList []chan error
// We get each group name & add users accordingly
for _, groupName := range groupsToAssign {
// We update the group
proc := parallelGroupsUpdate(groupName)
groupsUpdateList = append(groupsUpdateList, proc)
}
errorsList := []string{} // We get the errors list because we want to have all errors at once.
for _, err := range groupsUpdateList {
errorFromUpdate := <-err // We store the errors to avoid Data Race
if errorFromUpdate != nil {
// If there is an errors, we store the errors strings so we can join them after we receive all errors
errorsList = append(errorsList, errorFromUpdate.Error()) // We wait until all the channels have been closed.
}
}
// If there are errors, we throw the final errors with the errors inside
if len(errorsList) > 0 {
errGen := fmt.Errorf("error in users-groups assignation: %q", strings.Join(errorsList, ","))
return errGen
}
return nil
}
func getAddUsersListToGroupsResponse(session *models.Principal, params userApi.BulkUpdateUsersGroupsParams) *CodedAPIError {
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
defer cancel()
mAdmin, err := NewMinioAdminClient(params.HTTPRequest.Context(), session)
if err != nil {
return ErrorWithContext(ctx, err)
}
// create a minioClient interface implementation
// defining the client to be used
adminClient := AdminClient{Client: mAdmin}
usersList := params.Body.Users
groupsList := params.Body.Groups
if err := addUsersListToGroups(ctx, adminClient, usersList, groupsList); err != nil {
return ErrorWithContext(ctx, err)
}
return nil
}
func getListUsersWithAccessToBucketResponse(session *models.Principal, params bucketApi.ListUsersWithAccessToBucketParams) ([]string, *CodedAPIError) {
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
defer cancel()
mAdmin, err := NewMinioAdminClient(params.HTTPRequest.Context(), session)
if err != nil {
return nil, ErrorWithContext(ctx, err)
}
// create a minioClient interface implementation
// defining the client to be used
adminClient := AdminClient{Client: mAdmin}
list, err := listUsersWithAccessToBucket(ctx, adminClient, params.Bucket)
if err != nil {
return nil, ErrorWithContext(ctx, err)
}
return list, nil
}
func policyAllowsAndMatchesBucket(policy *iampolicy.Policy, bucket string) int {
policyStatements := policy.Statements
for i := 0; i < len(policyStatements); i++ {
resources := policyStatements[i].Resources
effect := policyStatements[i].Effect
if resources.Match(bucket, map[string][]string{}) {
if effect.IsValid() {
if effect.IsAllowed(true) {
return Allow
}
return Deny
}
}
}
return Unknown
}
func listUsersWithAccessToBucket(ctx context.Context, adminClient MinioAdmin, bucket string) ([]string, error) {
users, err := adminClient.listUsers(ctx)
if err != nil {
return nil, err
}
var retval []string
akHasAccess := make(map[string]struct{})
akIsDenied := make(map[string]struct{})
for k, v := range users {
for _, policyName := range strings.Split(v.PolicyName, ",") {
policyName = strings.TrimSpace(policyName)
if policyName == "" {
continue
}
policy, err := adminClient.getPolicy(ctx, policyName)
if err != nil {
ErrorWithContext(ctx, fmt.Errorf("unable to fetch policy %s: %v", policyName, err))
continue
}
if _, ok := akIsDenied[k]; !ok {
switch policyAllowsAndMatchesBucket(policy, bucket) {
case Allow:
if _, ok := akHasAccess[k]; !ok {
akHasAccess[k] = struct{}{}
}
case Deny:
akIsDenied[k] = struct{}{}
delete(akHasAccess, k)
}
}
}
}
groups, err := adminClient.listGroups(ctx)
if err != nil {
ErrorWithContext(ctx, fmt.Errorf("unable to list groups: %v", err))
return retval, nil
}
for _, groupName := range groups {
info, err := groupInfo(ctx, adminClient, groupName)
if err != nil {
ErrorWithContext(ctx, fmt.Errorf("unable to fetch group info %s: %v", groupName, err))
continue
}
policy, err := adminClient.getPolicy(ctx, info.Policy)
if err != nil {
ErrorWithContext(ctx, fmt.Errorf("unable to fetch group policy %s: %v", info.Policy, err))
continue
}
for _, member := range info.Members {
if _, ok := akIsDenied[member]; !ok {
switch policyAllowsAndMatchesBucket(policy, bucket) {
case Allow:
if _, ok := akHasAccess[member]; !ok {
akHasAccess[member] = struct{}{}
}
case Deny:
akIsDenied[member] = struct{}{}
delete(akHasAccess, member)
}
}
}
}
for k := range akHasAccess {
retval = append(retval, k)
}
sort.Strings(retval)
return retval, nil
}
// changeUserPassword changes password of selectedUser to newSecretKey
func changeUserPassword(ctx context.Context, client MinioAdmin, selectedUser string, newSecretKey string) error {
return client.changePassword(ctx, selectedUser, newSecretKey)
}
// getChangeUserPasswordResponse will change the password of selctedUser to newSecretKey
func getChangeUserPasswordResponse(session *models.Principal, params accountApi.ChangeUserPasswordParams) *CodedAPIError {
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
defer cancel()
mAdmin, err := NewMinioAdminClient(params.HTTPRequest.Context(), session)
if err != nil {
return ErrorWithContext(ctx, err)
}
// create a minioClient interface implementation
// defining the client to be used
adminClient := AdminClient{Client: mAdmin}
// params will contain selectedUser and newSecretKey credentials for the user
user := *params.Body.SelectedUser
newSecretKey := *params.Body.NewSecretKey
// changes password of user to newSecretKey
if err := changeUserPassword(ctx, adminClient, user, newSecretKey); err != nil {
return ErrorWithContext(ctx, err)
}
return nil
}
func getCheckUserSAResponse(session *models.Principal, params userApi.CheckUserServiceAccountsParams) (*models.UserServiceAccountSummary, *CodedAPIError) {
ctx, cancel := context.WithCancel(params.HTTPRequest.Context())
defer cancel()
mAdmin, err := NewMinioAdminClient(params.HTTPRequest.Context(), session)
if err != nil {
return nil, ErrorWithContext(ctx, err)
}
// create a minioClient interface implementation
// defining the client to be used
adminClient := AdminClient{Client: mAdmin}
var userServiceAccountList []*models.UserServiceAccountItem
hasSA := false
for _, user := range params.SelectedUsers {
listServAccs, err := adminClient.listServiceAccounts(ctx, user)
if err != nil {
return nil, ErrorWithContext(ctx, err)
}
numSAs := int64(len(listServAccs.Accounts))
if numSAs > 0 {
hasSA = true
}
userAccountItem := &models.UserServiceAccountItem{
UserName: user,
NumSAs: numSAs,
}
userServiceAccountList = append(userServiceAccountList, userAccountItem)
}
userAccountList := &models.UserServiceAccountSummary{
UserServiceAccountList: userServiceAccountList,
HasSA: hasSA,
}
return userAccountList, nil
}

View File

@@ -14,7 +14,7 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package restapi
package api
import (
"bytes"
@@ -24,47 +24,16 @@ import (
"strings"
"testing"
"github.com/minio/madmin-go"
iampolicy "github.com/minio/pkg/iam/policy"
"github.com/minio/madmin-go/v3"
iampolicy "github.com/minio/pkg/v3/policy"
asrt "github.com/stretchr/testify/assert"
)
// assigning mock at runtime instead of compile time
var minioListUsersMock func() (map[string]madmin.UserInfo, error)
var minioAddUserMock func(accessKey, secreyKey string) error
var minioRemoveUserMock func(accessKey string) error
var minioGetUserInfoMock func(accessKey string) (madmin.UserInfo, error)
var minioSetUserStatusMock func(accessKey string, status madmin.AccountStatus) error
// mock function of listUsers()
func (ac adminClientMock) listUsers(ctx context.Context) (map[string]madmin.UserInfo, error) {
return minioListUsersMock()
}
// mock function of addUser()
func (ac adminClientMock) addUser(ctx context.Context, accessKey, secretKey string) error {
return minioAddUserMock(accessKey, secretKey)
}
// mock function of removeUser()
func (ac adminClientMock) removeUser(ctx context.Context, accessKey string) error {
return minioRemoveUserMock(accessKey)
}
//mock function of getUserInfo()
func (ac adminClientMock) getUserInfo(ctx context.Context, accessKey string) (madmin.UserInfo, error) {
return minioGetUserInfoMock(accessKey)
}
//mock function of setUserStatus()
func (ac adminClientMock) setUserStatus(ctx context.Context, accessKey string, status madmin.AccountStatus) error {
return minioSetUserStatusMock(accessKey, status)
}
func TestListUsers(t *testing.T) {
assert := asrt.New(t)
adminClient := adminClientMock{}
ctx := context.Background()
adminClient := AdminClientMock{}
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
// Test-1 : listUsers() Get response from minio client with two users and return the same number on listUsers()
// mock minIO client
mockUserMap := map[string]madmin.UserInfo{
@@ -116,8 +85,9 @@ func TestListUsers(t *testing.T) {
func TestAddUser(t *testing.T) {
assert := asrt.New(t)
adminClient := adminClientMock{}
ctx := context.Background()
adminClient := AdminClientMock{}
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
// Test-1: valid case of adding a user with a proper access key
accessKey := "ABCDEFGHI"
secretKey := "ABCDEFGHIABCDEFGHI"
@@ -132,15 +102,15 @@ func TestAddUser(t *testing.T) {
}
// mock function response from addUser() return no error
minioAddUserMock = func(accessKey, secretKey string) error {
minioAddUserMock = func(_, _ string) error {
return nil
}
minioGetUserInfoMock = func(accessKey string) (madmin.UserInfo, error) {
minioGetUserInfoMock = func(_ string) (madmin.UserInfo, error) {
return *mockResponse, nil
}
minioUpdateGroupMembersMock = func(remove madmin.GroupAddRemove) error {
minioUpdateGroupMembersMock = func(_ madmin.GroupAddRemove) error {
return nil
}
// Test-1: Add a user
@@ -165,7 +135,7 @@ func TestAddUser(t *testing.T) {
accessKey = "AB"
secretKey = "ABCDEFGHIABCDEFGHI"
// mock function response from addUser() return no error
minioAddUserMock = func(accessKey, secretKey string) error {
minioAddUserMock = func(_, _ string) error {
return errors.New("error")
}
@@ -180,7 +150,7 @@ func TestAddUser(t *testing.T) {
}
// Test-4: add groups function returns an error
minioUpdateGroupMembersMock = func(remove madmin.GroupAddRemove) error {
minioUpdateGroupMembersMock = func(_ madmin.GroupAddRemove) error {
return errors.New("error")
}
@@ -198,13 +168,14 @@ func TestAddUser(t *testing.T) {
func TestRemoveUser(t *testing.T) {
assert := asrt.New(t)
// mock minIO client
adminClient := adminClientMock{}
ctx := context.Background()
adminClient := AdminClientMock{}
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
function := "removeUser()"
// Test-1: removeUser() delete a user
// mock function response from removeUser(accessKey)
minioRemoveUserMock = func(accessKey string) error {
minioRemoveUserMock = func(_ string) error {
return nil
}
@@ -214,7 +185,7 @@ func TestRemoveUser(t *testing.T) {
// Test-2: removeUser() make sure errors are handled correctly when error on DeleteUser()
// mock function response from removeUser(accessKey)
minioRemoveUserMock = func(accessKey string) error {
minioRemoveUserMock = func(_ string) error {
return errors.New("error")
}
@@ -226,8 +197,9 @@ func TestRemoveUser(t *testing.T) {
func TestUserGroups(t *testing.T) {
assert := asrt.New(t)
// mock minIO client
adminClient := adminClientMock{}
ctx := context.Background()
adminClient := AdminClientMock{}
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
function := "updateUserGroups()"
mockUserGroups := []string{"group1", "group2", "group3"}
@@ -248,11 +220,11 @@ func TestUserGroups(t *testing.T) {
// Test-1: updateUserGroups() updates the groups for a user
// mock function response from updateUserGroups(accessKey, groupsToAssign)
minioGetUserInfoMock = func(accessKey string) (madmin.UserInfo, error) {
minioGetUserInfoMock = func(_ string) (madmin.UserInfo, error) {
return *mockResponse, nil
}
minioUpdateGroupMembersMock = func(remove madmin.GroupAddRemove) error {
minioUpdateGroupMembersMock = func(_ madmin.GroupAddRemove) error {
return nil
}
@@ -263,7 +235,7 @@ func TestUserGroups(t *testing.T) {
// Test-2: updateUserGroups() make sure errors are handled correctly when error on UpdateGroupMembersMock()
// mock function response from removeUser(accessKey)
minioUpdateGroupMembersMock = func(remove madmin.GroupAddRemove) error {
minioUpdateGroupMembersMock = func(_ madmin.GroupAddRemove) error {
return errors.New("error")
}
@@ -272,11 +244,11 @@ func TestUserGroups(t *testing.T) {
}
// Test-3: updateUserGroups() make sure we return the correct error when getUserInfo returns error
minioGetUserInfoMock = func(accessKey string) (madmin.UserInfo, error) {
minioGetUserInfoMock = func(_ string) (madmin.UserInfo, error) {
return *mockEmptyResponse, errors.New("error getting user ")
}
minioUpdateGroupMembersMock = func(remove madmin.GroupAddRemove) error {
minioUpdateGroupMembersMock = func(_ madmin.GroupAddRemove) error {
return nil
}
@@ -287,8 +259,9 @@ func TestUserGroups(t *testing.T) {
func TestGetUserInfo(t *testing.T) {
assert := asrt.New(t)
adminClient := adminClientMock{}
ctx := context.Background()
adminClient := AdminClientMock{}
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
// Test-1 : getUserInfo() get user info
userName := "userNameTest"
@@ -306,7 +279,7 @@ func TestGetUserInfo(t *testing.T) {
}
// mock function response from getUserInfo()
minioGetUserInfoMock = func(username string) (madmin.UserInfo, error) {
minioGetUserInfoMock = func(_ string) (madmin.UserInfo, error) {
return *mockResponse, nil
}
function := "getUserInfo()"
@@ -321,7 +294,7 @@ func TestGetUserInfo(t *testing.T) {
assert.Equal(mockResponse.Status, info.Status)
// Test-2 : getUserInfo() Return error and see that the error is handled correctly and returned
minioGetUserInfoMock = func(username string) (madmin.UserInfo, error) {
minioGetUserInfoMock = func(_ string) (madmin.UserInfo, error) {
return *emptyMockResponse, errors.New("error")
}
_, err = getUserInfo(ctx, adminClient, userName)
@@ -332,14 +305,15 @@ func TestGetUserInfo(t *testing.T) {
func TestSetUserStatus(t *testing.T) {
assert := asrt.New(t)
adminClient := adminClientMock{}
adminClient := AdminClientMock{}
function := "setUserStatus()"
userName := "userName123"
ctx := context.Background()
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
// Test-1: setUserStatus() update valid disabled status
expectedStatus := "disabled"
minioSetUserStatusMock = func(accessKey string, status madmin.AccountStatus) error {
minioSetUserStatusMock = func(_ string, _ madmin.AccountStatus) error {
return nil
}
if err := setUserStatus(ctx, adminClient, userName, expectedStatus); err != nil {
@@ -347,7 +321,7 @@ func TestSetUserStatus(t *testing.T) {
}
// Test-2: setUserStatus() update valid enabled status
expectedStatus = "enabled"
minioSetUserStatusMock = func(accessKey string, status madmin.AccountStatus) error {
minioSetUserStatusMock = func(_ string, _ madmin.AccountStatus) error {
return nil
}
if err := setUserStatus(ctx, adminClient, userName, expectedStatus); err != nil {
@@ -355,7 +329,7 @@ func TestSetUserStatus(t *testing.T) {
}
// Test-3: setUserStatus() update invalid status, should send error
expectedStatus = "invalid"
minioSetUserStatusMock = func(accessKey string, status madmin.AccountStatus) error {
minioSetUserStatusMock = func(_ string, _ madmin.AccountStatus) error {
return nil
}
if err := setUserStatus(ctx, adminClient, userName, expectedStatus); assert.Error(err) {
@@ -363,7 +337,7 @@ func TestSetUserStatus(t *testing.T) {
}
// Test-4: setUserStatus() handler error correctly
expectedStatus = "enabled"
minioSetUserStatusMock = func(accessKey string, status madmin.AccountStatus) error {
minioSetUserStatusMock = func(_ string, _ madmin.AccountStatus) error {
return errors.New("error")
}
if err := setUserStatus(ctx, adminClient, userName, expectedStatus); assert.Error(err) {
@@ -374,8 +348,9 @@ func TestSetUserStatus(t *testing.T) {
func TestUserGroupsBulk(t *testing.T) {
assert := asrt.New(t)
// mock minIO client
adminClient := adminClientMock{}
ctx := context.Background()
adminClient := AdminClientMock{}
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
function := "updateUserGroups()"
mockUserGroups := []string{"group1", "group2", "group3"}
@@ -383,7 +358,7 @@ func TestUserGroupsBulk(t *testing.T) {
// Test-1: addUsersListToGroups() updates the groups for a users list
// mock function response from updateUserGroups(accessKey, groupsToAssign)
minioUpdateGroupMembersMock = func(remove madmin.GroupAddRemove) error {
minioUpdateGroupMembersMock = func(_ madmin.GroupAddRemove) error {
return nil
}
@@ -393,7 +368,7 @@ func TestUserGroupsBulk(t *testing.T) {
// Test-2: addUsersListToGroups() make sure errors are handled correctly when error on updateGroupMembers()
// mock function response from removeUser(accessKey)
minioUpdateGroupMembersMock = func(remove madmin.GroupAddRemove) error {
minioUpdateGroupMembersMock = func(_ madmin.GroupAddRemove) error {
return errors.New("error")
}
@@ -404,14 +379,17 @@ func TestUserGroupsBulk(t *testing.T) {
func TestListUsersWithAccessToBucket(t *testing.T) {
assert := asrt.New(t)
ctx := context.Background()
adminClient := adminClientMock{}
user1 := madmin.UserInfo{SecretKey: "testtest",
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
adminClient := AdminClientMock{}
user1 := madmin.UserInfo{
SecretKey: "testtest",
PolicyName: "consoleAdmin,testPolicy,redundantPolicy",
Status: "enabled",
MemberOf: []string{"group1"},
}
user2 := madmin.UserInfo{SecretKey: "testtest",
user2 := madmin.UserInfo{
SecretKey: "testtest",
PolicyName: "testPolicy, otherPolicy",
Status: "enabled",
MemberOf: []string{"group1"},
@@ -517,7 +495,7 @@ func TestListUsersWithAccessToBucket(t *testing.T) {
}
return mockResponse, nil
}
return nil, ErrorGeneric
return nil, ErrDefault
}
type args struct {
bucket string
@@ -549,10 +527,9 @@ func TestListUsersWithAccessToBucket(t *testing.T) {
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
t.Run(tt.name, func(_ *testing.T) {
got, _ := listUsersWithAccessToBucket(ctx, adminClient, tt.args.bucket)
assert.Equal(got, tt.want)
})
}
}

692
api/client-admin.go Normal file
View File

@@ -0,0 +1,692 @@
// This file is part of MinIO Console Server
// Copyright (c) 2021 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package api
import (
"bytes"
"context"
"encoding/json"
"io"
"net"
"net/http"
"net/url"
"regexp"
"strings"
"time"
"github.com/minio/console/pkg"
"github.com/minio/console/pkg/utils"
"github.com/minio/console/models"
"github.com/minio/madmin-go/v3"
"github.com/minio/minio-go/v7/pkg/credentials"
iampolicy "github.com/minio/pkg/v3/policy"
)
const globalAppName = "MinIO Console"
// MinioAdmin interface with all functions to be implemented
// by mock when testing, it should include all MinioAdmin respective api calls
// that are used within this project.
type MinioAdmin interface {
listUsers(ctx context.Context) (map[string]madmin.UserInfo, error)
addUser(ctx context.Context, acessKey, SecretKey string) error
removeUser(ctx context.Context, accessKey string) error
getUserInfo(ctx context.Context, accessKey string) (madmin.UserInfo, error)
setUserStatus(ctx context.Context, accessKey string, status madmin.AccountStatus) error
listGroups(ctx context.Context) ([]string, error)
updateGroupMembers(ctx context.Context, greq madmin.GroupAddRemove) error
getGroupDescription(ctx context.Context, group string) (*madmin.GroupDesc, error)
setGroupStatus(ctx context.Context, group string, status madmin.GroupStatus) error
listPolicies(ctx context.Context) (map[string]*iampolicy.Policy, error)
getPolicy(ctx context.Context, name string) (*iampolicy.Policy, error)
removePolicy(ctx context.Context, name string) error
addPolicy(ctx context.Context, name string, policy *iampolicy.Policy) error
setPolicy(ctx context.Context, policyName, entityName string, isGroup bool) error
getConfigKV(ctx context.Context, key string) ([]byte, error)
helpConfigKV(ctx context.Context, subSys, key string, envOnly bool) (madmin.Help, error)
helpConfigKVGlobal(ctx context.Context, envOnly bool) (madmin.Help, error)
setConfigKV(ctx context.Context, kv string) (restart bool, err error)
delConfigKV(ctx context.Context, kv string) (err error)
serviceRestart(ctx context.Context) error
serverInfo(ctx context.Context) (madmin.InfoMessage, error)
startProfiling(ctx context.Context, profiler madmin.ProfilerType) ([]madmin.StartProfilingResult, error)
stopProfiling(ctx context.Context) (io.ReadCloser, error)
serviceTrace(ctx context.Context, threshold int64, s3, internal, storage, os, errTrace bool) <-chan madmin.ServiceTraceInfo
getLogs(ctx context.Context, node string, lineCnt int, logKind string) <-chan madmin.LogInfo
AccountInfo(ctx context.Context) (madmin.AccountInfo, error)
heal(ctx context.Context, bucket, prefix string, healOpts madmin.HealOpts, clientToken string,
forceStart, forceStop bool) (healStart madmin.HealStartSuccess, healTaskStatus madmin.HealTaskStatus, err error)
// Service Accounts
addServiceAccount(ctx context.Context, policy string, user string, accessKey string, secretKey string, name string, description string, expiry *time.Time, comment string) (madmin.Credentials, error)
listServiceAccounts(ctx context.Context, user string) (madmin.ListServiceAccountsResp, error)
deleteServiceAccount(ctx context.Context, serviceAccount string) error
infoServiceAccount(ctx context.Context, serviceAccount string) (madmin.InfoServiceAccountResp, error)
updateServiceAccount(ctx context.Context, serviceAccount string, opts madmin.UpdateServiceAccountReq) error
// Remote Buckets
listRemoteBuckets(ctx context.Context, bucket, arnType string) (targets []madmin.BucketTarget, err error)
getRemoteBucket(ctx context.Context, bucket, arnType string) (targets *madmin.BucketTarget, err error)
removeRemoteBucket(ctx context.Context, bucket, arn string) error
addRemoteBucket(ctx context.Context, bucket string, target *madmin.BucketTarget) (string, error)
// Account password management
changePassword(ctx context.Context, accessKey, secretKey string) error
serverHealthInfo(ctx context.Context, deadline time.Duration) (interface{}, string, error)
// List Tiers
listTiers(ctx context.Context) ([]*madmin.TierConfig, error)
// Tier Info
tierStats(ctx context.Context) ([]madmin.TierInfo, error)
// Add Tier
addTier(ctx context.Context, tier *madmin.TierConfig) error
// Edit Tier Credentials
editTierCreds(ctx context.Context, tierName string, creds madmin.TierCreds) error
// verify Tier status
verifyTierStatus(ctx context.Context, tierName string) error
// remove empty Tier
removeTier(ctx context.Context, tierName string) error
// Speedtest
speedtest(ctx context.Context, opts madmin.SpeedtestOpts) (chan madmin.SpeedTestResult, error)
// Site Relication
getSiteReplicationInfo(ctx context.Context) (*madmin.SiteReplicationInfo, error)
addSiteReplicationInfo(ctx context.Context, sites []madmin.PeerSite, opts madmin.SRAddOptions) (*madmin.ReplicateAddStatus, error)
editSiteReplicationInfo(ctx context.Context, site madmin.PeerInfo, opts madmin.SREditOptions) (*madmin.ReplicateEditStatus, error)
deleteSiteReplicationInfo(ctx context.Context, removeReq madmin.SRRemoveReq) (*madmin.ReplicateRemoveStatus, error)
// Replication status
getSiteReplicationStatus(ctx context.Context, params madmin.SRStatusOptions) (*madmin.SRStatusInfo, error)
// KMS
kmsStatus(ctx context.Context) (madmin.KMSStatus, error)
kmsMetrics(ctx context.Context) (*madmin.KMSMetrics, error)
kmsAPIs(ctx context.Context) ([]madmin.KMSAPI, error)
kmsVersion(ctx context.Context) (*madmin.KMSVersion, error)
createKey(ctx context.Context, key string) error
listKeys(ctx context.Context, pattern string) ([]madmin.KMSKeyInfo, error)
keyStatus(ctx context.Context, key string) (*madmin.KMSKeyStatus, error)
// IDP
addOrUpdateIDPConfig(ctx context.Context, idpType, cfgName, cfgData string, update bool) (restart bool, err error)
listIDPConfig(ctx context.Context, idpType string) ([]madmin.IDPListItem, error)
deleteIDPConfig(ctx context.Context, idpType, cfgName string) (restart bool, err error)
getIDPConfig(ctx context.Context, cfgType, cfgName string) (c madmin.IDPConfig, err error)
// LDAP
getLDAPPolicyEntities(ctx context.Context, query madmin.PolicyEntitiesQuery) (madmin.PolicyEntitiesResult, error)
}
// Interface implementation
//
// Define the structure of a minIO Client and define the functions that are actually used
// from minIO api.
type AdminClient struct {
Client *madmin.AdminClient
}
func (ac AdminClient) changePassword(ctx context.Context, accessKey, secretKey string) error {
return ac.Client.SetUser(ctx, accessKey, secretKey, madmin.AccountEnabled)
}
// implements madmin.ListUsers()
func (ac AdminClient) listUsers(ctx context.Context) (map[string]madmin.UserInfo, error) {
return ac.Client.ListUsers(ctx)
}
// implements madmin.AddUser()
func (ac AdminClient) addUser(ctx context.Context, accessKey, secretKey string) error {
return ac.Client.AddUser(ctx, accessKey, secretKey)
}
// implements madmin.RemoveUser()
func (ac AdminClient) removeUser(ctx context.Context, accessKey string) error {
return ac.Client.RemoveUser(ctx, accessKey)
}
// implements madmin.GetUserInfo()
func (ac AdminClient) getUserInfo(ctx context.Context, accessKey string) (madmin.UserInfo, error) {
return ac.Client.GetUserInfo(ctx, accessKey)
}
// implements madmin.SetUserStatus()
func (ac AdminClient) setUserStatus(ctx context.Context, accessKey string, status madmin.AccountStatus) error {
return ac.Client.SetUserStatus(ctx, accessKey, status)
}
// implements madmin.ListGroups()
func (ac AdminClient) listGroups(ctx context.Context) ([]string, error) {
return ac.Client.ListGroups(ctx)
}
// implements madmin.UpdateGroupMembers()
func (ac AdminClient) updateGroupMembers(ctx context.Context, greq madmin.GroupAddRemove) error {
return ac.Client.UpdateGroupMembers(ctx, greq)
}
// implements madmin.GetGroupDescription(group)
func (ac AdminClient) getGroupDescription(ctx context.Context, group string) (*madmin.GroupDesc, error) {
return ac.Client.GetGroupDescription(ctx, group)
}
// implements madmin.SetGroupStatus(group, status)
func (ac AdminClient) setGroupStatus(ctx context.Context, group string, status madmin.GroupStatus) error {
return ac.Client.SetGroupStatus(ctx, group, status)
}
// implements madmin.ListCannedPolicies()
func (ac AdminClient) listPolicies(ctx context.Context) (map[string]*iampolicy.Policy, error) {
policyMap, err := ac.Client.ListCannedPolicies(ctx)
if err != nil {
return nil, err
}
policies := make(map[string]*iampolicy.Policy, len(policyMap))
for k, v := range policyMap {
p, err := iampolicy.ParseConfig(bytes.NewReader(v))
if err != nil {
return nil, err
}
policies[k] = p
}
return policies, nil
}
// implements madmin.ListCannedPolicies()
func (ac AdminClient) getPolicy(ctx context.Context, name string) (*iampolicy.Policy, error) {
info, err := ac.Client.InfoCannedPolicyV2(ctx, name)
if err != nil {
return nil, err
}
return iampolicy.ParseConfig(bytes.NewReader(info.Policy))
}
// implements madmin.RemoveCannedPolicy()
func (ac AdminClient) removePolicy(ctx context.Context, name string) error {
return ac.Client.RemoveCannedPolicy(ctx, name)
}
// implements madmin.AddCannedPolicy()
func (ac AdminClient) addPolicy(ctx context.Context, name string, policy *iampolicy.Policy) error {
buf, err := json.Marshal(policy)
if err != nil {
return err
}
return ac.Client.AddCannedPolicy(ctx, name, buf)
}
// implements madmin.SetPolicy()
func (ac AdminClient) setPolicy(ctx context.Context, policyName, entityName string, isGroup bool) error {
// nolint:staticcheck // ignore SA1019
return ac.Client.SetPolicy(ctx, policyName, entityName, isGroup)
}
// implements madmin.GetConfigKV()
func (ac AdminClient) getConfigKV(ctx context.Context, key string) ([]byte, error) {
return ac.Client.GetConfigKV(ctx, key)
}
// implements madmin.HelpConfigKV()
func (ac AdminClient) helpConfigKV(ctx context.Context, subSys, key string, envOnly bool) (madmin.Help, error) {
return ac.Client.HelpConfigKV(ctx, subSys, key, envOnly)
}
// implements madmin.helpConfigKVGlobal()
func (ac AdminClient) helpConfigKVGlobal(ctx context.Context, envOnly bool) (madmin.Help, error) {
return ac.Client.HelpConfigKV(ctx, "", "", envOnly)
}
// implements madmin.SetConfigKV()
func (ac AdminClient) setConfigKV(ctx context.Context, kv string) (restart bool, err error) {
return ac.Client.SetConfigKV(ctx, kv)
}
// implements madmin.DelConfigKV()
func (ac AdminClient) delConfigKV(ctx context.Context, kv string) (err error) {
_, err = ac.Client.DelConfigKV(ctx, kv)
return err
}
// implements madmin.ServiceRestart()
func (ac AdminClient) serviceRestart(ctx context.Context) (err error) {
return ac.Client.ServiceRestart(ctx)
}
// implements madmin.ServerInfo()
func (ac AdminClient) serverInfo(ctx context.Context) (madmin.InfoMessage, error) {
return ac.Client.ServerInfo(ctx)
}
// implements madmin.StartProfiling()
func (ac AdminClient) startProfiling(ctx context.Context, profiler madmin.ProfilerType) ([]madmin.StartProfilingResult, error) {
return ac.Client.StartProfiling(ctx, profiler)
}
// implements madmin.DownloadProfilingData()
func (ac AdminClient) stopProfiling(ctx context.Context) (io.ReadCloser, error) {
return ac.Client.DownloadProfilingData(ctx)
}
// implements madmin.ServiceTrace()
func (ac AdminClient) serviceTrace(ctx context.Context, threshold int64, _, internal, storage, os, errTrace bool) <-chan madmin.ServiceTraceInfo {
thresholdT := time.Duration(threshold)
tracingOptions := madmin.ServiceTraceOpts{
S3: true,
OnlyErrors: errTrace,
Internal: internal,
Storage: storage,
OS: os,
Threshold: thresholdT,
}
return ac.Client.ServiceTrace(ctx, tracingOptions)
}
// implements madmin.GetLogs()
func (ac AdminClient) getLogs(ctx context.Context, node string, lineCnt int, logKind string) <-chan madmin.LogInfo {
return ac.Client.GetLogs(ctx, node, lineCnt, logKind)
}
// implements madmin.AddServiceAccount()
func (ac AdminClient) addServiceAccount(ctx context.Context, policy string, user string, accessKey string, secretKey string, name string, description string, expiry *time.Time, comment string) (madmin.Credentials, error) {
return ac.Client.AddServiceAccount(ctx, madmin.AddServiceAccountReq{
Policy: []byte(policy),
TargetUser: user,
AccessKey: accessKey,
SecretKey: secretKey,
Name: name,
Description: description,
Expiration: expiry,
Comment: comment,
})
}
// implements madmin.ListServiceAccounts()
func (ac AdminClient) listServiceAccounts(ctx context.Context, user string) (madmin.ListServiceAccountsResp, error) {
return ac.Client.ListServiceAccounts(ctx, user)
}
// implements madmin.DeleteServiceAccount()
func (ac AdminClient) deleteServiceAccount(ctx context.Context, serviceAccount string) error {
return ac.Client.DeleteServiceAccount(ctx, serviceAccount)
}
// implements madmin.InfoServiceAccount()
func (ac AdminClient) infoServiceAccount(ctx context.Context, serviceAccount string) (madmin.InfoServiceAccountResp, error) {
return ac.Client.InfoServiceAccount(ctx, serviceAccount)
}
// implements madmin.UpdateServiceAccount()
func (ac AdminClient) updateServiceAccount(ctx context.Context, serviceAccount string, opts madmin.UpdateServiceAccountReq) error {
return ac.Client.UpdateServiceAccount(ctx, serviceAccount, opts)
}
// AccountInfo implements madmin.AccountInfo()
func (ac AdminClient) AccountInfo(ctx context.Context) (madmin.AccountInfo, error) {
return ac.Client.AccountInfo(ctx, madmin.AccountOpts{})
}
func (ac AdminClient) heal(ctx context.Context, bucket, prefix string, healOpts madmin.HealOpts, clientToken string,
forceStart, forceStop bool,
) (healStart madmin.HealStartSuccess, healTaskStatus madmin.HealTaskStatus, err error) {
return ac.Client.Heal(ctx, bucket, prefix, healOpts, clientToken, forceStart, forceStop)
}
// listRemoteBuckets - return a list of remote buckets
func (ac AdminClient) listRemoteBuckets(ctx context.Context, bucket, arnType string) (targets []madmin.BucketTarget, err error) {
return ac.Client.ListRemoteTargets(ctx, bucket, arnType)
}
// getRemoteBucket - gets remote bucked based on a given bucket name
func (ac AdminClient) getRemoteBucket(ctx context.Context, bucket, arnType string) (*madmin.BucketTarget, error) {
targets, err := ac.Client.ListRemoteTargets(ctx, bucket, arnType)
if err != nil {
return nil, err
}
if len(targets) > 0 {
return &targets[0], nil
}
return nil, err
}
// removeRemoteBucket removes a remote target associated with particular ARN for this bucket
func (ac AdminClient) removeRemoteBucket(ctx context.Context, bucket, arn string) error {
return ac.Client.RemoveRemoteTarget(ctx, bucket, arn)
}
// addRemoteBucket sets up a remote target for this bucket
func (ac AdminClient) addRemoteBucket(ctx context.Context, bucket string, target *madmin.BucketTarget) (string, error) {
return ac.Client.SetRemoteTarget(ctx, bucket, target)
}
func (ac AdminClient) setBucketQuota(ctx context.Context, bucket string, quota *madmin.BucketQuota) error {
return ac.Client.SetBucketQuota(ctx, bucket, quota)
}
func (ac AdminClient) getBucketQuota(ctx context.Context, bucket string) (madmin.BucketQuota, error) {
return ac.Client.GetBucketQuota(ctx, bucket)
}
// serverHealthInfo implements mc.ServerHealthInfo - Connect to a minio server and call Health Info Management API
func (ac AdminClient) serverHealthInfo(ctx context.Context, deadline time.Duration) (interface{}, string, error) {
info := madmin.HealthInfo{}
var healthInfo interface{}
var version string
var tryCount int
for info.Version == "" && tryCount < 10 {
var resp *http.Response
var err error
resp, version, err = ac.Client.ServerHealthInfo(ctx, madmin.HealthDataTypesList, deadline, "")
if err != nil {
return nil, version, err
}
decoder := json.NewDecoder(resp.Body)
for {
if err = decoder.Decode(&info); err != nil {
break
}
}
tryCount++
time.Sleep(2 * time.Second)
}
if info.Version == "" {
return nil, "", ErrHealthReportFail
}
healthInfo = info
return healthInfo, version, nil
}
// implements madmin.listTiers()
func (ac AdminClient) listTiers(ctx context.Context) ([]*madmin.TierConfig, error) {
return ac.Client.ListTiers(ctx)
}
// implements madmin.tierStats()
func (ac AdminClient) tierStats(ctx context.Context) ([]madmin.TierInfo, error) {
return ac.Client.TierStats(ctx)
}
// implements madmin.AddTier()
func (ac AdminClient) addTier(ctx context.Context, cfg *madmin.TierConfig) error {
return ac.Client.AddTier(ctx, cfg)
}
// implements madmin.Inspect()
func (ac AdminClient) inspect(ctx context.Context, insOpts madmin.InspectOptions) ([]byte, io.ReadCloser, error) {
return ac.Client.Inspect(ctx, insOpts)
}
// implements madmin.EditTier()
func (ac AdminClient) editTierCreds(ctx context.Context, tierName string, creds madmin.TierCreds) error {
return ac.Client.EditTier(ctx, tierName, creds)
}
// implements madmin.VerifyTier()
func (ac AdminClient) verifyTierStatus(ctx context.Context, tierName string) error {
return ac.Client.VerifyTier(ctx, tierName)
}
// implements madmin.RemoveTier()
func (ac AdminClient) removeTier(ctx context.Context, tierName string) error {
return ac.Client.RemoveTier(ctx, tierName)
}
func NewMinioAdminClient(ctx context.Context, sessionClaims *models.Principal) (*madmin.AdminClient, error) {
clientIP := utils.ClientIPFromContext(ctx)
adminClient, err := newAdminFromClaims(sessionClaims, clientIP)
if err != nil {
return nil, err
}
adminClient.SetAppInfo(globalAppName, pkg.Version)
return adminClient, nil
}
// newAdminFromClaims creates a minio admin from Decrypted claims using Assume role credentials
func newAdminFromClaims(claims *models.Principal, clientIP string) (*madmin.AdminClient, error) {
tlsEnabled := getMinIOEndpointIsSecure()
endpoint := getMinIOEndpoint()
adminClient, err := madmin.NewWithOptions(endpoint, &madmin.Options{
Creds: credentials.NewStaticV4(claims.STSAccessKeyID, claims.STSSecretAccessKey, claims.STSSessionToken),
Secure: tlsEnabled,
})
if err != nil {
return nil, err
}
adminClient.SetAppInfo(globalAppName, pkg.Version)
adminClient.SetCustomTransport(PrepareSTSClientTransport(clientIP))
return adminClient, nil
}
// newAdminFromCreds Creates a minio client using custom credentials for connecting to a remote host
func newAdminFromCreds(accessKey, secretKey, endpoint string, tlsEnabled bool) (*madmin.AdminClient, error) {
minioClient, err := madmin.NewWithOptions(endpoint, &madmin.Options{
Creds: credentials.NewStaticV4(accessKey, secretKey, ""),
Secure: tlsEnabled,
})
if err != nil {
return nil, err
}
minioClient.SetAppInfo(globalAppName, pkg.Version)
return minioClient, nil
}
// isLocalAddress returns true if the url contains an IPv4/IPv6 hostname
// that points to the local machine - FQDN are not supported
func isLocalIPEndpoint(endpoint string) bool {
u, err := url.Parse(endpoint)
if err != nil {
return false
}
return isLocalIPAddress(u.Hostname())
}
// isLocalAddress returns true if the url contains an IPv4/IPv6 hostname
// that points to the local machine - FQDN are not supported
func isLocalIPAddress(ipAddr string) bool {
if ipAddr == "" {
return false
}
if ipAddr == "localhost" {
return true
}
ip := net.ParseIP(ipAddr)
return ip != nil && ip.IsLoopback()
}
// GetConsoleHTTPClient caches different http clients depending on the target endpoint while taking
// in consideration CA certs stored in ${HOME}/.console/certs/CAs and ${HOME}/.minio/certs/CAs
// If the target endpoint points to a loopback device, skip the TLS verification.
func GetConsoleHTTPClient(clientIP string) *http.Client {
return PrepareConsoleHTTPClient(clientIP)
}
var (
// De-facto standard header keys.
xForwardedFor = http.CanonicalHeaderKey("X-Forwarded-For")
xRealIP = http.CanonicalHeaderKey("X-Real-IP")
)
var (
// RFC7239 defines a new "Forwarded: " header designed to replace the
// existing use of X-Forwarded-* headers.
// e.g. Forwarded: for=192.0.2.60;proto=https;by=203.0.113.43
forwarded = http.CanonicalHeaderKey("Forwarded")
// Allows for a sub-match of the first value after 'for=' to the next
// comma, semi-colon or space. The match is case-insensitive.
forRegex = regexp.MustCompile(`(?i)(?:for=)([^(;|,| )]+)(.*)`)
)
// getSourceIPFromHeaders retrieves the IP from the X-Forwarded-For, X-Real-IP
// and RFC7239 Forwarded headers (in that order)
func getSourceIPFromHeaders(r *http.Request) string {
var addr string
if fwd := r.Header.Get(xForwardedFor); fwd != "" {
// Only grab the first (client) address. Note that '192.168.0.1,
// 10.1.1.1' is a valid key for X-Forwarded-For where addresses after
// the first may represent forwarding proxies earlier in the chain.
s := strings.Index(fwd, ", ")
if s == -1 {
s = len(fwd)
}
addr = fwd[:s]
} else if fwd := r.Header.Get(xRealIP); fwd != "" {
// X-Real-IP should only contain one IP address (the client making the
// request).
addr = fwd
} else if fwd := r.Header.Get(forwarded); fwd != "" {
// match should contain at least two elements if the protocol was
// specified in the Forwarded header. The first element will always be
// the 'for=' capture, which we ignore. In the case of multiple IP
// addresses (for=8.8.8.8, 8.8.4.4, 172.16.1.20 is valid) we only
// extract the first, which should be the client IP.
if match := forRegex.FindStringSubmatch(fwd); len(match) > 1 {
// IPv6 addresses in Forwarded headers are quoted-strings. We strip
// these quotes.
addr = strings.Trim(match[1], `"`)
}
}
return addr
}
// getClientIP retrieves the IP from the request headers
// and falls back to r.RemoteAddr when necessary.
// however returns without bracketing.
func getClientIP(r *http.Request) string {
addr := getSourceIPFromHeaders(r)
if addr == "" {
addr = r.RemoteAddr
}
// Default to remote address if headers not set.
raddr, _, _ := net.SplitHostPort(addr)
if raddr == "" {
return addr
}
return raddr
}
func (ac AdminClient) speedtest(ctx context.Context, opts madmin.SpeedtestOpts) (chan madmin.SpeedTestResult, error) {
return ac.Client.Speedtest(ctx, opts)
}
// Site Replication
func (ac AdminClient) getSiteReplicationInfo(ctx context.Context) (*madmin.SiteReplicationInfo, error) {
res, err := ac.Client.SiteReplicationInfo(ctx)
if err != nil {
return nil, err
}
return &madmin.SiteReplicationInfo{
Enabled: res.Enabled,
Name: res.Name,
Sites: res.Sites,
ServiceAccountAccessKey: res.ServiceAccountAccessKey,
}, nil
}
func (ac AdminClient) addSiteReplicationInfo(ctx context.Context, sites []madmin.PeerSite, opts madmin.SRAddOptions) (*madmin.ReplicateAddStatus, error) {
res, err := ac.Client.SiteReplicationAdd(ctx, sites, opts)
if err != nil {
return nil, err
}
return &madmin.ReplicateAddStatus{
Success: res.Success,
Status: res.Status,
ErrDetail: res.ErrDetail,
InitialSyncErrorMessage: res.InitialSyncErrorMessage,
}, nil
}
func (ac AdminClient) editSiteReplicationInfo(ctx context.Context, site madmin.PeerInfo, opts madmin.SREditOptions) (*madmin.ReplicateEditStatus, error) {
res, err := ac.Client.SiteReplicationEdit(ctx, site, opts)
if err != nil {
return nil, err
}
return &madmin.ReplicateEditStatus{
Success: res.Success,
Status: res.Status,
ErrDetail: res.ErrDetail,
}, nil
}
func (ac AdminClient) deleteSiteReplicationInfo(ctx context.Context, removeReq madmin.SRRemoveReq) (*madmin.ReplicateRemoveStatus, error) {
res, err := ac.Client.SiteReplicationRemove(ctx, removeReq)
if err != nil {
return nil, err
}
return &madmin.ReplicateRemoveStatus{
Status: res.Status,
ErrDetail: res.ErrDetail,
}, nil
}
func (ac AdminClient) getSiteReplicationStatus(ctx context.Context, params madmin.SRStatusOptions) (*madmin.SRStatusInfo, error) {
res, err := ac.Client.SRStatusInfo(ctx, params)
if err != nil {
return nil, err
}
return &res, nil
}
func (ac AdminClient) kmsStatus(ctx context.Context) (madmin.KMSStatus, error) {
return ac.Client.KMSStatus(ctx)
}
func (ac AdminClient) kmsMetrics(ctx context.Context) (*madmin.KMSMetrics, error) {
return ac.Client.KMSMetrics(ctx)
}
func (ac AdminClient) kmsAPIs(ctx context.Context) ([]madmin.KMSAPI, error) {
return ac.Client.KMSAPIs(ctx)
}
func (ac AdminClient) kmsVersion(ctx context.Context) (*madmin.KMSVersion, error) {
return ac.Client.KMSVersion(ctx)
}
func (ac AdminClient) createKey(ctx context.Context, key string) error {
return ac.Client.CreateKey(ctx, key)
}
func (ac AdminClient) listKeys(ctx context.Context, pattern string) ([]madmin.KMSKeyInfo, error) {
return ac.Client.ListKeys(ctx, pattern)
}
func (ac AdminClient) keyStatus(ctx context.Context, key string) (*madmin.KMSKeyStatus, error) {
return ac.Client.GetKeyStatus(ctx, key)
}
func (ac AdminClient) addOrUpdateIDPConfig(ctx context.Context, idpType, cfgName, cfgData string, update bool) (restart bool, err error) {
return ac.Client.AddOrUpdateIDPConfig(ctx, idpType, cfgName, cfgData, update)
}
func (ac AdminClient) listIDPConfig(ctx context.Context, idpType string) ([]madmin.IDPListItem, error) {
return ac.Client.ListIDPConfig(ctx, idpType)
}
func (ac AdminClient) deleteIDPConfig(ctx context.Context, idpType, cfgName string) (restart bool, err error) {
return ac.Client.DeleteIDPConfig(ctx, idpType, cfgName)
}
func (ac AdminClient) getIDPConfig(ctx context.Context, idpType, cfgName string) (c madmin.IDPConfig, err error) {
return ac.Client.GetIDPConfig(ctx, idpType, cfgName)
}
func (ac AdminClient) getLDAPPolicyEntities(ctx context.Context, query madmin.PolicyEntitiesQuery) (madmin.PolicyEntitiesResult, error) {
return ac.Client.GetLDAPPolicyEntities(ctx, query)
}

View File

@@ -1,4 +1,4 @@
// This file is part of MinIO Orchestrator
// This file is part of MinIO Console Server
// Copyright (c) 2021 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
@@ -14,21 +14,20 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package restapi
package api
import (
"context"
"errors"
"fmt"
"io"
"net/url"
"path"
"strings"
"time"
"github.com/minio/minio-go/v7/pkg/replication"
"github.com/minio/minio-go/v7/pkg/sse"
"errors"
xnet "github.com/minio/pkg/v3/net"
"github.com/minio/console/models"
"github.com/minio/console/pkg"
@@ -229,11 +228,11 @@ type MCClient interface {
addNotificationConfig(ctx context.Context, arn string, events []string, prefix, suffix string, ignoreExisting bool) *probe.Error
removeNotificationConfig(ctx context.Context, arn string, event string, prefix string, suffix string) *probe.Error
watch(ctx context.Context, options mc.WatchOptions) (*mc.WatchObject, *probe.Error)
remove(ctx context.Context, isIncomplete, isRemoveBucket, isBypass bool, contentCh <-chan *mc.ClientContent) <-chan *probe.Error
remove(ctx context.Context, isIncomplete, isRemoveBucket, isBypass, forceDelete bool, contentCh <-chan *mc.ClientContent) <-chan mc.RemoveResult
list(ctx context.Context, opts mc.ListOptions) <-chan *mc.ClientContent
get(ctx context.Context, opts mc.GetOptions) (io.ReadCloser, *probe.Error)
shareDownload(ctx context.Context, versionID string, expires time.Duration) (string, *probe.Error)
setVersioning(ctx context.Context, status string) *probe.Error
setVersioning(ctx context.Context, status string, excludePrefix []string, excludeFolders bool) *probe.Error
}
// Interface implementation
@@ -262,12 +261,16 @@ func (c mcClient) setReplication(ctx context.Context, cfg *replication.Config, o
return c.client.SetReplication(ctx, cfg, opts)
}
func (c mcClient) setVersioning(ctx context.Context, status string) *probe.Error {
return c.client.SetVersion(ctx, status)
func (c mcClient) deleteAllReplicationRules(ctx context.Context) *probe.Error {
return c.client.RemoveReplication(ctx)
}
func (c mcClient) remove(ctx context.Context, isIncomplete, isRemoveBucket, isBypass bool, contentCh <-chan *mc.ClientContent) <-chan *probe.Error {
return c.client.Remove(ctx, isIncomplete, isRemoveBucket, isBypass, contentCh)
func (c mcClient) setVersioning(ctx context.Context, status string, excludePrefix []string, excludeFolders bool) *probe.Error {
return c.client.SetVersion(ctx, status, excludePrefix, excludeFolders)
}
func (c mcClient) remove(ctx context.Context, isIncomplete, isRemoveBucket, isBypass, forceDelete bool, contentCh <-chan *mc.ClientContent) <-chan mc.RemoveResult {
return c.client.Remove(ctx, isIncomplete, isRemoveBucket, isBypass, forceDelete, contentCh)
}
func (c mcClient) list(ctx context.Context, opts mc.ListOptions) <-chan *mc.ClientContent {
@@ -275,7 +278,8 @@ func (c mcClient) list(ctx context.Context, opts mc.ListOptions) <-chan *mc.Clie
}
func (c mcClient) get(ctx context.Context, opts mc.GetOptions) (io.ReadCloser, *probe.Error) {
return c.client.Get(ctx, opts)
rd, _, err := c.client.Get(ctx, opts)
return rd, err
}
func (c mcClient) shareDownload(ctx context.Context, versionID string, expires time.Duration) (string, *probe.Error) {
@@ -326,37 +330,68 @@ func (s consoleSTSAssumeRole) IsExpired() bool {
return s.stsAssumeRole.IsExpired()
}
func NewConsoleCredentials(accessKey, secretKey, location string) (*credentials.Credentials, error) {
func stsCredentials(minioURL, accessKey, secretKey, location, clientIP string) (*credentials.Credentials, error) {
if accessKey == "" || secretKey == "" {
return nil, errors.New("credentials endpoint, access and secret key are mandatory for AssumeRoleSTS")
}
opts := credentials.STSAssumeRoleOptions{
AccessKey: accessKey,
SecretKey: secretKey,
Location: location,
DurationSeconds: int(xjwt.GetConsoleSTSDuration().Seconds()),
}
stsAssumeRole := &credentials.STSAssumeRole{
Client: GetConsoleHTTPClient(clientIP),
STSEndpoint: minioURL,
Options: opts,
}
consoleSTSWrapper := consoleSTSAssumeRole{stsAssumeRole: stsAssumeRole}
return credentials.New(consoleSTSWrapper), nil
}
func NewConsoleCredentials(accessKey, secretKey, location, clientIP string) (*credentials.Credentials, error) {
minioURL := getMinIOServer()
// Future authentication methods can be added under this switch statement
switch {
// LDAP authentication for Console
case ldap.GetLDAPEnabled():
{
creds, err := auth.GetCredentialsFromLDAP(GetConsoleHTTPClient(), getMinIOServer(), accessKey, secretKey)
creds, err := auth.GetCredentialsFromLDAP(GetConsoleHTTPClient(clientIP), minioURL, accessKey, secretKey)
if err != nil {
return nil, err
}
// We verify if LDAP credentials are correct and no error is returned
_, err = creds.Get()
if err != nil && strings.Contains(strings.ToLower(err.Error()), "not found") {
// We try to use STS Credentials in case LDAP credentials are incorrect.
stsCreds, errSTS := stsCredentials(minioURL, accessKey, secretKey, location, clientIP)
// If there is an error with STS too, then we return the original LDAP error
if errSTS != nil {
LogError("error in STS credentials for LDAP case: %v ", errSTS)
// We return LDAP result
return creds, nil
}
_, err := stsCreds.Get()
// There is an error with STS credentials, We return the result of LDAP as STS is not a priority in this case.
if err != nil {
return creds, nil
}
return stsCreds, nil
}
return creds, nil
}
// default authentication for Console is via STS (Security Token Service) against MinIO
default:
{
if accessKey == "" || secretKey == "" {
return nil, errors.New("credentials endpoint, access and secret key are mandatory for AssumeRoleSTS")
}
opts := credentials.STSAssumeRoleOptions{
AccessKey: accessKey,
SecretKey: secretKey,
Location: location,
DurationSeconds: int(xjwt.GetConsoleSTSDuration().Seconds()),
}
stsAssumeRole := &credentials.STSAssumeRole{
Client: GetConsoleHTTPClient(),
STSEndpoint: getMinIOServer(),
Options: opts,
}
consoleSTSWrapper := consoleSTSAssumeRole{stsAssumeRole: stsAssumeRole}
return credentials.New(consoleSTSWrapper), nil
return stsCredentials(minioURL, accessKey, secretKey, location, clientIP)
}
}
}
@@ -364,45 +399,49 @@ func NewConsoleCredentials(accessKey, secretKey, location string) (*credentials.
// getConsoleCredentialsFromSession returns the *consoleCredentials.Login associated to the
// provided session token, this is useful for running the Expire() or IsExpired() operations
func getConsoleCredentialsFromSession(claims *models.Principal) *credentials.Credentials {
if claims == nil {
return credentials.NewStaticV4("", "", "")
}
return credentials.NewStaticV4(claims.STSAccessKeyID, claims.STSSecretAccessKey, claims.STSSessionToken)
}
// newMinioClient creates a new MinIO client based on the ConsoleCredentials extracted
// from the provided session token
func newMinioClient(claims *models.Principal) (*minio.Client, error) {
func newMinioClient(claims *models.Principal, clientIP string) (*minio.Client, error) {
creds := getConsoleCredentialsFromSession(claims)
minioClient, err := minio.New(getMinIOEndpoint(), &minio.Options{
endpoint := getMinIOEndpoint()
secure := getMinIOEndpointIsSecure()
minioClient, err := minio.New(endpoint, &minio.Options{
Creds: creds,
Secure: getMinIOEndpointIsSecure(),
Transport: GetConsoleHTTPClient().Transport,
Secure: secure,
Transport: GetConsoleHTTPClient(clientIP).Transport,
})
if err != nil {
return nil, err
}
// set user-agent to differentiate Console UI requests for auditing.
minioClient.SetAppInfo("MinIO Console", pkg.Version)
return minioClient, nil
}
// computeObjectURLWithoutEncode returns a MinIO url containing the object filename without encoding
func computeObjectURLWithoutEncode(bucketName, prefix string) (string, error) {
endpoint := getMinIOServer()
u, err := url.Parse(endpoint)
u, err := xnet.ParseHTTPURL(getMinIOServer())
if err != nil {
return "", fmt.Errorf("the provided endpoint is invalid")
return "", fmt.Errorf("the provided endpoint: '%s' is invalid", getMinIOServer())
}
objectURL := fmt.Sprintf("%s:%s", u.Hostname(), u.Port())
var p string
if strings.TrimSpace(bucketName) != "" {
objectURL = path.Join(objectURL, bucketName)
p = path.Join(p, bucketName)
}
if strings.TrimSpace(prefix) != "" {
objectURL = pathJoinFinalSlash(objectURL, prefix)
p = pathJoinFinalSlash(p, prefix)
}
objectURL = fmt.Sprintf("%s://%s", u.Scheme, objectURL)
return objectURL, nil
return u.String() + "/" + p, nil
}
// newS3BucketClient creates a new mc S3Client to talk to the server based on a bucket
func newS3BucketClient(claims *models.Principal, bucketName string, prefix string) (*mc.S3Client, error) {
func newS3BucketClient(claims *models.Principal, bucketName string, prefix string, clientIP string) (*mc.S3Client, error) {
if claims == nil {
return nil, fmt.Errorf("the provided credentials are invalid")
}
@@ -411,7 +450,7 @@ func newS3BucketClient(claims *models.Principal, bucketName string, prefix strin
if err != nil {
return nil, fmt.Errorf("the provided endpoint is invalid")
}
s3Config := newS3Config(objectURL, claims.STSAccessKeyID, claims.STSSecretAccessKey, claims.STSSessionToken, false)
s3Config := newS3Config(objectURL, claims.STSAccessKeyID, claims.STSSecretAccessKey, claims.STSSessionToken, clientIP)
client, pErr := mc.S3New(s3Config)
if pErr != nil {
return nil, pErr.Cause
@@ -433,24 +472,24 @@ func pathJoinFinalSlash(elem ...string) string {
return path.Join(elem...)
}
// Deprecated
// newS3Config simply creates a new Config struct using the passed
// parameters.
func newS3Config(endpoint, accessKey, secretKey, sessionToken string, insecure bool) *mc.Config {
func newS3Config(endpoint, accessKey, secretKey, sessionToken string, clientIP string) *mc.Config {
// We have a valid alias and hostConfig. We populate the/
// consoleCredentials from the match found in the config file.
s3Config := new(mc.Config)
s3Config.AppName = globalAppName
s3Config.AppVersion = pkg.Version
s3Config.Debug = false
s3Config.Insecure = insecure
s3Config.HostURL = endpoint
s3Config.AccessKey = accessKey
s3Config.SecretKey = secretKey
s3Config.SessionToken = sessionToken
s3Config.Signature = "S3v4"
s3Config.Transport = prepareSTSClientTransport(insecure)
return s3Config
return &mc.Config{
HostURL: endpoint,
AccessKey: accessKey,
SecretKey: secretKey,
SessionToken: sessionToken,
Signature: "S3v4",
AppName: globalAppName,
AppVersion: pkg.Version,
Insecure: isLocalIPEndpoint(endpoint),
Transport: &ConsoleTransport{
ClientIP: clientIP,
Transport: GlobalTransport,
},
}
}

View File

@@ -1,5 +1,5 @@
// This file is part of MinIO Orchestrator
// Copyright (c) 2021 MinIO, Inc.
// This file is part of MinIO Console Server
// Copyright (c) 2024 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
@@ -14,7 +14,7 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package restapi
package api
import "testing"
@@ -76,14 +76,15 @@ func Test_computeObjectURLWithoutEncode(t *testing.T) {
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
t.Run(tt.name, func(_ *testing.T) {
got, err := computeObjectURLWithoutEncode(tt.args.bucketName, tt.args.prefix)
if (err != nil) != tt.wantErr {
t.Errorf("computeObjectURLWithoutEncode() error = %v, wantErr %v", err, tt.wantErr)
return
t.Errorf("computeObjectURLWithoutEncode() errors = %v, wantErr %v", err, tt.wantErr)
}
if got != tt.want {
t.Errorf("computeObjectURLWithoutEncode() got = %v, want %v", got, tt.want)
if err == nil {
if got != tt.want {
t.Errorf("computeObjectURLWithoutEncode() got = %v, want %v", got, tt.want)
}
}
})
}

309
api/config.go Normal file
View File

@@ -0,0 +1,309 @@
// This file is part of MinIO Console Server
// Copyright (c) 2021 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package api
import (
"crypto/tls"
"crypto/x509"
"net"
"net/http"
"strconv"
"strings"
"time"
"github.com/minio/console/pkg/auth/idp/oauth2"
xcerts "github.com/minio/pkg/v3/certs"
"github.com/minio/pkg/v3/env"
xnet "github.com/minio/pkg/v3/net"
)
var (
// Port console default port
Port = "9090"
// Hostname console hostname
// avoid listening on 0.0.0.0 by default
// instead listen on all IPv4 and IPv6
// - Hostname should be empty.
Hostname = ""
// TLSPort console tls port
TLSPort = "9443"
// TLSRedirect console tls redirect rule
TLSRedirect = "on"
ConsoleResourceName = "console-ui"
)
var (
// GlobalRootCAs is CA root certificates, a nil value means system certs pool will be used
GlobalRootCAs *x509.CertPool
// GlobalPublicCerts has certificates Console will use to serve clients
GlobalPublicCerts []*x509.Certificate
// GlobalTLSCertsManager custom TLS Manager for SNI support
GlobalTLSCertsManager *xcerts.Manager
// GlobalTransport is common transport used for all HTTP calls, this is set via
// MinIO server to be the correct transport, however we still define some defaults
// here just in case.
GlobalTransport = &http.Transport{
Proxy: http.ProxyFromEnvironment,
DialContext: (&net.Dialer{
Timeout: 10 * time.Second,
KeepAlive: 15 * time.Second,
}).DialContext,
MaxIdleConns: 1024,
MaxIdleConnsPerHost: 1024,
IdleConnTimeout: 90 * time.Second,
TLSHandshakeTimeout: 10 * time.Second,
ExpectContinueTimeout: 10 * time.Second,
DisableCompression: true, // Set to avoid auto-decompression
TLSClientConfig: &tls.Config{
// Can't use SSLv3 because of POODLE and BEAST
// Can't use TLSv1.0 because of POODLE and BEAST using CBC cipher
// Can't use TLSv1.1 because of RC4 cipher usage
MinVersion: tls.VersionTLS12,
// Console runs in the same pod/node as MinIO this is acceptable.
InsecureSkipVerify: true,
RootCAs: GlobalRootCAs,
},
}
)
// MinIOConfig represents application configuration passed in from the MinIO
// server to the console.
type MinIOConfig struct {
OpenIDProviders oauth2.OpenIDPCfg
}
// GlobalMinIOConfig is the global application configuration passed in from the
// MinIO server.
var GlobalMinIOConfig MinIOConfig
func getMinIOServer() string {
return strings.TrimSpace(env.Get(ConsoleMinIOServer, "http://localhost:9000"))
}
func getSubnetProxy() string {
return strings.TrimSpace(env.Get(ConsoleSubnetProxy, ""))
}
func GetMinIORegion() string {
return strings.TrimSpace(env.Get(ConsoleMinIORegion, ""))
}
func getMinIOEndpoint() string {
u, err := xnet.ParseHTTPURL(getMinIOServer())
if err != nil {
panic(err)
}
return u.Host
}
func getMinIOEndpointIsSecure() bool {
u, err := xnet.ParseHTTPURL(getMinIOServer())
if err != nil {
panic(err)
}
return u.Scheme == "https"
}
// GetHostname gets console hostname set on env variable,
// default one or defined on run command
func GetHostname() string {
return strings.ToLower(env.Get(ConsoleHostname, Hostname))
}
// GetPort gets console por set on env variable
// or default one
func GetPort() int {
port, err := strconv.Atoi(env.Get(ConsolePort, Port))
if err != nil {
port = 9090
}
return port
}
// GetTLSPort gets console tls port set on env variable
// or default one
func GetTLSPort() int {
port, err := strconv.Atoi(env.Get(ConsoleTLSPort, TLSPort))
if err != nil {
port = 9443
}
return port
}
// If GetTLSRedirect is set to true, then only allow HTTPS requests. Default is true.
func GetTLSRedirect() string {
return strings.ToLower(env.Get(ConsoleSecureTLSRedirect, TLSRedirect))
}
// Get secure middleware env variable configurations
func GetSecureAllowedHosts() []string {
allowedHosts := env.Get(ConsoleSecureAllowedHosts, "")
if allowedHosts != "" {
return strings.Split(allowedHosts, ",")
}
return []string{}
}
// AllowedHostsAreRegex determines, if the provided AllowedHosts slice contains valid regular expressions. Default is false.
func GetSecureAllowedHostsAreRegex() bool {
return strings.ToLower(env.Get(ConsoleSecureAllowedHostsAreRegex, "off")) == "on"
}
// If FrameDeny is set to true, adds the X-Frame-Options header with the value of `DENY`. Default is true.
func GetSecureFrameDeny() bool {
return strings.ToLower(env.Get(ConsoleSecureFrameDeny, "on")) == "on"
}
// If ContentTypeNosniff is true, adds the X-Content-Type-Options header with the value `nosniff`. Default is true.
func GetSecureContentTypeNonSniff() bool {
return strings.ToLower(env.Get(ConsoleSecureContentTypeNoSniff, "on")) == "on"
}
// If BrowserXssFilter is true, adds the X-XSS-Protection header with the value `1; mode=block`. Default is true.
func GetSecureBrowserXSSFilter() bool {
return strings.ToLower(env.Get(ConsoleSecureBrowserXSSFilter, "on")) == "on"
}
// ContentSecurityPolicy allows the Content-Security-Policy header value to be set with a custom value. Default is "".
// Passing a template string will replace `$NONCE` with a dynamic nonce value of 16 bytes for each request which can be
// later retrieved using the Nonce function.
func GetSecureContentSecurityPolicy() string {
return env.Get(ConsoleSecureContentSecurityPolicy, "")
}
// ContentSecurityPolicyReportOnly allows the Content-Security-Policy-Report-Only header value to be set with a custom value. Default is "".
func GetSecureContentSecurityPolicyReportOnly() string {
return env.Get(ConsoleSecureContentSecurityPolicyReportOnly, "")
}
// HostsProxyHeaders is a set of header keys that may hold a proxied hostname value for the request.
func GetSecureHostsProxyHeaders() []string {
allowedHosts := env.Get(ConsoleSecureHostsProxyHeaders, "")
if allowedHosts != "" {
return strings.Split(allowedHosts, ",")
}
return []string{}
}
// TLSHost is the host name that is used to redirect HTTP requests to HTTPS. Default is "", which indicates to use the same host.
func GetSecureTLSHost() string {
tlsHost := env.Get(ConsoleSecureTLSHost, "")
if tlsHost == "" && Hostname != "" {
return net.JoinHostPort(Hostname, TLSPort)
}
return ""
}
// STSSeconds is the max-age of the Strict-Transport-Security header. Default is 0, which would NOT include the header.
func GetSecureSTSSeconds() int64 {
seconds, err := strconv.Atoi(env.Get(ConsoleSecureSTSSeconds, "0"))
if err != nil {
seconds = 0
}
return int64(seconds)
}
// If STSIncludeSubdomains is set to true, the `includeSubdomains` will be appended to the Strict-Transport-Security header. Default is false.
func GetSecureSTSIncludeSubdomains() bool {
return strings.ToLower(env.Get(ConsoleSecureSTSIncludeSubdomains, "off")) == "on"
}
// If STSPreload is set to true, the `preload` flag will be appended to the Strict-Transport-Security header. Default is false.
func GetSecureSTSPreload() bool {
return strings.ToLower(env.Get(ConsoleSecureSTSPreload, "off")) == "on"
}
// If TLSTemporaryRedirect is true, the a 302 will be used while redirecting. Default is false (301).
func GetSecureTLSTemporaryRedirect() bool {
return strings.ToLower(env.Get(ConsoleSecureTLSTemporaryRedirect, "off")) == "on"
}
// STS header is only included when the connection is HTTPS.
func GetSecureForceSTSHeader() bool {
return strings.ToLower(env.Get(ConsoleSecureForceSTSHeader, "off")) == "on"
}
// ReferrerPolicy allows the Referrer-Policy header with the value to be set with a custom value. Default is "".
func GetSecureReferrerPolicy() string {
return env.Get(ConsoleSecureReferrerPolicy, "")
}
// FeaturePolicy allows the Feature-Policy header with the value to be set with a custom value. Default is "".
func GetSecureFeaturePolicy() string {
return env.Get(ConsoleSecureFeaturePolicy, "")
}
func getLogSearchAPIToken() string {
if v := env.Get(ConsoleLogQueryAuthToken, ""); v != "" {
return v
}
return env.Get(LogSearchQueryAuthToken, "")
}
func getLogSearchURL() string {
return env.Get(ConsoleLogQueryURL, "")
}
func getPrometheusURL() string {
return env.Get(PrometheusURL, "")
}
func getPrometheusAuthToken() string {
return env.Get(PrometheusAuthToken, "")
}
func getPrometheusJobID() string {
return env.Get(PrometheusJobID, "minio-job")
}
func getPrometheusExtraLabels() string {
return env.Get(PrometheusExtraLabels, "")
}
func getMaxConcurrentUploadsLimit() int64 {
cu, err := strconv.ParseInt(env.Get(ConsoleMaxConcurrentUploads, "10"), 10, 64)
if err != nil {
return 10
}
return cu
}
func getMaxConcurrentDownloadsLimit() int64 {
cu, err := strconv.ParseInt(env.Get(ConsoleMaxConcurrentDownloads, "20"), 10, 64)
if err != nil {
return 20
}
return cu
}
func getConsoleDevMode() bool {
return strings.ToLower(env.Get(ConsoleDevMode, "off")) == "on"
}
func getConsoleAnimatedLogin() bool {
return strings.ToLower(env.Get(ConsoleAnimatedLogin, "on")) == "on"
}
func getConsoleBrowserRedirectURL() string {
return env.Get(ConsoleBrowserRedirectURL, "")
}

393
api/config_test.go Normal file
View File

@@ -0,0 +1,393 @@
// This file is part of MinIO Console Server
// Copyright (c) 2023 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package api
import (
"os"
"testing"
"github.com/stretchr/testify/assert"
)
func TestGetHostname(t *testing.T) {
os.Setenv(ConsoleHostname, "x")
defer os.Unsetenv(ConsoleHostname)
assert.Equalf(t, "x", GetHostname(), "GetHostname()")
}
func TestGetPort(t *testing.T) {
type args struct {
env string
}
tests := []struct {
name string
args args
want int
}{
{
name: "valid port",
args: args{
env: "9091",
},
want: 9091,
},
{
name: "invalid port",
args: args{
env: "duck",
},
want: 9090,
},
}
for _, tt := range tests {
t.Run(tt.name, func(_ *testing.T) {
os.Setenv(ConsolePort, tt.args.env)
assert.Equalf(t, tt.want, GetPort(), "GetPort()")
os.Unsetenv(ConsolePort)
})
}
}
func TestGetTLSPort(t *testing.T) {
type args struct {
env string
}
tests := []struct {
name string
args args
want int
}{
{
name: "valid port",
args: args{
env: "9444",
},
want: 9444,
},
{
name: "invalid port",
args: args{
env: "duck",
},
want: 9443,
},
}
for _, tt := range tests {
t.Run(tt.name, func(_ *testing.T) {
os.Setenv(ConsoleTLSPort, tt.args.env)
assert.Equalf(t, tt.want, GetTLSPort(), "GetTLSPort()")
os.Unsetenv(ConsoleTLSPort)
})
}
}
func TestGetSecureAllowedHosts(t *testing.T) {
type args struct {
env string
}
tests := []struct {
name string
args args
want []string
}{
{
name: "valid hosts",
args: args{
env: "host1,host2",
},
want: []string{"host1", "host2"},
},
{
name: "empty hosts",
args: args{
env: "",
},
want: []string{},
},
}
for _, tt := range tests {
t.Run(tt.name, func(_ *testing.T) {
os.Setenv(ConsoleSecureAllowedHosts, tt.args.env)
assert.Equalf(t, tt.want, GetSecureAllowedHosts(), "GetSecureAllowedHosts()")
os.Unsetenv(ConsoleSecureAllowedHosts)
})
}
}
func TestGetSecureHostsProxyHeaders(t *testing.T) {
type args struct {
env string
}
tests := []struct {
name string
args args
want []string
}{
{
name: "valid headers",
args: args{
env: "header1,header2",
},
want: []string{"header1", "header2"},
},
{
name: "empty headers",
args: args{
env: "",
},
want: []string{},
},
}
for _, tt := range tests {
t.Run(tt.name, func(_ *testing.T) {
os.Setenv(ConsoleSecureHostsProxyHeaders, tt.args.env)
assert.Equalf(t, tt.want, GetSecureHostsProxyHeaders(), "GetSecureHostsProxyHeaders()")
os.Unsetenv(ConsoleSecureHostsProxyHeaders)
})
}
}
func TestGetSecureSTSSeconds(t *testing.T) {
type args struct {
env string
}
tests := []struct {
name string
args args
want int64
}{
{
name: "valid",
args: args{
env: "1",
},
want: 1,
},
{
name: "invalid",
args: args{
env: "duck",
},
want: 0,
},
}
for _, tt := range tests {
t.Run(tt.name, func(_ *testing.T) {
os.Setenv(ConsoleSecureSTSSeconds, tt.args.env)
assert.Equalf(t, tt.want, GetSecureSTSSeconds(), "GetSecureSTSSeconds()")
os.Unsetenv(ConsoleSecureSTSSeconds)
})
}
}
func Test_getLogSearchAPIToken(t *testing.T) {
type args struct {
env string
}
tests := []struct {
name string
args args
want string
}{
{
name: "env set",
args: args{
env: "value",
},
want: "value",
},
{
name: "env not set",
args: args{
env: "",
},
want: "",
},
}
for _, tt := range tests {
t.Run(tt.name, func(_ *testing.T) {
os.Setenv(ConsoleLogQueryAuthToken, tt.args.env)
assert.Equalf(t, tt.want, getLogSearchAPIToken(), "getLogSearchAPIToken()")
os.Setenv(ConsoleLogQueryAuthToken, tt.args.env)
})
}
}
func Test_getPrometheusURL(t *testing.T) {
type args struct {
env string
}
tests := []struct {
name string
args args
want string
}{
{
name: "env set",
args: args{
env: "value",
},
want: "value",
},
{
name: "env not set",
args: args{
env: "",
},
want: "",
},
}
for _, tt := range tests {
t.Run(tt.name, func(_ *testing.T) {
os.Setenv(PrometheusURL, tt.args.env)
assert.Equalf(t, tt.want, getPrometheusURL(), "getPrometheusURL()")
os.Setenv(PrometheusURL, tt.args.env)
})
}
}
func Test_getPrometheusJobID(t *testing.T) {
type args struct {
env string
}
tests := []struct {
name string
args args
want string
}{
{
name: "env set",
args: args{
env: "value",
},
want: "value",
},
{
name: "env not set",
args: args{
env: "",
},
want: "minio-job",
},
}
for _, tt := range tests {
t.Run(tt.name, func(_ *testing.T) {
os.Setenv(PrometheusJobID, tt.args.env)
assert.Equalf(t, tt.want, getPrometheusJobID(), "getPrometheusJobID()")
os.Setenv(PrometheusJobID, tt.args.env)
})
}
}
func Test_getMaxConcurrentUploadsLimit(t *testing.T) {
type args struct {
env string
}
tests := []struct {
name string
args args
want int64
}{
{
name: "valid",
args: args{
env: "1",
},
want: 1,
},
{
name: "invalid",
args: args{
env: "duck",
},
want: 10,
},
}
for _, tt := range tests {
t.Run(tt.name, func(_ *testing.T) {
os.Setenv(ConsoleMaxConcurrentUploads, tt.args.env)
assert.Equalf(t, tt.want, getMaxConcurrentUploadsLimit(), "getMaxConcurrentUploadsLimit()")
os.Unsetenv(ConsoleMaxConcurrentUploads)
})
}
}
func Test_getMaxConcurrentDownloadsLimit(t *testing.T) {
type args struct {
env string
}
tests := []struct {
name string
args args
want int64
}{
{
name: "valid",
args: args{
env: "1",
},
want: 1,
},
{
name: "invalid",
args: args{
env: "duck",
},
want: 20,
},
}
for _, tt := range tests {
t.Run(tt.name, func(_ *testing.T) {
os.Setenv(ConsoleMaxConcurrentDownloads, tt.args.env)
assert.Equalf(t, tt.want, getMaxConcurrentDownloadsLimit(), "getMaxConcurrentDownloadsLimit()")
os.Unsetenv(ConsoleMaxConcurrentDownloads)
})
}
}
func Test_getConsoleDevMode(t *testing.T) {
type args struct {
env string
}
tests := []struct {
name string
args args
want bool
}{
{
name: "value set",
args: args{
env: "on",
},
want: true,
},
{
name: "value not set",
args: args{
env: "",
},
want: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(_ *testing.T) {
os.Setenv(ConsoleDevMode, tt.args.env)
assert.Equalf(t, tt.want, getConsoleDevMode(), "getConsoleDevMode()")
os.Unsetenv(ConsoleDevMode)
})
}
}

525
api/configure_console.go Normal file
View File

@@ -0,0 +1,525 @@
// This file is part of MinIO Console Server
// Copyright (c) 2021 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// This file is safe to edit. Once it exists it will not be overwritten
package api
import (
"bytes"
"context"
"crypto/tls"
"fmt"
"io"
"io/fs"
"log"
"net"
"net/http"
"path"
"path/filepath"
"regexp"
"strings"
"sync"
"time"
"github.com/google/uuid"
"github.com/minio/console/pkg/logger"
"github.com/minio/console/pkg/utils"
"github.com/minio/minio-go/v7/pkg/credentials"
"github.com/klauspost/compress/gzhttp"
portal_ui "github.com/minio/console/web-app"
"github.com/minio/pkg/v3/env"
"github.com/minio/pkg/v3/mimedb"
xnet "github.com/minio/pkg/v3/net"
"github.com/go-openapi/errors"
"github.com/go-openapi/swag"
"github.com/minio/console/api/operations"
"github.com/minio/console/models"
"github.com/minio/console/pkg/auth"
"github.com/unrolled/secure"
)
//go:generate swagger generate server --target ../../console --name Console --spec ../swagger.yml
var additionalServerFlags = struct {
CertsDir string `long:"certs-dir" description:"path to certs directory" env:"CONSOLE_CERTS_DIR"`
}{}
const (
SubPath = "CONSOLE_SUBPATH"
)
var (
cfgSubPath = "/"
subPathOnce sync.Once
)
func configureFlags(api *operations.ConsoleAPI) {
api.CommandLineOptionsGroups = []swag.CommandLineOptionsGroup{
{
ShortDescription: "additional server flags",
Options: &additionalServerFlags,
},
}
}
func configureAPI(api *operations.ConsoleAPI) http.Handler {
// Applies when the "x-token" header is set
api.KeyAuth = func(token string, _ []string) (*models.Principal, error) {
// we are validating the session token by decrypting the claims inside, if the operation succeed that means the jwt
// was generated and signed by us in the first place
if token == "Anonymous" {
return &models.Principal{}, nil
}
claims, err := auth.ParseClaimsFromToken(token)
if err != nil {
api.Logger("Unable to validate the session token %s: %v", token, err)
return nil, errors.New(401, "incorrect api key auth")
}
return &models.Principal{
STSAccessKeyID: claims.STSAccessKeyID,
STSSecretAccessKey: claims.STSSecretAccessKey,
STSSessionToken: claims.STSSessionToken,
AccountAccessKey: claims.AccountAccessKey,
Hm: claims.HideMenu,
Ob: claims.ObjectBrowser,
CustomStyleOb: claims.CustomStyleOB,
}, nil
}
api.AnonymousAuth = func(_ string) (*models.Principal, error) {
return &models.Principal{}, nil
}
// Register login handlers
registerLoginHandlers(api)
// Register logout handlers
registerLogoutHandlers(api)
// Register bucket handlers
registerBucketsHandlers(api)
// Register all users handlers
registerUsersHandlers(api)
// Register groups handlers
registerGroupsHandlers(api)
// Register policies handlers
registersPoliciesHandler(api)
// Register configurations handlers
registerConfigHandlers(api)
// Register bucket events handlers
registerBucketEventsHandlers(api)
// Register bucket lifecycle handlers
registerBucketsLifecycleHandlers(api)
// Register service handlers
registerServiceHandlers(api)
// Register session handlers
registerSessionHandlers(api)
// Register admin info handlers
registerAdminInfoHandlers(api)
// Register admin arns handlers
registerAdminArnsHandlers(api)
// Register admin notification endpoints handlers
registerAdminNotificationEndpointsHandlers(api)
// Register admin Service Account Handlers
registerServiceAccountsHandlers(api)
// Register admin remote buckets
registerAdminBucketRemoteHandlers(api)
// Register admin log search
registerLogSearchHandlers(api)
// Register admin subnet handlers
registerSubnetHandlers(api)
// Register admin KMS handlers
registerKMSHandlers(api)
// Register admin IDP handlers
registerIDPHandlers(api)
// Register Account handlers
registerAdminTiersHandlers(api)
// Register Inspect Handler
registerInspectHandler(api)
// Register nodes handlers
registerNodesHandler(api)
registerSiteReplicationHandler(api)
registerSiteReplicationStatusHandler(api)
// Register Support Handler
registerSupportHandlers(api)
// Operator Console
// Register Object's Handlers
registerObjectsHandlers(api)
// Register Bucket Quota's Handlers
registerBucketQuotaHandlers(api)
// Register Account handlers
registerAccountHandlers(api)
registerReleasesHandlers(api)
registerPublicObjectsHandlers(api)
api.PreServerShutdown = func() {}
api.ServerShutdown = func() {}
// do an initial subnet plan caching
fetchLicensePlan()
return setupGlobalMiddleware(api.Serve(setupMiddlewares))
}
// The TLS configuration before HTTPS server starts.
func configureTLS(tlsConfig *tls.Config) {
tlsConfig.RootCAs = GlobalRootCAs
tlsConfig.GetCertificate = GlobalTLSCertsManager.GetCertificate
}
// The middleware configuration is for the handler executors. These do not apply to the swagger.json document.
// The middleware executes after routing but before authentication, binding and validation
func setupMiddlewares(handler http.Handler) http.Handler {
return handler
}
func ContextMiddleware(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
requestID := uuid.NewString()
ctx := context.WithValue(r.Context(), utils.ContextRequestID, requestID)
ctx = context.WithValue(ctx, utils.ContextRequestUserAgent, r.UserAgent())
ctx = context.WithValue(ctx, utils.ContextRequestHost, r.Host)
ctx = context.WithValue(ctx, utils.ContextRequestRemoteAddr, r.RemoteAddr)
ctx = context.WithValue(ctx, utils.ContextClientIP, getClientIP(r))
next.ServeHTTP(w, r.WithContext(ctx))
})
}
func AuditLogMiddleware(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
rw := logger.NewResponseWriter(w)
next.ServeHTTP(rw, r)
if strings.HasPrefix(r.URL.Path, "/ws") || strings.HasPrefix(r.URL.Path, "/api") {
logger.AuditLog(r.Context(), rw, r, map[string]interface{}{}, "Authorization", "Cookie", "Set-Cookie")
}
})
}
// The middleware configuration happens before anything, this middleware also applies to serving the swagger.json document.
// So this is a good place to plug in a panic handling middleware, logger and metrics
func setupGlobalMiddleware(handler http.Handler) http.Handler {
gnext := gzhttp.GzipHandler(handler)
// if audit-log is enabled console will log all incoming request
next := AuditLogMiddleware(gnext)
// serve static files
next = FileServerMiddleware(next)
// add information to request context
next = ContextMiddleware(next)
// handle cookie or authorization header for session
next = AuthenticationMiddleware(next)
sslHostFn := secure.SSLHostFunc(func(host string) string {
xhost, err := xnet.ParseHost(host)
if err != nil {
return host
}
return net.JoinHostPort(xhost.Name, TLSPort)
})
// Secure middleware, this middleware wrap all the previous handlers and add
// HTTP security headers
secureOptions := secure.Options{
AllowedHosts: GetSecureAllowedHosts(),
AllowedHostsAreRegex: GetSecureAllowedHostsAreRegex(),
HostsProxyHeaders: GetSecureHostsProxyHeaders(),
SSLRedirect: GetTLSRedirect() == "on" && len(GlobalPublicCerts) > 0,
SSLHostFunc: &sslHostFn,
SSLHost: GetSecureTLSHost(),
STSSeconds: GetSecureSTSSeconds(),
STSIncludeSubdomains: GetSecureSTSIncludeSubdomains(),
STSPreload: GetSecureSTSPreload(),
SSLTemporaryRedirect: false,
ForceSTSHeader: GetSecureForceSTSHeader(),
FrameDeny: GetSecureFrameDeny(),
ContentTypeNosniff: GetSecureContentTypeNonSniff(),
BrowserXssFilter: GetSecureBrowserXSSFilter(),
ContentSecurityPolicy: GetSecureContentSecurityPolicy(),
ContentSecurityPolicyReportOnly: GetSecureContentSecurityPolicyReportOnly(),
ReferrerPolicy: GetSecureReferrerPolicy(),
FeaturePolicy: GetSecureFeaturePolicy(),
IsDevelopment: false,
}
secureMiddleware := secure.New(secureOptions)
next = secureMiddleware.Handler(next)
return RejectS3Middleware(next)
}
const apiRequestErr = `<?xml version="1.0" encoding="UTF-8"?><Error><Code>InvalidArgument</Code><Message>S3 API Requests must be made to API port.</Message><RequestId>0</RequestId></Error>`
// RejectS3Middleware will reject requests that have AWS S3 specific headers.
func RejectS3Middleware(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if len(r.Header.Get("X-Amz-Content-Sha256")) > 0 ||
len(r.Header.Get("X-Amz-Date")) > 0 ||
strings.HasPrefix(r.Header.Get("Authorization"), "AWS4-HMAC-SHA256") ||
r.URL.Query().Get("AWSAccessKeyId") != "" {
w.Header().Set("Location", getMinIOServer())
w.WriteHeader(http.StatusBadRequest)
w.Write([]byte(apiRequestErr))
return
}
next.ServeHTTP(w, r)
})
}
func AuthenticationMiddleware(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
token, err := auth.GetTokenFromRequest(r)
if err != nil && err != auth.ErrNoAuthToken {
http.Error(w, err.Error(), http.StatusUnauthorized)
return
}
sessionToken, _ := auth.DecryptToken(token)
// All handlers handle appropriately to return errors
// based on their swagger rules, we do not need to
// additionally return error here, let the next ServeHTTPs
// handle it appropriately.
if len(sessionToken) > 0 {
r.Header.Add("Authorization", fmt.Sprintf("Bearer %s", string(sessionToken)))
} else {
r.Header.Add("Authorization", fmt.Sprintf("Bearer %s", "Anonymous"))
}
ctx := r.Context()
claims, _ := auth.ParseClaimsFromToken(string(sessionToken))
if claims != nil {
// save user session id context
ctx = context.WithValue(r.Context(), utils.ContextRequestUserID, claims.STSSessionToken)
}
next.ServeHTTP(w, r.WithContext(ctx))
})
}
// FileServerMiddleware serves files from the static folder
func FileServerMiddleware(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Server", globalAppName) // do not add version information
switch {
case strings.HasPrefix(r.URL.Path, "/ws"):
serveWS(w, r)
case strings.HasPrefix(r.URL.Path, "/api"):
next.ServeHTTP(w, r)
default:
buildFs, err := fs.Sub(portal_ui.GetStaticAssets(), "build")
if err != nil {
panic(err)
}
wrapHandlerSinglePageApplication(requestBounce(http.FileServer(http.FS(buildFs)))).ServeHTTP(w, r)
}
})
}
type notFoundRedirectRespWr struct {
http.ResponseWriter // We embed http.ResponseWriter
status int
}
func (w *notFoundRedirectRespWr) WriteHeader(status int) {
w.status = status // Store the status for our own use
if status != http.StatusNotFound {
w.ResponseWriter.WriteHeader(status)
}
}
func (w *notFoundRedirectRespWr) Write(p []byte) (int, error) {
if w.status != http.StatusNotFound {
return w.ResponseWriter.Write(p)
}
return len(p), nil // Lie that we successfully wrote it
}
// handleSPA handles the serving of the React Single Page Application
func handleSPA(w http.ResponseWriter, r *http.Request) {
basePath := "/"
// For SPA mode we will replace root base with a sub path if configured unless we received cp=y and cpb=/NEW/BASE
if v := r.URL.Query().Get("cp"); v == "y" {
if base := r.URL.Query().Get("cpb"); base != "" {
// make sure the subpath has a trailing slash
if !strings.HasSuffix(base, "/") {
base = fmt.Sprintf("%s/", base)
}
basePath = base
}
}
indexPage, err := portal_ui.GetStaticAssets().Open("build/index.html")
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
sts := r.URL.Query().Get("sts")
stsAccessKey := r.URL.Query().Get("sts_a")
stsSecretKey := r.URL.Query().Get("sts_s")
overridenStyles := r.URL.Query().Get("ov_st")
// if these three parameters are present we are being asked to issue a session with these values
if sts != "" && stsAccessKey != "" && stsSecretKey != "" {
creds := credentials.NewStaticV4(stsAccessKey, stsSecretKey, sts)
consoleCreds := &ConsoleCredentials{
ConsoleCredentials: creds,
AccountAccessKey: stsAccessKey,
}
sf := &auth.SessionFeatures{}
sf.HideMenu = true
sf.ObjectBrowser = true
if overridenStyles != "" {
err := ValidateEncodedStyles(overridenStyles)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
sf.CustomStyleOB = overridenStyles
}
sessionID, err := login(consoleCreds, sf)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
cookie := NewSessionCookieForConsole(*sessionID)
http.SetCookie(w, &cookie)
// Allow us to be iframed
w.Header().Del("X-Frame-Options")
}
indexPageBytes, err := io.ReadAll(indexPage)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
// if we have a seeded basePath. This should override CONSOLE_SUBPATH every time, thus the `if else`
if basePath != "/" {
indexPageBytes = replaceBaseInIndex(indexPageBytes, basePath)
// if we have a custom subpath replace it in
} else if getSubPath() != "/" {
indexPageBytes = replaceBaseInIndex(indexPageBytes, getSubPath())
}
indexPageBytes = replaceLicense(indexPageBytes)
mimeType := mimedb.TypeByExtension(filepath.Ext(r.URL.Path))
if mimeType == "application/octet-stream" {
mimeType = "text/html"
}
w.Header().Set("Content-Type", mimeType)
http.ServeContent(w, r, "index.html", time.Now(), bytes.NewReader(indexPageBytes))
}
// wrapHandlerSinglePageApplication handles a http.FileServer returning a 404 and overrides it with index.html
func wrapHandlerSinglePageApplication(h http.Handler) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
if r.URL.Path == "/" {
handleSPA(w, r)
return
}
w.Header().Set("Content-Type", mimedb.TypeByExtension(filepath.Ext(r.URL.Path)))
nfw := &notFoundRedirectRespWr{ResponseWriter: w}
h.ServeHTTP(nfw, r)
if nfw.status == http.StatusNotFound {
handleSPA(w, r)
}
}
}
type nullWriter struct{}
func (lw nullWriter) Write(b []byte) (int, error) {
return len(b), nil
}
// As soon as server is initialized but not run yet, this function will be called.
// If you need to modify a config, store server instance to stop it individually later, this is the place.
// This function can be called multiple times, depending on the number of serving schemes.
// scheme value will be set accordingly: "http", "https" or "unix"
func configureServer(s *http.Server, _, _ string) {
// Turn-off random logger by Go net/http
s.ErrorLog = log.New(&nullWriter{}, "", 0)
}
func getSubPath() string {
subPathOnce.Do(func() {
cfgSubPath = parseSubPath(env.Get(SubPath, ""))
})
return cfgSubPath
}
func parseSubPath(v string) string {
v = strings.TrimSpace(v)
if v == "" {
return SlashSeparator
}
// Replace all unnecessary `\` to `/`
// also add pro-actively at the end.
subPath := path.Clean(filepath.ToSlash(v))
if !strings.HasPrefix(subPath, SlashSeparator) {
subPath = SlashSeparator + subPath
}
if !strings.HasSuffix(subPath, SlashSeparator) {
subPath += SlashSeparator
}
return subPath
}
func replaceBaseInIndex(indexPageBytes []byte, basePath string) []byte {
if basePath != "" {
validBasePath := regexp.MustCompile(`^[0-9a-zA-Z\/-]+$`)
if !validBasePath.MatchString(basePath) {
return indexPageBytes
}
indexPageStr := string(indexPageBytes)
newBase := fmt.Sprintf("<base href=\"%s\"/>", basePath)
indexPageStr = strings.Replace(indexPageStr, "<base href=\"/\"/>", newBase, 1)
indexPageBytes = []byte(indexPageStr)
}
return indexPageBytes
}
func replaceLicense(indexPageBytes []byte) []byte {
indexPageStr := string(indexPageBytes)
newPlan := fmt.Sprintf("<meta name=\"minio-license\" content=\"%s\" />", InstanceLicensePlan.String())
indexPageStr = strings.Replace(indexPageStr, "<meta name=\"minio-license\" content=\"agpl\"/>", newPlan, 1)
indexPageBytes = []byte(indexPageStr)
return indexPageBytes
}
func requestBounce(handler http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if strings.HasSuffix(r.URL.Path, "/") {
http.NotFound(w, r)
return
}
handler.ServeHTTP(w, r)
})
}

View File

@@ -0,0 +1,125 @@
// This file is part of MinIO Console Server
// Copyright (c) 2022 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package api
import (
"os"
"sync"
"testing"
"github.com/stretchr/testify/assert"
)
func Test_parseSubPath(t *testing.T) {
type args struct {
v string
}
tests := []struct {
name string
args args
want string
}{
{
name: "Empty",
args: args{
v: "",
},
want: "/",
},
{
name: "Slash",
args: args{
v: "/",
},
want: "/",
},
{
name: "Double Slash",
args: args{
v: "//",
},
want: "/",
},
{
name: "No slashes",
args: args{
v: "route",
},
want: "/route/",
},
{
name: "No trailing slashes",
args: args{
v: "/route",
},
want: "/route/",
},
}
for _, tt := range tests {
t.Run(tt.name, func(_ *testing.T) {
assert.Equalf(t, tt.want, parseSubPath(tt.args.v), "parseSubPath(%v)", tt.args.v)
})
}
}
func Test_getSubPath(t *testing.T) {
type args struct {
envValue string
}
tests := []struct {
name string
args args
want string
}{
{
name: "Empty",
args: args{
envValue: "",
},
want: "/",
},
{
name: "Slash",
args: args{
envValue: "/",
},
want: "/",
},
{
name: "Valid Value",
args: args{
envValue: "/subpath/",
},
want: "/subpath/",
},
{
name: "No starting slash",
args: args{
envValue: "subpath/",
},
want: "/subpath/",
},
}
for _, tt := range tests {
t.Run(tt.name, func(_ *testing.T) {
t.Setenv(SubPath, tt.args.envValue)
defer os.Unsetenv(SubPath)
subPathOnce = sync.Once{}
assert.Equalf(t, tt.want, getSubPath(), "getSubPath()")
})
}
}

63
api/consts.go Normal file
View File

@@ -0,0 +1,63 @@
// This file is part of MinIO Console Server
// Copyright (c) 2021 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package api
// list of all console environment constants
const (
// Constants for common configuration
ConsoleMinIOServer = "CONSOLE_MINIO_SERVER"
ConsoleSubnetProxy = "CONSOLE_SUBNET_PROXY"
ConsoleMinIORegion = "CONSOLE_MINIO_REGION"
ConsoleHostname = "CONSOLE_HOSTNAME"
ConsolePort = "CONSOLE_PORT"
ConsoleTLSPort = "CONSOLE_TLS_PORT"
// Constants for Secure middleware
ConsoleSecureAllowedHosts = "CONSOLE_SECURE_ALLOWED_HOSTS"
ConsoleSecureAllowedHostsAreRegex = "CONSOLE_SECURE_ALLOWED_HOSTS_ARE_REGEX"
ConsoleSecureFrameDeny = "CONSOLE_SECURE_FRAME_DENY"
ConsoleSecureContentTypeNoSniff = "CONSOLE_SECURE_CONTENT_TYPE_NO_SNIFF"
ConsoleSecureBrowserXSSFilter = "CONSOLE_SECURE_BROWSER_XSS_FILTER"
ConsoleSecureContentSecurityPolicy = "CONSOLE_SECURE_CONTENT_SECURITY_POLICY"
ConsoleSecureContentSecurityPolicyReportOnly = "CONSOLE_SECURE_CONTENT_SECURITY_POLICY_REPORT_ONLY"
ConsoleSecureHostsProxyHeaders = "CONSOLE_SECURE_HOSTS_PROXY_HEADERS"
ConsoleSecureSTSSeconds = "CONSOLE_SECURE_STS_SECONDS"
ConsoleSecureSTSIncludeSubdomains = "CONSOLE_SECURE_STS_INCLUDE_SUB_DOMAINS"
ConsoleSecureSTSPreload = "CONSOLE_SECURE_STS_PRELOAD"
ConsoleSecureTLSRedirect = "CONSOLE_SECURE_TLS_REDIRECT"
ConsoleSecureTLSHost = "CONSOLE_SECURE_TLS_HOST"
ConsoleSecureTLSTemporaryRedirect = "CONSOLE_SECURE_TLS_TEMPORARY_REDIRECT"
ConsoleSecureForceSTSHeader = "CONSOLE_SECURE_FORCE_STS_HEADER"
ConsoleSecurePublicKey = "CONSOLE_SECURE_PUBLIC_KEY"
ConsoleSecureReferrerPolicy = "CONSOLE_SECURE_REFERRER_POLICY"
ConsoleSecureFeaturePolicy = "CONSOLE_SECURE_FEATURE_POLICY"
ConsoleSecureExpectCTHeader = "CONSOLE_SECURE_EXPECT_CT_HEADER"
PrometheusURL = "CONSOLE_PROMETHEUS_URL"
PrometheusAuthToken = "CONSOLE_PROMETHEUS_AUTH_TOKEN"
PrometheusJobID = "CONSOLE_PROMETHEUS_JOB_ID"
PrometheusExtraLabels = "CONSOLE_PROMETHEUS_EXTRA_LABELS"
ConsoleLogQueryURL = "CONSOLE_LOG_QUERY_URL"
ConsoleLogQueryAuthToken = "CONSOLE_LOG_QUERY_AUTH_TOKEN"
ConsoleMaxConcurrentUploads = "CONSOLE_MAX_CONCURRENT_UPLOADS"
ConsoleMaxConcurrentDownloads = "CONSOLE_MAX_CONCURRENT_DOWNLOADS"
ConsoleDevMode = "CONSOLE_DEV_MODE"
ConsoleAnimatedLogin = "CONSOLE_ANIMATED_LOGIN"
ConsoleBrowserRedirectURL = "CONSOLE_BROWSER_REDIRECT_URL"
LogSearchQueryAuthToken = "LOGSEARCH_QUERY_AUTH_TOKEN"
SlashSeparator = "/"
LocalAddress = "127.0.0.1"
)

556
api/custom-server.go Normal file
View File

@@ -0,0 +1,556 @@
// This file is part of MinIO Console Server
// Copyright (c) 2023 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
package api
import (
"context"
"crypto/tls"
"crypto/x509"
"errors"
"fmt"
"log"
"net"
"net/http"
"os"
"os/signal"
"strconv"
"sync"
"sync/atomic"
"syscall"
"time"
"github.com/go-openapi/runtime/flagext"
"github.com/go-openapi/swag"
flags "github.com/jessevdk/go-flags"
"golang.org/x/net/netutil"
"github.com/minio/console/api/operations"
)
const (
schemeHTTP = "http"
schemeHTTPS = "https"
schemeUnix = "unix"
)
var defaultSchemes []string
func init() {
defaultSchemes = []string{
schemeHTTP,
}
}
// NewServer creates a new api console server but does not configure it
func NewServer(api *operations.ConsoleAPI) *Server {
s := new(Server)
s.shutdown = make(chan struct{})
s.api = api
s.interrupt = make(chan os.Signal, 1)
return s
}
// ConfigureAPI configures the API and handlers.
func (s *Server) ConfigureAPI() {
if s.api != nil {
s.handler = configureAPI(s.api)
}
}
// ConfigureFlags configures the additional flags defined by the handlers. Needs to be called before the parser.Parse
func (s *Server) ConfigureFlags() {
if s.api != nil {
configureFlags(s.api)
}
}
// Server for the console API
type Server struct {
EnabledListeners []string `long:"scheme" description:"the listeners to enable, this can be repeated and defaults to the schemes in the swagger spec"`
CleanupTimeout time.Duration `long:"cleanup-timeout" description:"grace period for which to wait before killing idle connections" default:"10s"`
GracefulTimeout time.Duration `long:"graceful-timeout" description:"grace period for which to wait before shutting down the server" default:"15s"`
MaxHeaderSize flagext.ByteSize `long:"max-header-size" description:"controls the maximum number of bytes the server will read parsing the request header's keys and values, including the request line. It does not limit the size of the request body." default:"1MiB"`
SocketPath flags.Filename `long:"socket-path" description:"the unix socket to listen on" default:"/var/run/console.sock"`
domainSocketL net.Listener
Host string `long:"host" description:"the IP to listen on" default:"localhost" env:"HOST"`
Port int `long:"port" description:"the port to listen on for insecure connections, defaults to a random value" env:"PORT"`
ListenLimit int `long:"listen-limit" description:"limit the number of outstanding requests"`
KeepAlive time.Duration `long:"keep-alive" description:"sets the TCP keep-alive timeouts on accepted connections. It prunes dead TCP connections ( e.g. closing laptop mid-download)" default:"3m"`
ReadTimeout time.Duration `long:"read-timeout" description:"maximum duration before timing out read of the request" default:"30s"`
WriteTimeout time.Duration `long:"write-timeout" description:"maximum duration before timing out write of the response" default:"60s"`
httpServerL []net.Listener
TLSHost string `long:"tls-host" description:"the IP to listen on for tls, when not specified it's the same as --host" env:"TLS_HOST"`
TLSPort int `long:"tls-port" description:"the port to listen on for secure connections, defaults to a random value" env:"TLS_PORT"`
TLSCertificate flags.Filename `long:"tls-certificate" description:"the certificate to use for secure connections" env:"TLS_CERTIFICATE"`
TLSCertificateKey flags.Filename `long:"tls-key" description:"the private key to use for secure connections" env:"TLS_PRIVATE_KEY"`
TLSCACertificate flags.Filename `long:"tls-ca" description:"the certificate authority file to be used with mutual tls auth" env:"TLS_CA_CERTIFICATE"`
TLSListenLimit int `long:"tls-listen-limit" description:"limit the number of outstanding requests"`
TLSKeepAlive time.Duration `long:"tls-keep-alive" description:"sets the TCP keep-alive timeouts on accepted connections. It prunes dead TCP connections ( e.g. closing laptop mid-download)"`
TLSReadTimeout time.Duration `long:"tls-read-timeout" description:"maximum duration before timing out read of the request"`
TLSWriteTimeout time.Duration `long:"tls-write-timeout" description:"maximum duration before timing out write of the response"`
httpsServerL []net.Listener
api *operations.ConsoleAPI
handler http.Handler
hasListeners bool
shutdown chan struct{}
shuttingDown int32
interrupted bool
interrupt chan os.Signal
}
// Logf logs message either via defined user logger or via system one if no user logger is defined.
func (s *Server) Logf(f string, args ...interface{}) {
if s.api != nil && s.api.Logger != nil {
s.api.Logger(f, args...)
} else {
log.Printf(f, args...)
}
}
// Fatalf logs message either via defined user logger or via system one if no user logger is defined.
// Exits with non-zero status after printing
func (s *Server) Fatalf(f string, args ...interface{}) {
if s.api != nil && s.api.Logger != nil {
s.api.Logger(f, args...)
os.Exit(1)
}
log.Fatalf(f, args...)
}
// SetAPI configures the server with the specified API. Needs to be called before Serve
func (s *Server) SetAPI(api *operations.ConsoleAPI) {
if api == nil {
s.api = nil
s.handler = nil
return
}
s.api = api
s.handler = configureAPI(api)
}
func (s *Server) hasScheme(scheme string) bool {
schemes := s.EnabledListeners
if len(schemes) == 0 {
schemes = defaultSchemes
}
for _, v := range schemes {
if v == scheme {
return true
}
}
return false
}
// Serve the api
func (s *Server) Serve() (err error) {
if !s.hasListeners {
if err = s.Listen(); err != nil {
return err
}
}
// set default handler, if none is set
if s.handler == nil {
if s.api == nil {
return errors.New("can't create the default handler, as no api is set")
}
s.SetHandler(s.api.Serve(nil))
}
wg := new(sync.WaitGroup)
once := new(sync.Once)
signalNotify(s.interrupt)
go handleInterrupt(once, s)
servers := []*http.Server{}
if s.hasScheme(schemeUnix) {
domainSocket := new(http.Server)
domainSocket.MaxHeaderBytes = int(s.MaxHeaderSize)
domainSocket.Handler = s.handler
if int64(s.CleanupTimeout) > 0 {
domainSocket.IdleTimeout = s.CleanupTimeout
}
configureServer(domainSocket, "unix", string(s.SocketPath))
servers = append(servers, domainSocket)
wg.Add(1)
s.Logf("Serving console at unix://%s", s.SocketPath)
go func(l net.Listener) {
defer wg.Done()
if err := domainSocket.Serve(l); err != nil && err != http.ErrServerClosed {
s.Fatalf("%v", err)
}
s.Logf("Stopped serving console at unix://%s", s.SocketPath)
}(s.domainSocketL)
}
if s.hasScheme(schemeHTTP) {
httpServer := new(http.Server)
httpServer.MaxHeaderBytes = int(s.MaxHeaderSize)
httpServer.ReadTimeout = s.ReadTimeout
httpServer.WriteTimeout = s.WriteTimeout
httpServer.SetKeepAlivesEnabled(int64(s.KeepAlive) > 0)
if s.ListenLimit > 0 {
for i := range s.httpServerL {
s.httpServerL[i] = netutil.LimitListener(s.httpServerL[i], s.ListenLimit)
}
}
if int64(s.CleanupTimeout) > 0 {
httpServer.IdleTimeout = s.CleanupTimeout
}
httpServer.Handler = s.handler
configureServer(httpServer, "http", s.httpServerL[0].Addr().String())
servers = append(servers, httpServer)
s.Logf("Serving console at http://%s", s.httpServerL[0].Addr())
for i := range s.httpServerL {
wg.Add(1)
go func(l net.Listener) {
defer wg.Done()
if err := httpServer.Serve(l); err != nil && err != http.ErrServerClosed {
s.Fatalf("%v", err)
}
s.Logf("Stopped serving console at http://%s", l.Addr())
}(s.httpServerL[i])
}
}
if s.hasScheme(schemeHTTPS) {
httpsServer := new(http.Server)
httpsServer.MaxHeaderBytes = int(s.MaxHeaderSize)
httpsServer.ReadTimeout = s.TLSReadTimeout
httpsServer.WriteTimeout = s.TLSWriteTimeout
httpsServer.SetKeepAlivesEnabled(int64(s.TLSKeepAlive) > 0)
if s.TLSListenLimit > 0 {
for i := range s.httpsServerL {
s.httpsServerL[i] = netutil.LimitListener(s.httpsServerL[i], s.TLSListenLimit)
}
}
if int64(s.CleanupTimeout) > 0 {
httpsServer.IdleTimeout = s.CleanupTimeout
}
httpsServer.Handler = s.handler
// Inspired by https://blog.bracebin.com/achieving-perfect-ssl-labs-score-with-go
httpsServer.TLSConfig = &tls.Config{
// Causes servers to use Go's default ciphersuite preferences,
// which are tuned to avoid attacks. Does nothing on clients.
PreferServerCipherSuites: true,
// Only use curves which have assembly implementations
// https://github.com/golang/go/tree/master/src/crypto/elliptic
CurvePreferences: []tls.CurveID{tls.CurveP256},
// Use modern tls mode https://wiki.mozilla.org/Security/Server_Side_TLS#Modern_compatibility
NextProtos: []string{"h2", "http/1.1"},
// https://www.owasp.org/index.php/Transport_Layer_Protection_Cheat_Sheet#Rule_-_Only_Support_Strong_Protocols
MinVersion: tls.VersionTLS12,
// These ciphersuites support Forward Secrecy: https://en.wikipedia.org/wiki/Forward_secrecy
CipherSuites: []uint16{
tls.TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,
tls.TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,
tls.TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,
tls.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,
tls.TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305,
tls.TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305,
},
}
// build standard config from server options
if s.TLSCertificate != "" && s.TLSCertificateKey != "" {
httpsServer.TLSConfig.Certificates = make([]tls.Certificate, 1)
httpsServer.TLSConfig.Certificates[0], err = tls.LoadX509KeyPair(string(s.TLSCertificate), string(s.TLSCertificateKey))
if err != nil {
return err
}
}
if s.TLSCACertificate != "" {
// include specified CA certificate
caCert, caCertErr := os.ReadFile(string(s.TLSCACertificate))
if caCertErr != nil {
return caCertErr
}
caCertPool := x509.NewCertPool()
ok := caCertPool.AppendCertsFromPEM(caCert)
if !ok {
return fmt.Errorf("cannot parse CA certificate")
}
httpsServer.TLSConfig.ClientCAs = caCertPool
httpsServer.TLSConfig.ClientAuth = tls.RequireAndVerifyClientCert
}
// call custom TLS configurator
configureTLS(httpsServer.TLSConfig)
if len(httpsServer.TLSConfig.Certificates) == 0 && httpsServer.TLSConfig.GetCertificate == nil {
// after standard and custom config are passed, this ends up with no certificate
if s.TLSCertificate == "" {
if s.TLSCertificateKey == "" {
s.Fatalf("the required flags `--tls-certificate` and `--tls-key` were not specified")
}
s.Fatalf("the required flag `--tls-certificate` was not specified")
}
if s.TLSCertificateKey == "" {
s.Fatalf("the required flag `--tls-key` was not specified")
}
// this happens with a wrong custom TLS configurator
s.Fatalf("no certificate was configured for TLS")
}
configureServer(httpsServer, "https", s.httpsServerL[0].Addr().String())
servers = append(servers, httpsServer)
s.Logf("Serving console at https://%s", s.httpsServerL[0].Addr())
for i := range s.httpsServerL {
wg.Add(1)
go func(l net.Listener) {
defer wg.Done()
if err := httpsServer.Serve(l); err != nil && err != http.ErrServerClosed {
s.Fatalf("%v", err)
}
s.Logf("Stopped serving console at https://%s", l.Addr())
}(tls.NewListener(s.httpsServerL[i], httpsServer.TLSConfig))
}
}
wg.Add(1)
go s.handleShutdown(wg, &servers)
wg.Wait()
return nil
}
// Listen creates the listeners for the server
func (s *Server) Listen() error {
if s.hasListeners { // already done this
return nil
}
if s.hasScheme(schemeHTTPS) {
// Use http host if https host wasn't defined
if s.TLSHost == "" {
s.TLSHost = s.Host
}
// Use http listen limit if https listen limit wasn't defined
if s.TLSListenLimit == 0 {
s.TLSListenLimit = s.ListenLimit
}
// Use http tcp keep alive if https tcp keep alive wasn't defined
if int64(s.TLSKeepAlive) == 0 {
s.TLSKeepAlive = s.KeepAlive
}
// Use http read timeout if https read timeout wasn't defined
if int64(s.TLSReadTimeout) == 0 {
s.TLSReadTimeout = s.ReadTimeout
}
// Use http write timeout if https write timeout wasn't defined
if int64(s.TLSWriteTimeout) == 0 {
s.TLSWriteTimeout = s.WriteTimeout
}
}
if s.hasScheme(schemeUnix) {
domSockListener, err := net.Listen("unix", string(s.SocketPath))
if err != nil {
return err
}
s.domainSocketL = domSockListener
}
lookup := func(addr string) []net.IP {
ips, err := net.LookupIP(addr)
if err == nil {
return ips
}
return []net.IP{net.ParseIP(addr)}
}
convert := func(ip net.IP) (string, string) {
if ip == nil {
return "", "tcp"
}
proto := "tcp4"
if ip.To4() == nil {
proto = "tcp6"
}
return ip.String(), proto
}
if s.hasScheme(schemeHTTP) {
for _, ip := range lookup(s.Host) {
host, proto := convert(ip)
listener, err := net.Listen(proto, net.JoinHostPort(host, strconv.Itoa(s.Port)))
if err != nil {
return err
}
if s.Host == "" || s.Port == 0 {
h, p, err := swag.SplitHostPort(listener.Addr().String())
if err != nil {
return err
}
s.Host = h
s.Port = p
}
s.httpServerL = append(s.httpServerL, listener)
}
}
if s.hasScheme(schemeHTTPS) {
for _, ip := range lookup(s.TLSHost) {
host, proto := convert(ip)
tlsListener, err := net.Listen(proto, net.JoinHostPort(host, strconv.Itoa(s.TLSPort)))
if err != nil {
return err
}
if s.TLSHost == "" || s.TLSPort == 0 {
sh, sp, err := swag.SplitHostPort(tlsListener.Addr().String())
if err != nil {
return err
}
s.TLSHost = sh
s.TLSPort = sp
}
s.httpsServerL = append(s.httpsServerL, tlsListener)
}
}
s.hasListeners = true
return nil
}
// Shutdown server and clean up resources
func (s *Server) Shutdown() error {
if atomic.CompareAndSwapInt32(&s.shuttingDown, 0, 1) {
close(s.shutdown)
}
return nil
}
func (s *Server) handleShutdown(wg *sync.WaitGroup, serversPtr *[]*http.Server) {
// wg.Done must occur last, after s.api.ServerShutdown()
// (to preserve old behavior)
defer wg.Done()
<-s.shutdown
servers := *serversPtr
ctx, cancel := context.WithTimeout(context.TODO(), s.GracefulTimeout)
defer cancel()
// first execute the pre-shutdown hook
s.api.PreServerShutdown()
shutdownChan := make(chan bool)
for i := range servers {
server := servers[i]
go func() {
var success bool
defer func() {
shutdownChan <- success
}()
if err := server.Shutdown(ctx); err != nil {
// Error from closing listeners, or context timeout:
s.Logf("HTTP server Shutdown: %v", err)
} else {
success = true
}
}()
}
// Wait until all listeners have successfully shut down before calling ServerShutdown
success := true
for range servers {
success = success && <-shutdownChan
}
if success {
s.api.ServerShutdown()
}
}
// GetHandler returns a handler useful for testing
func (s *Server) GetHandler() http.Handler {
return s.handler
}
// SetHandler allows for setting a http handler on this server
func (s *Server) SetHandler(handler http.Handler) {
s.handler = handler
}
// UnixListener returns the domain socket listener
func (s *Server) UnixListener() (net.Listener, error) {
if !s.hasListeners {
if err := s.Listen(); err != nil {
return nil, err
}
}
return s.domainSocketL, nil
}
// HTTPListener returns the http listener
func (s *Server) HTTPListener() ([]net.Listener, error) {
if !s.hasListeners {
if err := s.Listen(); err != nil {
return nil, err
}
}
return s.httpServerL, nil
}
// TLSListener returns the https listener
func (s *Server) TLSListener() ([]net.Listener, error) {
if !s.hasListeners {
if err := s.Listen(); err != nil {
return nil, err
}
}
return s.httpsServerL, nil
}
func handleInterrupt(once *sync.Once, s *Server) {
once.Do(func() {
for range s.interrupt {
if s.interrupted {
s.Logf("Server already shutting down")
continue
}
s.interrupted = true
s.Logf("Shutting down... ")
if err := s.Shutdown(); err != nil {
s.Logf("HTTP server Shutdown: %v", err)
}
}
})
}
func signalNotify(interrupt chan<- os.Signal) {
signal.Notify(interrupt, syscall.SIGINT, syscall.SIGTERM)
}

38
api/doc.go Normal file
View File

@@ -0,0 +1,38 @@
// Code generated by go-swagger; DO NOT EDIT.
// This file is part of MinIO Console Server
// Copyright (c) 2023 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
// Package api MinIO Console Server
//
// Schemes:
// http
// ws
// Host: localhost
// BasePath: /api/v1
// Version: 0.1.0
//
// Consumes:
// - application/json
// - multipart/form-data
//
// Produces:
// - application/zip
// - application/octet-stream
// - application/json
//
// swagger:meta
package api

17655
api/embedded_spec.go Normal file

File diff suppressed because it is too large Load Diff

278
api/errors.go Normal file
View File

@@ -0,0 +1,278 @@
// This file is part of MinIO Console Server
// Copyright (c) 2022 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package api
import (
"context"
"errors"
"strings"
"github.com/minio/minio-go/v7"
"github.com/minio/console/models"
"github.com/minio/madmin-go/v3"
)
var (
ErrDefault = errors.New("an error occurred, please try again")
ErrInvalidLogin = errors.New("invalid Login")
ErrForbidden = errors.New("403 Forbidden")
ErrBadRequest = errors.New("400 Bad Request")
ErrFileTooLarge = errors.New("413 File too Large")
ErrInvalidSession = errors.New("invalid session")
ErrNotFound = errors.New("not found")
ErrGroupAlreadyExists = errors.New("error group name already in use")
ErrInvalidErasureCodingValue = errors.New("invalid Erasure Coding Value")
ErrBucketBodyNotInRequest = errors.New("error bucket body not in request")
ErrBucketNameNotInRequest = errors.New("error bucket name not in request")
ErrGroupBodyNotInRequest = errors.New("error group body not in request")
ErrGroupNameNotInRequest = errors.New("error group name not in request")
ErrPolicyNameNotInRequest = errors.New("error policy name not in request")
ErrPolicyBodyNotInRequest = errors.New("error policy body not in request")
ErrPolicyNameContainsSpace = errors.New("error policy name cannot contain spaces")
ErrInvalidEncryptionAlgorithm = errors.New("error invalid encryption algorithm")
ErrSSENotConfigured = errors.New("error server side encryption configuration not found")
ErrBucketLifeCycleNotConfigured = errors.New("error bucket life cycle configuration not found")
ErrChangePassword = errors.New("error please check your current password")
ErrInvalidLicense = errors.New("invalid license key")
ErrLicenseNotFound = errors.New("license not found")
ErrAvoidSelfAccountDelete = errors.New("logged in user cannot be deleted by itself")
ErrAccessDenied = errors.New("access denied")
ErrOauth2Provider = errors.New("unable to contact configured identity provider")
ErrOauth2Login = errors.New("unable to login using configured identity provider")
ErrNonUniqueAccessKey = errors.New("access key already in use")
ErrRemoteTierExists = errors.New("specified remote tier already exists")
ErrRemoteTierNotFound = errors.New("specified remote tier was not found")
ErrRemoteTierUppercase = errors.New("tier name must be in uppercase")
ErrRemoteTierBucketNotFound = errors.New("remote tier bucket not found")
ErrRemoteInvalidCredentials = errors.New("invalid remote tier credentials")
ErrUnableToGetTenantUsage = errors.New("unable to get tenant usage")
ErrTooManyNodes = errors.New("cannot request more nodes than what is available in the cluster")
ErrTooFewNodes = errors.New("there are not enough nodes in the cluster to support this tenant")
ErrTooFewAvailableNodes = errors.New("there is not enough available nodes to satisfy this requirement")
ErrFewerThanFourNodes = errors.New("at least 4 nodes are required for a tenant")
ErrUnableToGetTenantLogs = errors.New("unable to get tenant logs")
ErrUnableToUpdateTenantCertificates = errors.New("unable to update tenant certificates")
ErrUpdatingEncryptionConfig = errors.New("unable to update encryption configuration")
ErrDeletingEncryptionConfig = errors.New("error disabling tenant encryption")
ErrEncryptionConfigNotFound = errors.New("encryption configuration not found")
ErrPolicyNotFound = errors.New("policy does not exist")
ErrLoginNotAllowed = errors.New("login not allowed")
ErrHealthReportFail = errors.New("failure to generate Health report")
)
type CodedAPIError struct {
Code int
APIError *models.APIError
}
// ErrorWithContext :
func ErrorWithContext(ctx context.Context, err ...interface{}) *CodedAPIError {
errorCode := 500
errorMessage := ErrDefault.Error()
var detailedMessage string
var err1 error
var exists bool
if len(err) > 0 {
if err1, exists = err[0].(error); exists {
detailedMessage = err1.Error()
var lastError error
if len(err) > 1 {
if err2, lastExists := err[1].(error); lastExists {
lastError = err2
}
}
if err1.Error() == ErrForbidden.Error() {
errorCode = 403
}
if err1.Error() == ErrBadRequest.Error() {
errorCode = 400
}
if err1 == ErrNotFound {
errorCode = 404
errorMessage = ErrNotFound.Error()
}
if errors.Is(err1, ErrInvalidLogin) {
detailedMessage = ""
errorCode = 401
errorMessage = ErrInvalidLogin.Error()
}
if strings.Contains(strings.ToLower(err1.Error()), ErrAccessDenied.Error()) {
errorCode = 403
errorMessage = err1.Error()
}
// If the last error is ErrInvalidLogin, this is a login failure
if errors.Is(lastError, ErrInvalidLogin) {
detailedMessage = ""
errorCode = 401
errorMessage = err1.Error()
}
if strings.Contains(err1.Error(), ErrLoginNotAllowed.Error()) {
detailedMessage = ""
errorCode = 400
errorMessage = ErrLoginNotAllowed.Error()
}
// console invalid erasure coding value
if errors.Is(err1, ErrInvalidErasureCodingValue) {
errorCode = 400
errorMessage = ErrInvalidErasureCodingValue.Error()
}
if errors.Is(err1, ErrBucketBodyNotInRequest) {
errorCode = 400
errorMessage = ErrBucketBodyNotInRequest.Error()
}
if errors.Is(err1, ErrBucketNameNotInRequest) {
errorCode = 400
errorMessage = ErrBucketNameNotInRequest.Error()
}
if errors.Is(err1, ErrGroupBodyNotInRequest) {
errorCode = 400
errorMessage = ErrGroupBodyNotInRequest.Error()
}
if errors.Is(err1, ErrGroupNameNotInRequest) {
errorCode = 400
errorMessage = ErrGroupNameNotInRequest.Error()
}
if errors.Is(err1, ErrPolicyNameNotInRequest) {
errorCode = 400
errorMessage = ErrPolicyNameNotInRequest.Error()
}
if errors.Is(err1, ErrPolicyBodyNotInRequest) {
errorCode = 400
errorMessage = ErrPolicyBodyNotInRequest.Error()
}
if errors.Is(err1, ErrPolicyNameContainsSpace) {
errorCode = 400
errorMessage = ErrPolicyNameContainsSpace.Error()
}
// console invalid session errors
if errors.Is(err1, ErrInvalidSession) {
errorCode = 401
errorMessage = ErrInvalidSession.Error()
}
if errors.Is(err1, ErrGroupAlreadyExists) {
errorCode = 400
errorMessage = ErrGroupAlreadyExists.Error()
}
// Bucket life cycle not configured
if errors.Is(err1, ErrBucketLifeCycleNotConfigured) {
errorCode = 404
errorMessage = ErrBucketLifeCycleNotConfigured.Error()
}
// Encryption not configured
if errors.Is(err1, ErrSSENotConfigured) {
errorCode = 404
errorMessage = ErrSSENotConfigured.Error()
}
if errors.Is(err1, ErrEncryptionConfigNotFound) {
errorCode = 404
errorMessage = err1.Error()
}
// account change password
if errors.Is(err1, ErrChangePassword) {
errorCode = 403
errorMessage = ErrChangePassword.Error()
}
if madmin.ToErrorResponse(err1).Code == "SignatureDoesNotMatch" {
errorCode = 403
errorMessage = ErrChangePassword.Error()
}
if errors.Is(err1, ErrLicenseNotFound) {
errorCode = 404
errorMessage = ErrLicenseNotFound.Error()
}
if errors.Is(err1, ErrInvalidLicense) {
errorCode = 404
errorMessage = ErrInvalidLicense.Error()
}
if errors.Is(err1, ErrAvoidSelfAccountDelete) {
errorCode = 403
errorMessage = ErrAvoidSelfAccountDelete.Error()
}
if errors.Is(err1, ErrAccessDenied) {
errorCode = 403
errorMessage = ErrAccessDenied.Error()
}
if errors.Is(err1, ErrPolicyNotFound) {
errorCode = 404
errorMessage = ErrPolicyNotFound.Error()
}
if madmin.ToErrorResponse(err1).Code == "AccessDenied" {
errorCode = 403
errorMessage = ErrAccessDenied.Error()
}
if madmin.ToErrorResponse(err1).Code == "InvalidAccessKeyId" {
errorCode = 401
errorMessage = ErrInvalidSession.Error()
}
// console invalid session errors
if madmin.ToErrorResponse(err1).Code == "XMinioAdminNoSuchUser" {
errorCode = 401
errorMessage = ErrInvalidSession.Error()
}
// tiering errors
if err1.Error() == ErrRemoteTierExists.Error() {
errorCode = 400
errorMessage = err1.Error()
}
if err1.Error() == ErrRemoteTierNotFound.Error() {
errorCode = 400
errorMessage = err1.Error()
}
if err1.Error() == ErrRemoteTierUppercase.Error() {
errorCode = 400
errorMessage = err1.Error()
}
if err1.Error() == ErrRemoteTierBucketNotFound.Error() {
errorCode = 400
errorMessage = err1.Error()
}
if err1.Error() == ErrRemoteInvalidCredentials.Error() {
errorCode = 403
errorMessage = err1.Error()
}
if err1.Error() == ErrFileTooLarge.Error() {
errorCode = 413
errorMessage = err1.Error()
}
// bucket already exists
if minio.ToErrorResponse(err1).Code == "BucketAlreadyOwnedByYou" {
errorCode = 400
errorMessage = "Bucket already exists"
}
LogError("ErrorWithContext:%v", err...)
LogIf(ctx, err1, err...)
}
if len(err) > 1 && err[1] != nil {
if err2, ok := err[1].(error); ok {
errorMessage = err2.Error()
}
}
}
return &CodedAPIError{Code: errorCode, APIError: &models.APIError{Message: errorMessage, DetailedMessage: detailedMessage}}
}
// Error receives an errors object and parse it against k8sErrors, returns the right errors code paired with a generic errors message
func Error(err ...interface{}) *CodedAPIError {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
return ErrorWithContext(ctx, err...)
}

159
api/errors_test.go Normal file
View File

@@ -0,0 +1,159 @@
// This file is part of MinIO Console Server
// Copyright (c) 2021 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package api
import (
"context"
"fmt"
"testing"
"github.com/minio/console/models"
"github.com/stretchr/testify/assert"
)
func TestError(t *testing.T) {
type args struct {
err []interface{}
}
type testError struct {
name string
args args
want *CodedAPIError
}
var tests []testError
type expectedError struct {
err error
code int
}
appErrors := map[string]expectedError{
"ErrDefault": {code: 500, err: ErrDefault},
"ErrForbidden": {code: 403, err: ErrForbidden},
"ErrFileTooLarge": {code: 413, err: ErrFileTooLarge},
"ErrInvalidSession": {code: 401, err: ErrInvalidSession},
"ErrNotFound": {code: 404, err: ErrNotFound},
"ErrGroupAlreadyExists": {code: 400, err: ErrGroupAlreadyExists},
"ErrInvalidErasureCodingValue": {code: 400, err: ErrInvalidErasureCodingValue},
"ErrBucketBodyNotInRequest": {code: 400, err: ErrBucketBodyNotInRequest},
"ErrBucketNameNotInRequest": {code: 400, err: ErrBucketNameNotInRequest},
"ErrGroupBodyNotInRequest": {code: 400, err: ErrGroupBodyNotInRequest},
"ErrGroupNameNotInRequest": {code: 400, err: ErrGroupNameNotInRequest},
"ErrPolicyNameNotInRequest": {code: 400, err: ErrPolicyNameNotInRequest},
"ErrPolicyBodyNotInRequest": {code: 400, err: ErrPolicyBodyNotInRequest},
"ErrInvalidEncryptionAlgorithm": {code: 500, err: ErrInvalidEncryptionAlgorithm},
"ErrSSENotConfigured": {code: 404, err: ErrSSENotConfigured},
"ErrBucketLifeCycleNotConfigured": {code: 404, err: ErrBucketLifeCycleNotConfigured},
"ErrChangePassword": {code: 403, err: ErrChangePassword},
"ErrInvalidLicense": {code: 404, err: ErrInvalidLicense},
"ErrLicenseNotFound": {code: 404, err: ErrLicenseNotFound},
"ErrAvoidSelfAccountDelete": {code: 403, err: ErrAvoidSelfAccountDelete},
"ErrNonUniqueAccessKey": {code: 500, err: ErrNonUniqueAccessKey},
"ErrRemoteTierExists": {code: 400, err: ErrRemoteTierExists},
"ErrRemoteTierNotFound": {code: 400, err: ErrRemoteTierNotFound},
"ErrRemoteTierUppercase": {code: 400, err: ErrRemoteTierUppercase},
"ErrRemoteTierBucketNotFound": {code: 400, err: ErrRemoteTierBucketNotFound},
"ErrRemoteInvalidCredentials": {code: 403, err: ErrRemoteInvalidCredentials},
"ErrTooFewNodes": {code: 500, err: ErrTooFewNodes},
"ErrUnableToGetTenantUsage": {code: 500, err: ErrUnableToGetTenantUsage},
"ErrTooManyNodes": {code: 500, err: ErrTooManyNodes},
"ErrAccessDenied": {code: 403, err: ErrAccessDenied},
"ErrTooFewAvailableNodes": {code: 500, err: ErrTooFewAvailableNodes},
"ErrFewerThanFourNodes": {code: 500, err: ErrFewerThanFourNodes},
"ErrUnableToGetTenantLogs": {code: 500, err: ErrUnableToGetTenantLogs},
"ErrUnableToUpdateTenantCertificates": {code: 500, err: ErrUnableToUpdateTenantCertificates},
"ErrUpdatingEncryptionConfig": {code: 500, err: ErrUpdatingEncryptionConfig},
"ErrDeletingEncryptionConfig": {code: 500, err: ErrDeletingEncryptionConfig},
"ErrEncryptionConfigNotFound": {code: 404, err: ErrEncryptionConfigNotFound},
}
for k, e := range appErrors {
tests = append(tests, testError{
name: fmt.Sprintf("%s error", k),
args: args{
err: []interface{}{e.err},
},
want: &CodedAPIError{
Code: e.code,
APIError: &models.APIError{Message: e.err.Error(), DetailedMessage: e.err.Error()},
},
})
}
tests = append(tests,
testError{
name: "passing multiple errors but ErrInvalidLogin is last",
args: args{
err: []interface{}{ErrDefault, ErrInvalidLogin},
},
want: &CodedAPIError{
Code: int(401),
APIError: &models.APIError{Message: ErrDefault.Error(), DetailedMessage: ""},
},
})
tests = append(tests,
testError{
name: "login error omits detailedMessage",
args: args{
err: []interface{}{ErrInvalidLogin},
},
want: &CodedAPIError{
Code: int(401),
APIError: &models.APIError{Message: ErrInvalidLogin.Error(), DetailedMessage: ""},
},
})
for _, tt := range tests {
t.Run(tt.name, func(_ *testing.T) {
got := Error(tt.args.err...)
assert.Equalf(t, tt.want.Code, got.Code, "Error(%v) Got (%v)", tt.want.Code, got.Code)
assert.Equalf(t, tt.want.APIError.DetailedMessage, got.APIError.DetailedMessage, "Error(%s) Got (%s)", tt.want.APIError.DetailedMessage, got.APIError.DetailedMessage)
})
}
}
func TestErrorWithContext(t *testing.T) {
type args struct {
ctx context.Context
err []interface{}
}
tests := []struct {
name string
args args
want *CodedAPIError
}{
{
name: "default error",
args: args{
ctx: context.Background(),
err: []interface{}{ErrDefault},
},
want: &CodedAPIError{
Code: 500, APIError: &models.APIError{Message: ErrDefault.Error(), DetailedMessage: ErrDefault.Error()},
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(_ *testing.T) {
assert.Equalf(t, tt.want, ErrorWithContext(tt.args.ctx, tt.args.err...), "ErrorWithContext(%v, %v)", tt.args.ctx, tt.args.err)
})
}
}

81
api/license.go Normal file
View File

@@ -0,0 +1,81 @@
// This file is part of MinIO Console Server
// Copyright (c) 2023 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package api
import (
"net/http"
"os"
"github.com/minio/pkg/v3/licverifier"
"github.com/minio/pkg/v3/subnet"
)
type SubnetPlan int
const (
PlanAGPL SubnetPlan = iota
PlanStandard
PlanEnterprise
PlanEnterpriseLite
PlanEnterprisePlus
)
func (sp SubnetPlan) String() string {
switch sp {
case PlanStandard:
return "standard"
case PlanEnterprise:
return "enterprise"
case PlanEnterpriseLite:
return "enterprise-lite"
case PlanEnterprisePlus:
return "enterprise-plus"
default:
return "agpl"
}
}
var InstanceLicensePlan = PlanAGPL
func getLicenseInfo(client http.Client, license string) (*licverifier.LicenseInfo, error) {
lv := subnet.LicenseValidator{
Client: client,
ExpiryGracePeriod: 0,
}
lv.Init(getConsoleDevMode())
return lv.ParseLicense(license)
}
func fetchLicensePlan() {
client := GetConsoleHTTPClient("127.0.0.1")
licenseInfo, err := getLicenseInfo(*client, os.Getenv(EnvSubnetLicense))
if err != nil {
return
}
switch licenseInfo.Plan {
case "STANDARD":
InstanceLicensePlan = PlanStandard
case "ENTERPRISE":
InstanceLicensePlan = PlanEnterprise
case "ENTERPRISE-LITE":
InstanceLicensePlan = PlanEnterpriseLite
case "ENTERPRISE-PLUS":
InstanceLicensePlan = PlanEnterprisePlus
default:
InstanceLicensePlan = PlanAGPL
}
}

83
api/logs.go Normal file
View File

@@ -0,0 +1,83 @@
// This file is part of MinIO Console Server
// Copyright (c) 2021 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
package api
import (
"context"
"errors"
"log"
"os"
"github.com/minio/cli"
)
var (
infoLog = log.New(os.Stdout, "I: ", log.LstdFlags)
errorLog = log.New(os.Stdout, "E: ", log.LstdFlags)
)
func logInfo(msg string, data ...interface{}) {
infoLog.Printf(msg+"\n", data...)
}
func logError(msg string, data ...interface{}) {
errorLog.Printf(msg+"\n", data...)
}
func logIf(_ context.Context, _ error, _ ...interface{}) {
}
// globally changeable logger styles
var (
LogInfo = logInfo
LogError = logError
LogIf = logIf
)
// Context captures all command line flags values
type Context struct {
Host string
HTTPPort, HTTPSPort int
TLSRedirect string
// Legacy options, TODO: remove in future
TLSCertificate, TLSKey, TLSca string
}
// Load loads api Context from command line context.
func (c *Context) Load(ctx *cli.Context) error {
*c = Context{
Host: ctx.String("host"),
HTTPPort: ctx.Int("port"),
HTTPSPort: ctx.Int("tls-port"),
TLSRedirect: ctx.String("tls-redirect"),
// Legacy options to be removed.
TLSCertificate: ctx.String("tls-certificate"),
TLSKey: ctx.String("tls-key"),
TLSca: ctx.String("tls-ca"),
}
if c.HTTPPort > 65535 {
return errors.New("invalid argument --port out of range - ports can range from 1-65535")
}
if c.HTTPSPort > 65535 {
return errors.New("invalid argument --tls-port out of range - ports can range from 1-65535")
}
if c.TLSRedirect != "on" && c.TLSRedirect != "off" {
return errors.New("invalid argument --tls-redirect only accepts either 'on' or 'off'")
}
return nil
}

110
api/logs_test.go Normal file
View File

@@ -0,0 +1,110 @@
// This file is part of MinIO Console Server
// Copyright (c) 2022 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package api
import (
"flag"
"fmt"
"testing"
"github.com/minio/cli"
"github.com/stretchr/testify/assert"
)
func TestContext_Load(t *testing.T) {
type fields struct {
Host string
HTTPPort int
HTTPSPort int
TLSRedirect string
TLSCertificate string
TLSKey string
TLSca string
}
type args struct {
values map[string]string
}
tests := []struct {
name string
fields fields
args args
wantErr bool
}{
{
name: "valid args",
args: args{
values: map[string]string{
"tls-redirect": "on",
},
},
wantErr: false,
},
{
name: "invalid args",
args: args{
values: map[string]string{
"tls-redirect": "aaaa",
},
},
wantErr: true,
},
{
name: "invalid port http",
args: args{
values: map[string]string{
"tls-redirect": "on",
"port": "65536",
},
},
wantErr: true,
},
{
name: "invalid port https",
args: args{
values: map[string]string{
"tls-redirect": "on",
"port": "65534",
"tls-port": "65536",
},
},
wantErr: true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(_ *testing.T) {
c := &Context{}
fs := flag.NewFlagSet("flags", flag.ContinueOnError)
for k, v := range tt.args.values {
fs.String(k, v, "ok")
}
ctx := cli.NewContext(nil, fs, &cli.Context{})
err := c.Load(ctx)
if tt.wantErr {
assert.NotNilf(t, err, fmt.Sprintf("Load(%v)", err))
} else {
assert.Nilf(t, err, fmt.Sprintf("Load(%v)", err))
}
})
}
}
func Test_logInfo(_ *testing.T) {
logInfo("message", nil)
}

View File

@@ -1,7 +1,7 @@
// Code generated by go-swagger; DO NOT EDIT.
// This file is part of MinIO Console Server
// Copyright (c) 2021 MinIO, Inc.
// Copyright (c) 2023 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
@@ -17,7 +17,7 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
package user_api
package account
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the generate command
@@ -48,10 +48,10 @@ func NewAccountChangePassword(ctx *middleware.Context, handler AccountChangePass
return &AccountChangePassword{Context: ctx, Handler: handler}
}
/* AccountChangePassword swagger:route POST /account/change-password UserAPI accountChangePassword
/*
AccountChangePassword swagger:route POST /account/change-password Account accountChangePassword
Change password of currently logged in user.
*/
type AccountChangePassword struct {
Context *middleware.Context

View File

@@ -1,7 +1,7 @@
// Code generated by go-swagger; DO NOT EDIT.
// This file is part of MinIO Console Server
// Copyright (c) 2021 MinIO, Inc.
// Copyright (c) 2023 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
@@ -17,13 +17,12 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
package user_api
package account
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"io"
"net/http"
@@ -83,7 +82,7 @@ func (o *AccountChangePasswordParams) BindRequest(r *http.Request, route *middle
res = append(res, err)
}
ctx := validate.WithOperationRequest(context.Background())
ctx := validate.WithOperationRequest(r.Context())
if err := body.ContextValidate(ctx, route.Formats); err != nil {
res = append(res, err)
}

View File

@@ -1,7 +1,7 @@
// Code generated by go-swagger; DO NOT EDIT.
// This file is part of MinIO Console Server
// Copyright (c) 2021 MinIO, Inc.
// Copyright (c) 2023 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
@@ -17,7 +17,7 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
package user_api
package account
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
@@ -33,7 +33,8 @@ import (
// AccountChangePasswordNoContentCode is the HTTP code returned for type AccountChangePasswordNoContent
const AccountChangePasswordNoContentCode int = 204
/*AccountChangePasswordNoContent A successful login.
/*
AccountChangePasswordNoContent A successful login.
swagger:response accountChangePasswordNoContent
*/
@@ -54,7 +55,8 @@ func (o *AccountChangePasswordNoContent) WriteResponse(rw http.ResponseWriter, p
rw.WriteHeader(204)
}
/*AccountChangePasswordDefault Generic error response.
/*
AccountChangePasswordDefault Generic error response.
swagger:response accountChangePasswordDefault
*/
@@ -64,7 +66,7 @@ type AccountChangePasswordDefault struct {
/*
In: Body
*/
Payload *models.Error `json:"body,omitempty"`
Payload *models.APIError `json:"body,omitempty"`
}
// NewAccountChangePasswordDefault creates AccountChangePasswordDefault with default headers values
@@ -90,13 +92,13 @@ func (o *AccountChangePasswordDefault) SetStatusCode(code int) {
}
// WithPayload adds the payload to the account change password default response
func (o *AccountChangePasswordDefault) WithPayload(payload *models.Error) *AccountChangePasswordDefault {
func (o *AccountChangePasswordDefault) WithPayload(payload *models.APIError) *AccountChangePasswordDefault {
o.Payload = payload
return o
}
// SetPayload sets the payload to the account change password default response
func (o *AccountChangePasswordDefault) SetPayload(payload *models.Error) {
func (o *AccountChangePasswordDefault) SetPayload(payload *models.APIError) {
o.Payload = payload
}

View File

@@ -1,7 +1,7 @@
// Code generated by go-swagger; DO NOT EDIT.
// This file is part of MinIO Console Server
// Copyright (c) 2021 MinIO, Inc.
// Copyright (c) 2023 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
@@ -17,7 +17,7 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
package user_api
package account
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the generate command

View File

@@ -1,7 +1,7 @@
// Code generated by go-swagger; DO NOT EDIT.
// This file is part of MinIO Console Server
// Copyright (c) 2021 MinIO, Inc.
// Copyright (c) 2023 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
@@ -17,7 +17,7 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
package admin_api
package account
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the generate command
@@ -48,10 +48,10 @@ func NewChangeUserPassword(ctx *middleware.Context, handler ChangeUserPasswordHa
return &ChangeUserPassword{Context: ctx, Handler: handler}
}
/* ChangeUserPassword swagger:route POST /account/change-user-password AdminAPI changeUserPassword
/*
ChangeUserPassword swagger:route POST /account/change-user-password Account changeUserPassword
Change password of currently logged in user.
*/
type ChangeUserPassword struct {
Context *middleware.Context

View File

@@ -1,7 +1,7 @@
// Code generated by go-swagger; DO NOT EDIT.
// This file is part of MinIO Console Server
// Copyright (c) 2021 MinIO, Inc.
// Copyright (c) 2023 MinIO, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
@@ -17,13 +17,12 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
package admin_api
package account
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"context"
"io"
"net/http"
@@ -83,7 +82,7 @@ func (o *ChangeUserPasswordParams) BindRequest(r *http.Request, route *middlewar
res = append(res, err)
}
ctx := validate.WithOperationRequest(context.Background())
ctx := validate.WithOperationRequest(r.Context())
if err := body.ContextValidate(ctx, route.Formats); err != nil {
res = append(res, err)
}

Some files were not shown because too many files have changed in this diff Show More