16
16
17
17
import React , { Fragment , useEffect } from "react" ;
18
18
import { useNavigate } from "react-router-dom" ;
19
- import {
20
- InputAdornment ,
21
- LinearProgress ,
22
- MenuItem ,
23
- Select ,
24
- } from "@mui/material" ;
25
- import {
26
- Button ,
27
- Loader ,
28
- LockIcon ,
29
- LoginWrapper ,
30
- LogoutIcon ,
31
- RefreshIcon ,
32
- } from "mds" ;
19
+ import { Button , Loader , LoginWrapper , RefreshIcon } from "mds" ;
33
20
import { Theme } from "@mui/material/styles" ;
34
21
import createStyles from "@mui/styles/createStyles" ;
35
22
import makeStyles from "@mui/styles/makeStyles" ;
36
- import Grid from "@mui/material/Grid" ;
37
23
import { loginStrategyType , redirectRule } from "./types" ;
38
24
import MainError from "../Console/Common/MainError/MainError" ;
39
25
import { spacingUtils } from "../Console/Common/FormComponents/common/styleLibrary" ;
40
- import clsx from "clsx" ;
41
26
import { AppState , useAppDispatch } from "../../store" ;
42
27
import { useSelector } from "react-redux" ;
43
- import {
44
- doLoginAsync ,
45
- getFetchConfigurationAsync ,
46
- getVersionAsync ,
47
- } from "./loginThunks" ;
48
- import { resetForm , setJwt } from "./loginSlice" ;
28
+ import { getFetchConfigurationAsync , getVersionAsync } from "./loginThunks" ;
29
+ import { resetForm } from "./loginSlice" ;
49
30
import StrategyForm from "./StrategyForm" ;
50
- import { LoginField } from "./LoginField" ;
51
31
import { redirectRules } from "../../utils/sortFunctions" ;
52
32
import { getLogoVar } from "../../config" ;
53
33
@@ -250,19 +230,12 @@ const useStyles = makeStyles((theme: Theme) =>
250
230
} )
251
231
) ;
252
232
253
- export interface LoginStrategyRoutes {
254
- [ key : string ] : string ;
255
- }
256
-
257
233
export interface LoginStrategyPayload {
258
- [ key : string ] : any ;
234
+ accessKey : string ;
235
+ secretKey : string ;
236
+ sts ?: string ;
259
237
}
260
238
261
- export const loginStrategyEndpoints : LoginStrategyRoutes = {
262
- form : "/api/v1/login" ,
263
- "service-account" : "/api/v1/login/operator" ,
264
- } ;
265
-
266
239
export const getTargetPath = ( ) => {
267
240
let targetPath = "/" ;
268
241
if (
@@ -280,13 +253,9 @@ const Login = () => {
280
253
const navigate = useNavigate ( ) ;
281
254
const classes = useStyles ( ) ;
282
255
283
- const jwt = useSelector ( ( state : AppState ) => state . login . jwt ) ;
284
256
const loginStrategy = useSelector (
285
257
( state : AppState ) => state . login . loginStrategy
286
258
) ;
287
- const loginSending = useSelector (
288
- ( state : AppState ) => state . login . loginSending
289
- ) ;
290
259
const loadingFetchConfiguration = useSelector (
291
260
( state : AppState ) => state . login . loadingFetchConfiguration
292
261
) ;
@@ -295,25 +264,15 @@ const Login = () => {
295
264
) ;
296
265
const navigateTo = useSelector ( ( state : AppState ) => state . login . navigateTo ) ;
297
266
298
- const isDirectPV = useSelector ( ( state : AppState ) => state . login . isDirectPV ) ;
299
267
const isK8S = useSelector ( ( state : AppState ) => state . login . isK8S ) ;
300
268
301
- const isOperator =
302
- loginStrategy . loginStrategy === loginStrategyType . serviceAccount ||
303
- loginStrategy . loginStrategy === loginStrategyType . redirectServiceAccount ;
304
-
305
269
useEffect ( ( ) => {
306
270
if ( navigateTo !== "" ) {
307
271
dispatch ( resetForm ( ) ) ;
308
272
navigate ( navigateTo ) ;
309
273
}
310
274
} , [ navigateTo , dispatch , navigate ] ) ;
311
275
312
- const formSubmit = ( e : React . FormEvent < HTMLFormElement > ) => {
313
- e . preventDefault ( ) ;
314
- dispatch ( doLoginAsync ( ) ) ;
315
- } ;
316
-
317
276
useEffect ( ( ) => {
318
277
if ( loadingFetchConfiguration ) {
319
278
dispatch ( getFetchConfigurationAsync ( ) ) ;
@@ -329,12 +288,8 @@ const Login = () => {
329
288
let loginComponent ;
330
289
331
290
switch ( loginStrategy . loginStrategy ) {
332
- case loginStrategyType . form : {
333
- loginComponent = < StrategyForm /> ;
334
- break ;
335
- }
336
291
case loginStrategyType . redirect :
337
- case loginStrategyType . redirectServiceAccount : {
292
+ case loginStrategyType . form : {
338
293
let redirectItems : redirectRule [ ] = [ ] ;
339
294
340
295
if (
@@ -344,111 +299,7 @@ const Login = () => {
344
299
redirectItems = [ ...loginStrategy . redirectRules ] . sort ( redirectRules ) ;
345
300
}
346
301
347
- if (
348
- loginStrategy . redirectRules &&
349
- loginStrategy . redirectRules . length > 1
350
- ) {
351
- loginComponent = (
352
- < Fragment >
353
- < div className = { classes . loginSsoText } > Login with SSO:</ div >
354
- < Select
355
- id = "ssoLogin"
356
- name = "ssoLogin"
357
- data-test-id = "sso-login"
358
- onChange = { ( e ) => {
359
- if ( e . target . value ) {
360
- window . location . href = e . target . value as string ;
361
- }
362
- } }
363
- displayEmpty
364
- className = { classes . ssoSelect }
365
- renderValue = { ( ) => "Select Provider" }
366
- >
367
- { redirectItems . map ( ( r , idx ) => (
368
- < MenuItem
369
- value = { r . redirect }
370
- key = { `sso-login-option-${ idx } ` }
371
- className = { classes . ssoMenuItem }
372
- divider = { true }
373
- >
374
- < LogoutIcon className = { classes . ssoLoginIcon } />
375
- { r . displayName }
376
- </ MenuItem >
377
- ) ) }
378
- </ Select >
379
- </ Fragment >
380
- ) ;
381
- } else if ( redirectItems . length === 1 ) {
382
- loginComponent = (
383
- < div className = { clsx ( classes . submit , classes . ssoSubmit ) } >
384
- < Button
385
- key = { `login-button` }
386
- variant = "callAction"
387
- id = "sso-login"
388
- label = {
389
- redirectItems [ 0 ] . displayName === ""
390
- ? "Login with SSO"
391
- : redirectItems [ 0 ] . displayName
392
- }
393
- onClick = { ( ) => ( window . location . href = redirectItems [ 0 ] . redirect ) }
394
- fullWidth
395
- />
396
- </ div >
397
- ) ;
398
- } else {
399
- loginComponent = (
400
- < div className = { classes . loginStrategyMessage } >
401
- Cannot retrieve redirect from login strategy
402
- </ div >
403
- ) ;
404
- }
405
- break ;
406
- }
407
- case loginStrategyType . serviceAccount : {
408
- loginComponent = (
409
- < Fragment >
410
- < form className = { classes . form } noValidate onSubmit = { formSubmit } >
411
- < Grid container spacing = { 2 } >
412
- < Grid item xs = { 12 } >
413
- < LoginField
414
- required
415
- className = { classes . inputField }
416
- fullWidth
417
- id = "jwt"
418
- value = { jwt }
419
- onChange = { ( e : React . ChangeEvent < HTMLInputElement > ) =>
420
- dispatch ( setJwt ( e . target . value ) )
421
- }
422
- name = "jwt"
423
- autoComplete = "off"
424
- disabled = { loginSending }
425
- placeholder = { "Enter JWT" }
426
- variant = { "outlined" }
427
- InputProps = { {
428
- startAdornment : (
429
- < InputAdornment position = "start" >
430
- < LockIcon />
431
- </ InputAdornment >
432
- ) ,
433
- } }
434
- />
435
- </ Grid >
436
- </ Grid >
437
- < Grid item xs = { 12 } className = { classes . submitContainer } >
438
- < Button
439
- variant = "callAction"
440
- id = "do-login"
441
- disabled = { jwt === "" || loginSending }
442
- label = { "Login" }
443
- fullWidth
444
- />
445
- </ Grid >
446
- < Grid item xs = { 12 } className = { classes . linearPredef } >
447
- { loginSending && < LinearProgress /> }
448
- </ Grid >
449
- </ form >
450
- </ Fragment >
451
- ) ;
302
+ loginComponent = < StrategyForm redirectRules = { redirectItems } /> ;
452
303
break ;
453
304
}
454
305
default :
@@ -483,16 +334,6 @@ const Login = () => {
483
334
) ;
484
335
}
485
336
486
- let modeLogo : "console" | "directpv" | "operator" | "kes" | "subnet" =
487
- "console" ;
488
- const logoVar = getLogoVar ( ) ;
489
-
490
- if ( isDirectPV ) {
491
- modeLogo = "directpv" ;
492
- } else if ( isOperator ) {
493
- modeLogo = "operator" ;
494
- }
495
-
496
337
let docsURL = "https://min.io/docs/minio/linux/index.html?ref=con" ;
497
338
if ( isK8S ) {
498
339
docsURL =
@@ -503,7 +344,7 @@ const Login = () => {
503
344
< Fragment >
504
345
< MainError />
505
346
< LoginWrapper
506
- logoProps = { { applicationName : modeLogo , subVariant : logoVar } }
347
+ logoProps = { { applicationName : "console" , subVariant : getLogoVar ( ) } }
507
348
form = { loginComponent }
508
349
formFooter = {
509
350
< Fragment >
0 commit comments