(ctx context.Context, pid string, aid string)
| 449 | } |
| 450 | |
| 451 | func (i *imlAuthorizationModule) Detail(ctx context.Context, pid string, aid string) ([]application_authorization_dto.DetailItem, error) { |
| 452 | _, err := i.serviceService.Get(ctx, pid) |
| 453 | if err != nil { |
| 454 | return nil, err |
| 455 | } |
| 456 | authInfo, err := i.authorizationService.Get(ctx, aid) |
| 457 | if err != nil { |
| 458 | return nil, err |
| 459 | } |
| 460 | authFactory, has := authDriver.GetAuthFactory(authInfo.Type) |
| 461 | if !has { |
| 462 | return nil, errors.New("unknown driver") |
| 463 | } |
| 464 | auth, err := authFactory.Create(authInfo.Config) |
| 465 | if err != nil { |
| 466 | return nil, err |
| 467 | } |
| 468 | cfgItems := auth.AuthConfig().Detail() |
| 469 | details := make([]application_authorization_dto.DetailItem, 0, 6+len(cfgItems)) |
| 470 | details = append(details, application_authorization_dto.DetailItem{Key: "名称", Value: authInfo.Name}) |
| 471 | details = append(details, application_authorization_dto.DetailItem{Key: "鉴权类型", Value: authInfo.Type}) |
| 472 | details = append(details, application_authorization_dto.DetailItem{Key: "参数位置", Value: authInfo.Position}) |
| 473 | details = append(details, application_authorization_dto.DetailItem{Key: "参数名", Value: authInfo.TokenName}) |
| 474 | details = append(details, cfgItems...) |
| 475 | dateStr := "永久" |
| 476 | if authInfo.ExpireTime != 0 { |
| 477 | dateStr = time.Unix(authInfo.ExpireTime, 0).Format("2006-01-02") |
| 478 | } |
| 479 | details = append(details, application_authorization_dto.DetailItem{Key: "过期日期", Value: dateStr}) |
| 480 | hideAuthStr := "是" |
| 481 | if !authInfo.HideCredential { |
| 482 | hideAuthStr = "否" |
| 483 | } |
| 484 | details = append(details, application_authorization_dto.DetailItem{Key: "隐藏鉴权信息", Value: hideAuthStr}) |
| 485 | |
| 486 | return details, nil |
| 487 | } |
| 488 | |
| 489 | func (i *imlAuthorizationModule) Info(ctx context.Context, pid string, aid string) (*application_authorization_dto.Authorization, error) { |
| 490 | _, err := i.serviceService.Get(ctx, pid) |
nothing calls this directly
no test coverage detected