Skip to content

Commit

Permalink
Remove the automatic project provisioning implemented for the MOOC
Browse files Browse the repository at this point in the history
  • Loading branch information
Simon Dumas committed Nov 27, 2024
1 parent a2f1af8 commit 0207fe2
Show file tree
Hide file tree
Showing 13 changed files with 21 additions and 458 deletions.
24 changes: 0 additions & 24 deletions delta/app/src/main/resources/app.conf
Original file line number Diff line number Diff line change
Expand Up @@ -277,30 +277,6 @@ app {
}
}

# Configuration for the automatic provisioning of projects.
automatic-provisioning {
enabled = false
# The list of permissions to apply to the owner on the generated project
permissions = ["resources/read", "resources/write", "projects/read"]
description = "Auto provisioned project"

# configuration of realms for automatic provisioning
# mapping between realm label and organization in which to provision the project
enabled-realms {
realm = "users-realm"
}
api-mappings {
# example API mapping
# documents = "https://bluebrain.github.io/nexus/vocabulary/defaultElasticSearchIndex"
}
# vocab setting for the project
# vocab = "http://example.com/vocab"
# base setting for the project
# base = "http://example.com/base"
# to ban unconstrained resources in a project
enforce-schema = false
}

# Quotas for projects
quotas {
# flag to enable or disable project quotas
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import ch.epfl.bluebrain.nexus.delta.sdk.model.ServiceAccountConfig
import ch.epfl.bluebrain.nexus.delta.sdk.organizations.OrganizationsConfig
import ch.epfl.bluebrain.nexus.delta.sdk.permissions.PermissionsConfig
import ch.epfl.bluebrain.nexus.delta.sdk.projects.ProjectsConfig
import ch.epfl.bluebrain.nexus.delta.sdk.provisioning.AutomaticProvisioningConfig
import ch.epfl.bluebrain.nexus.delta.sdk.quotas.QuotasConfig
import ch.epfl.bluebrain.nexus.delta.sdk.realms.RealmsConfig
import ch.epfl.bluebrain.nexus.delta.sdk.resolvers.ResolversConfig
Expand Down Expand Up @@ -43,7 +42,6 @@ final case class AppConfig(
organizations: OrganizationsConfig,
acls: AclsConfig,
projects: ProjectsConfig,
automaticProvisioning: AutomaticProvisioningConfig,
quotas: QuotasConfig,
resolvers: ResolversConfig,
resources: ResourcesConfig,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,39 +1,30 @@
package ch.epfl.bluebrain.nexus.delta.routes

import akka.http.scaladsl.server.{Directive0, Route}
import akka.http.scaladsl.server.Route
import cats.effect.IO
import cats.effect.unsafe.implicits._
import ch.epfl.bluebrain.nexus.delta.rdf.jsonld.context.RemoteContextResolution
import ch.epfl.bluebrain.nexus.delta.rdf.utils.JsonKeyOrdering
import ch.epfl.bluebrain.nexus.delta.sdk.acls.AclCheck
import ch.epfl.bluebrain.nexus.delta.sdk.directives.AuthDirectives
import ch.epfl.bluebrain.nexus.delta.sdk.directives.DeltaDirectives._
import ch.epfl.bluebrain.nexus.delta.sdk.identities.Identities
import ch.epfl.bluebrain.nexus.delta.sdk.identities.model.Caller
import ch.epfl.bluebrain.nexus.delta.sdk.identities.model.Caller._
import ch.epfl.bluebrain.nexus.delta.sdk.model.BaseUri
import ch.epfl.bluebrain.nexus.delta.sdk.provisioning.ProjectProvisioning

/**
* The identities routes
*/
class IdentitiesRoutes(identities: Identities, aclCheck: AclCheck, projectProvisioning: ProjectProvisioning)(implicit
class IdentitiesRoutes(identities: Identities, aclCheck: AclCheck)(implicit
baseUri: BaseUri,
cr: RemoteContextResolution,
ordering: JsonKeyOrdering
) extends AuthDirectives(identities, aclCheck) {

private def provisionProject(implicit caller: Caller): Directive0 = onSuccess(
projectProvisioning(caller.subject).unsafeToFuture()
)

def routes: Route = {
baseUriPrefix(baseUri.prefix) {
(pathPrefix("identities") & pathEndOrSingleSlash) {
(extractCaller & get) { implicit caller =>
provisionProject.apply {
emit(IO.pure(caller))
}
emit(IO.pure(caller))
}
}
}
Expand All @@ -48,8 +39,7 @@ object IdentitiesRoutes {
*/
def apply(
identities: Identities,
aclCheck: AclCheck,
projectProvisioning: ProjectProvisioning
aclCheck: AclCheck
)(implicit baseUri: BaseUri, cr: RemoteContextResolution, ordering: JsonKeyOrdering): Route =
new IdentitiesRoutes(identities, aclCheck, projectProvisioning).routes
new IdentitiesRoutes(identities, aclCheck).routes
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import cats.effect.{Clock, IO}
import ch.epfl.bluebrain.nexus.delta.Main.pluginsMaxPriority
import ch.epfl.bluebrain.nexus.delta.config.AppConfig
import ch.epfl.bluebrain.nexus.delta.kernel.cache.CacheConfig
import ch.epfl.bluebrain.nexus.delta.kernel.http.HttpClient
import ch.epfl.bluebrain.nexus.delta.kernel.utils.ClasspathResourceLoader
import ch.epfl.bluebrain.nexus.delta.rdf.Vocabulary.contexts
import ch.epfl.bluebrain.nexus.delta.rdf.jsonld.context.{ContextValue, RemoteContextResolution}
Expand All @@ -12,10 +13,8 @@ import ch.epfl.bluebrain.nexus.delta.routes.IdentitiesRoutes
import ch.epfl.bluebrain.nexus.delta.sdk.PriorityRoute
import ch.epfl.bluebrain.nexus.delta.sdk.acls.AclCheck
import ch.epfl.bluebrain.nexus.delta.sdk.auth.{AuthTokenProvider, OpenIdAuthService}
import ch.epfl.bluebrain.nexus.delta.kernel.http.HttpClient
import ch.epfl.bluebrain.nexus.delta.sdk.identities.{Identities, IdentitiesImpl}
import ch.epfl.bluebrain.nexus.delta.sdk.model.BaseUri
import ch.epfl.bluebrain.nexus.delta.sdk.provisioning.ProjectProvisioning
import ch.epfl.bluebrain.nexus.delta.sdk.realms.Realms
import izumi.distage.model.definition.{Id, ModuleDef}

Expand Down Expand Up @@ -49,11 +48,10 @@ object IdentitiesModule extends ModuleDef {
(
identities: Identities,
aclCheck: AclCheck,
projectProvisioning: ProjectProvisioning,
baseUri: BaseUri,
cr: RemoteContextResolution @Id("aggregate"),
ordering: JsonKeyOrdering
) => new IdentitiesRoutes(identities, aclCheck, projectProvisioning)(baseUri, cr, ordering)
) => new IdentitiesRoutes(identities, aclCheck)(baseUri, cr, ordering)

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import ch.epfl.bluebrain.nexus.delta.rdf.jsonld.context.{ContextValue, RemoteCon
import ch.epfl.bluebrain.nexus.delta.rdf.utils.JsonKeyOrdering
import ch.epfl.bluebrain.nexus.delta.routes.ProjectsRoutes
import ch.epfl.bluebrain.nexus.delta.sdk._
import ch.epfl.bluebrain.nexus.delta.sdk.acls.{AclCheck, Acls}
import ch.epfl.bluebrain.nexus.delta.sdk.acls.AclCheck
import ch.epfl.bluebrain.nexus.delta.sdk.deletion.{ProjectDeletionCoordinator, ProjectDeletionTask}
import ch.epfl.bluebrain.nexus.delta.sdk.directives.DeltaSchemeDirectives
import ch.epfl.bluebrain.nexus.delta.sdk.fusion.FusionConfig
Expand All @@ -21,7 +21,6 @@ import ch.epfl.bluebrain.nexus.delta.sdk.organizations.FetchActiveOrganization
import ch.epfl.bluebrain.nexus.delta.sdk.projects._
import ch.epfl.bluebrain.nexus.delta.sdk.projects.job.ProjectHealthJob
import ch.epfl.bluebrain.nexus.delta.sdk.projects.model._
import ch.epfl.bluebrain.nexus.delta.sdk.provisioning.ProjectProvisioning
import ch.epfl.bluebrain.nexus.delta.sdk.quotas.Quotas
import ch.epfl.bluebrain.nexus.delta.sdk.sse.SseEncoder
import ch.epfl.bluebrain.nexus.delta.sourcing.Transactors
Expand Down Expand Up @@ -85,16 +84,6 @@ object ProjectsModule extends ModuleDef {
ProjectsStatistics(xas)
}

make[ProjectProvisioning].from {
(
acls: Acls,
projects: Projects,
config: AppConfig,
serviceAccount: ServiceAccount
) =>
ProjectProvisioning(acls, projects, config.automaticProvisioning, serviceAccount)
}

make[FetchContext].from { (mappings: ApiMappingsCollection, xas: Transactors, quotas: Quotas) =>
FetchContext(mappings.merge, xas, quotas)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,12 @@ import akka.http.scaladsl.model.StatusCodes
import akka.http.scaladsl.model.headers.{Accept, BasicHttpCredentials, OAuth2BearerToken}
import akka.http.scaladsl.server.Directives.handleExceptions
import akka.http.scaladsl.server.Route
import cats.effect.{IO, Ref}
import ch.epfl.bluebrain.nexus.delta.sdk.acls.AclSimpleCheck
import ch.epfl.bluebrain.nexus.delta.sdk.identities.IdentitiesDummy
import ch.epfl.bluebrain.nexus.delta.sdk.identities.model.Caller
import ch.epfl.bluebrain.nexus.delta.sdk.marshalling.RdfExceptionHandler
import ch.epfl.bluebrain.nexus.delta.sdk.provisioning.ProjectProvisioning
import ch.epfl.bluebrain.nexus.delta.sdk.utils.BaseRouteSpec
import ch.epfl.bluebrain.nexus.delta.sourcing.model.Identity
import ch.epfl.bluebrain.nexus.delta.sourcing.model.Identity.{Anonymous, Authenticated, Group, Subject}
import ch.epfl.bluebrain.nexus.delta.sourcing.model.Identity.{Anonymous, Authenticated, Group}

class IdentitiesRoutesSpec extends BaseRouteSpec {

Expand All @@ -23,45 +20,36 @@ class IdentitiesRoutesSpec extends BaseRouteSpec {

private val aclCheck = AclSimpleCheck().accepted

private val refSubjects = Ref.unsafe[IO, Set[Subject]](Set.empty[Subject])

private val projectProvisioning: ProjectProvisioning =
(subject: Identity.Subject) => refSubjects.update(_ + subject)

private val route = Route.seal(
handleExceptions(RdfExceptionHandler.apply) {
IdentitiesRoutes(identities, aclCheck, projectProvisioning)
IdentitiesRoutes(identities, aclCheck)
}
)

"The identity routes" should {
"return forbidden" in {
Get("/v1/identities") ~> addCredentials(OAuth2BearerToken("unknown")) ~> route ~> check {
status shouldEqual StatusCodes.Unauthorized
refSubjects.get.accepted shouldBe empty
}
}

"return unauthorized" in {
Get("/v1/identities") ~> addCredentials(BasicHttpCredentials("fail")) ~> route ~> check {
status shouldEqual StatusCodes.Unauthorized
refSubjects.get.accepted shouldBe empty
}
}

"return anonymous" in {
Get("/v1/identities") ~> Accept(`*/*`) ~> route ~> check {
status shouldEqual StatusCodes.OK
response.asJson should equalIgnoreArrayOrder(jsonContentOf("identities/anonymous.json"))
refSubjects.get.accepted should contain(Anonymous)
}
}

"return all identities" in {
Get("/v1/identities") ~> Accept(`*/*`) ~> addCredentials(OAuth2BearerToken("alice")) ~> route ~> check {
status shouldEqual StatusCodes.OK
response.asJson should equalIgnoreArrayOrder(jsonContentOf("identities/alice.json"))
refSubjects.get.accepted should contain(alice)
}
}
}
Expand Down

This file was deleted.

Loading

0 comments on commit 0207fe2

Please sign in to comment.