• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

hyperledger / identus-cloud-agent / 8998019047

08 May 2024 07:31AM UTC coverage: 47.171% (-0.7%) from 47.829%
8998019047

Pull #1021

patlo-iog
chore: pr cleanup
Pull Request #1021: feat: oidc4vc credential configuration and metadata endpoints [WIP]

2 of 253 new or added lines in 12 files covered. (0.79%)

186 existing lines in 51 files now uncovered.

7388 of 15662 relevant lines covered (47.17%)

0.47 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/cloud-agent/service/server/src/main/scala/org/hyperledger/identus/agent/server/MainApp.scala
1
package org.hyperledger.identus.agent.server
2

3
import com.nimbusds.jose.crypto.bc.BouncyCastleProviderSingleton
4
import io.micrometer.prometheus.{PrometheusConfig, PrometheusMeterRegistry}
5
import org.hyperledger.identus.agent.server.config.AppConfig
6
import org.hyperledger.identus.agent.server.http.ZioHttpClient
7
import org.hyperledger.identus.agent.server.sql.Migrations as AgentMigrations
8
import org.hyperledger.identus.agent.walletapi.service.{
9
  EntityServiceImpl,
10
  ManagedDIDService,
11
  ManagedDIDServiceWithEventNotificationImpl,
12
  WalletManagementServiceImpl
13
}
14
import org.hyperledger.identus.agent.walletapi.sql.{
15
  JdbcDIDNonSecretStorage,
16
  JdbcEntityRepository,
17
  JdbcWalletNonSecretStorage
18
}
19
import org.hyperledger.identus.agent.walletapi.storage.GenericSecretStorage
20
import org.hyperledger.identus.castor.controller.{DIDControllerImpl, DIDRegistrarControllerImpl}
21
import org.hyperledger.identus.castor.core.service.DIDServiceImpl
22
import org.hyperledger.identus.castor.core.util.DIDOperationValidator
23
import org.hyperledger.identus.connect.controller.ConnectionControllerImpl
24
import org.hyperledger.identus.connect.core.service.{ConnectionServiceImpl, ConnectionServiceNotifier}
25
import org.hyperledger.identus.connect.sql.repository.{JdbcConnectionRepository, Migrations as ConnectMigrations}
26
import org.hyperledger.identus.credential.status.controller.CredentialStatusControllerImpl
27
import org.hyperledger.identus.event.controller.EventControllerImpl
28
import org.hyperledger.identus.event.notification.EventNotificationServiceImpl
29
import org.hyperledger.identus.iam.authentication.DefaultAuthenticator
30
import org.hyperledger.identus.iam.authentication.apikey.JdbcAuthenticationRepository
31
import org.hyperledger.identus.iam.authorization.DefaultPermissionManagementService
32
import org.hyperledger.identus.iam.authorization.core.EntityPermissionManagementService
33
import org.hyperledger.identus.iam.entity.http.controller.{EntityController, EntityControllerImpl}
34
import org.hyperledger.identus.iam.wallet.http.controller.WalletManagementControllerImpl
35
import org.hyperledger.identus.issue.controller.IssueControllerImpl
36
import org.hyperledger.identus.mercury.*
37
import org.hyperledger.identus.oidc4vc.controller.CredentialIssuerControllerImpl
38
import org.hyperledger.identus.oidc4vc.service.OIDCCredentialIssuerServiceImpl
39
import org.hyperledger.identus.oidc4vc.storage.InMemoryIssuanceSessionService
40
import org.hyperledger.identus.pollux.core.service.*
41
import org.hyperledger.identus.pollux.core.service.verification.VcVerificationServiceImpl
42
import org.hyperledger.identus.pollux.credentialdefinition.controller.CredentialDefinitionControllerImpl
43
import org.hyperledger.identus.pollux.credentialschema.controller.{
44
  CredentialSchemaController,
45
  CredentialSchemaControllerImpl,
46
  VerificationPolicyControllerImpl
47
}
48
import org.hyperledger.identus.pollux.sql.repository.JdbcOIDC4VCIssuerMetadataRepository
49
import org.hyperledger.identus.pollux.sql.repository.{
50
  JdbcCredentialDefinitionRepository,
51
  JdbcCredentialRepository,
52
  JdbcCredentialSchemaRepository,
53
  JdbcCredentialStatusListRepository,
54
  JdbcPresentationRepository,
55
  JdbcVerificationPolicyRepository,
56
  Migrations as PolluxMigrations
57
}
58
import org.hyperledger.identus.presentproof.controller.PresentProofControllerImpl
59
import org.hyperledger.identus.resolvers.DIDResolver
60
import org.hyperledger.identus.system.controller.SystemControllerImpl
61
import org.hyperledger.identus.verification.controller.VcVerificationControllerImpl
62
import zio.*
63
import zio.logging.*
64
import zio.logging.LogFormat.*
65
import zio.logging.backend.SLF4J
66
import zio.metrics.connectors.micrometer
67
import zio.metrics.connectors.micrometer.MicrometerConfig
68
import zio.metrics.jvm.DefaultJvmMetrics
69

70
import java.security.Security
71

72
object MainApp extends ZIOAppDefault {
73

74
  val colorFormat: LogFormat =
75
    fiberId.color(LogColor.YELLOW) |-|
×
76
      line.highlight |-|
×
77
      allAnnotations |-|
×
78
      cause.highlight
×
79

80
  override val bootstrap: ZLayer[ZIOAppArgs, Any, Any] =
81
    Runtime.removeDefaultLoggers >>> SLF4J.slf4j(colorFormat)
×
82

83
  Security.insertProviderAt(BouncyCastleProviderSingleton.getInstance(), 2)
×
84

85
  // FIXME: remove this when db app user have correct privileges provisioned by k8s operator.
86
  // This should be executed before migration to have correct privilege for new objects.
87
  private val preMigrations = for {
×
88
    _ <- ZIO.logInfo("running pre-migration steps.")
×
89
    appConfig <- ZIO.service[AppConfig].provide(SystemModule.configLayer)
×
90
    _ <- PolluxMigrations
×
91
      .initDbPrivileges(appConfig.pollux.database.appUsername)
×
92
      .provide(RepoModule.polluxTransactorLayer)
×
93
    _ <- ConnectMigrations
×
94
      .initDbPrivileges(appConfig.connect.database.appUsername)
×
95
      .provide(RepoModule.connectTransactorLayer)
×
96
    _ <- AgentMigrations
×
97
      .initDbPrivileges(appConfig.agent.database.appUsername)
×
98
      .provide(RepoModule.agentTransactorLayer)
×
99
  } yield ()
×
100

101
  private val migrations = for {
×
102
    _ <- ZIO.serviceWithZIO[PolluxMigrations](_.migrate)
×
103
    _ <- ZIO.serviceWithZIO[ConnectMigrations](_.migrate)
×
104
    _ <- ZIO.serviceWithZIO[AgentMigrations](_.migrate)
×
105
    _ <- ZIO.logInfo("Running post-migration RLS checks for DB application users")
×
106
    _ <- PolluxMigrations.validateRLS.provide(RepoModule.polluxContextAwareTransactorLayer)
×
107
    _ <- ConnectMigrations.validateRLS.provide(RepoModule.connectContextAwareTransactorLayer)
×
108
    _ <- AgentMigrations.validateRLS.provide(RepoModule.agentContextAwareTransactorLayer)
×
109
  } yield ()
×
110
  override def run: ZIO[Any, Throwable, Unit] = {
×
111

112
    val app = for {
×
113
      _ <- Console
×
114
        .printLine(s"""
×
115
      |██████╗ ██████╗ ██╗███████╗███╗   ███╗
116
      |██╔══██╗██╔══██╗██║██╔════╝████╗ ████║
117
      |██████╔╝██████╔╝██║███████╗██╔████╔██║
118
      |██╔═══╝ ██╔══██╗██║╚════██║██║╚██╔╝██║
119
      |██║     ██║  ██║██║███████║██║ ╚═╝ ██║
120
      |╚═╝     ╚═╝  ╚═╝╚═╝╚══════╝╚═╝     ╚═╝
121
      |
122
      | █████╗  ██████╗ ███████╗███╗   ██╗████████╗
123
      |██╔══██╗██╔════╝ ██╔════╝████╗  ██║╚══██╔══╝
124
      |███████║██║  ███╗█████╗  ██╔██╗ ██║   ██║
125
      |██╔══██║██║   ██║██╔══╝  ██║╚██╗██║   ██║
126
      |██║  ██║╚██████╔╝███████╗██║ ╚████║   ██║
127
      |╚═╝  ╚═╝ ╚═════╝ ╚══════╝╚═╝  ╚═══╝   ╚═╝
128
      |
129
      |version: ${BuildInfo.version}
130
      |
131
      |""".stripMargin)
×
132
        .ignore
133

134
      _ <- preMigrations
×
135
      _ <- migrations
×
136

137
      app <- CloudAgentApp.run
×
138
        .provide(
×
139
          DidCommX.liveLayer,
140
          // infra
141
          SystemModule.configLayer,
142
          ZioHttpClient.layer,
143
          // observability
144
          DefaultJvmMetrics.live.unit,
×
145
          SystemControllerImpl.layer,
146
          ZLayer.succeed(PrometheusMeterRegistry(PrometheusConfig.DEFAULT)),
×
147
          ZLayer.succeed(MicrometerConfig.default),
×
148
          micrometer.micrometerLayer,
149
          // controller
150
          ConnectionControllerImpl.layer,
151
          CredentialSchemaControllerImpl.layer,
152
          CredentialDefinitionControllerImpl.layer,
153
          DIDControllerImpl.layer,
154
          DIDRegistrarControllerImpl.layer,
155
          IssueControllerImpl.layer,
156
          CredentialStatusControllerImpl.layer,
157
          PresentProofControllerImpl.layer,
158
          VcVerificationControllerImpl.layer,
159
          VerificationPolicyControllerImpl.layer,
160
          EntityControllerImpl.layer,
161
          WalletManagementControllerImpl.layer,
162
          EventControllerImpl.layer,
163
          // domain
164
          AppModule.apolloLayer,
165
          AppModule.didJwtResolverLayer,
166
          DIDOperationValidator.layer(),
×
167
          DIDResolver.layer,
168
          HttpURIDereferencerImpl.layer,
169
          // service
170
          ConnectionServiceImpl.layer >>> ConnectionServiceNotifier.layer,
×
171
          CredentialSchemaServiceImpl.layer,
172
          CredentialDefinitionServiceImpl.layer,
173
          CredentialStatusListServiceImpl.layer,
174
          LinkSecretServiceImpl.layer >>> CredentialServiceImpl.layer >>> CredentialServiceNotifier.layer,
×
175
          DIDServiceImpl.layer,
176
          EntityServiceImpl.layer,
177
          ManagedDIDServiceWithEventNotificationImpl.layer,
178
          LinkSecretServiceImpl.layer >>> PresentationServiceImpl.layer >>> PresentationServiceNotifier.layer,
×
179
          VerificationPolicyServiceImpl.layer,
180
          WalletManagementServiceImpl.layer,
181
          VcVerificationServiceImpl.layer,
182
          // authentication
183
          AppModule.builtInAuthenticatorLayer,
184
          AppModule.keycloakAuthenticatorLayer,
185
          AppModule.keycloakPermissionManagementLayer,
186
          DefaultAuthenticator.layer,
187
          DefaultPermissionManagementService.layer,
×
188
          EntityPermissionManagementService.layer,
189
          // grpc
190
          GrpcModule.prismNodeStubLayer,
191
          // storage
192
          RepoModule.agentContextAwareTransactorLayer ++ RepoModule.agentTransactorLayer >>> JdbcDIDNonSecretStorage.layer,
×
193
          RepoModule.agentContextAwareTransactorLayer >>> JdbcWalletNonSecretStorage.layer,
×
194
          RepoModule.allSecretStorageLayer,
195
          RepoModule.agentTransactorLayer >>> JdbcEntityRepository.layer,
×
196
          RepoModule.agentTransactorLayer >>> JdbcAuthenticationRepository.layer,
×
197
          RepoModule.connectContextAwareTransactorLayer ++ RepoModule.connectTransactorLayer >>> JdbcConnectionRepository.layer,
×
198
          RepoModule.polluxContextAwareTransactorLayer ++ RepoModule.polluxTransactorLayer >>> JdbcCredentialRepository.layer,
×
199
          RepoModule.polluxContextAwareTransactorLayer ++ RepoModule.polluxTransactorLayer >>> JdbcCredentialStatusListRepository.layer,
×
200
          RepoModule.polluxContextAwareTransactorLayer ++ RepoModule.polluxTransactorLayer >>> JdbcCredentialSchemaRepository.layer,
×
201
          RepoModule.polluxContextAwareTransactorLayer ++ RepoModule.polluxTransactorLayer >>> JdbcCredentialDefinitionRepository.layer,
×
202
          RepoModule.polluxContextAwareTransactorLayer ++ RepoModule.polluxTransactorLayer >>> JdbcPresentationRepository.layer,
×
NEW
203
          RepoModule.polluxContextAwareTransactorLayer ++ RepoModule.polluxTransactorLayer >>> JdbcOIDC4VCIssuerMetadataRepository.layer,
×
UNCOV
204
          RepoModule.polluxContextAwareTransactorLayer >>> JdbcVerificationPolicyRepository.layer,
×
205
          // oidc
206
          CredentialIssuerControllerImpl.layer,
207
          InMemoryIssuanceSessionService.layer,
208
          OIDC4VCIssuerMetadataServiceImpl.layer,
×
209
          OIDCCredentialIssuerServiceImpl.layer,
210
          // event notification service
211
          ZLayer.succeed(500) >>> EventNotificationServiceImpl.layer,
×
212
          // HTTP client
213
          SystemModule.zioHttpClientLayer,
214
          Scope.default,
215
        )
216
    } yield app
217

218
    app.provide(
×
219
      RepoModule.polluxDbConfigLayer(appUser = false) >>> PolluxMigrations.layer,
×
220
      RepoModule.connectDbConfigLayer(appUser = false) >>> ConnectMigrations.layer,
×
221
      RepoModule.agentDbConfigLayer(appUser = false) >>> AgentMigrations.layer,
×
222
    )
223
  }
224

225
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc