Skip to content

Commit

Permalink
Merge branch 'develop' into ID-804-new-tos-config-endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
Ghost-in-a-Jar committed Oct 25, 2023
2 parents bf94bae + fde245d commit 4aaabfc
Show file tree
Hide file tree
Showing 15 changed files with 415 additions and 385 deletions.
6 changes: 6 additions & 0 deletions .scalafmt.conf
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,9 @@ rewrite.rules = [
AsciiSortImports
PreferCurlyFors
]

fileOverride {
"glob:**/src/main/scala/org/broadinstitute/dsde/workbench/sam/api/**Routes*.scala" {
indentOperator.excludeRegex = "^.*~.*$"
}
}
6 changes: 3 additions & 3 deletions src/main/resources/swagger/api-docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1789,7 +1789,7 @@ paths:
patch:
tags:
- Resources
summary: Update the groups in the Auth Domain for a resource
summary: Add groups to the Auth Domain for a resource (removal of groups is not permitted)
operationId: patchAuthDomainV2
parameters:
- name: resourceTypeName
Expand Down Expand Up @@ -3196,7 +3196,7 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/TermsOfService'
$ref: '#/components/schemas/TermsOfServiceConfigResponse'
/version:
get:
tags:
Expand Down Expand Up @@ -3834,7 +3834,7 @@ components:
type: boolean
description: true if the user is in their proxy group
description: ""
TermsOfService:
TermsOfServiceConfigResponse:
required:
- enforced
- currentVersion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ trait AdminRoutes extends SecurityDirectives with SamRequestContextDirectives wi
pathPrefix("admin") {
adminUserRoutes(user, requestContext) ~ pathPrefix("v1") {
adminUserRoutes(user, requestContext) ~
adminResourcesRoutes(user, requestContext) ~
adminResourceTypesRoutes(user, requestContext)
adminResourcesRoutes(user, requestContext) ~
adminResourceTypesRoutes(user, requestContext)
} ~ pathPrefix("v2") {
asWorkbenchAdmin(user) {
adminUserRoutesV2(user, requestContext)
Expand All @@ -49,76 +49,76 @@ trait AdminRoutes extends SecurityDirectives with SamRequestContextDirectives wi
.map(status => (if (status.isDefined) OK else NotFound) -> status)
}
} ~
pathPrefix(Segment) { userId =>
pathEnd {
delete {
pathPrefix(Segment) { userId =>
pathEnd {
delete {
complete {
userService.deleteUser(WorkbenchUserId(userId), samRequestContext).map(_ => OK)
}
} ~
get {
complete {
userService
.getUserStatus(WorkbenchUserId(userId), samRequestContext = samRequestContext)
.map(status => (if (status.isDefined) OK else NotFound) -> status)
}
} ~
patch {
entity(as[AdminUpdateUserRequest]) { request =>
complete {
userService.deleteUser(WorkbenchUserId(userId), samRequestContext).map(_ => OK)
userService
.updateUserCrud(WorkbenchUserId(userId), request, samRequestContext)
.map(user => (if (user.isDefined) OK else NotFound) -> user)
}
} ~
get {
complete {
userService
.getUserStatus(WorkbenchUserId(userId), samRequestContext = samRequestContext)
.map(status => (if (status.isDefined) OK else NotFound) -> status)
}
} ~
patch {
entity(as[AdminUpdateUserRequest]) { request =>
complete {
userService
.updateUserCrud(WorkbenchUserId(userId), request, samRequestContext)
.map(user => (if (user.isDefined) OK else NotFound) -> user)
}
}
}
} ~
pathPrefix("enable") {
pathEndOrSingleSlash {
put {
complete {
userService
.enableUser(WorkbenchUserId(userId), samRequestContext)
.map(status => (if (status.isDefined) OK else NotFound) -> status)
}
}
}
}
} ~
pathPrefix("enable") {
pathEndOrSingleSlash {
put {
complete {
userService
.enableUser(WorkbenchUserId(userId), samRequestContext)
.map(status => (if (status.isDefined) OK else NotFound) -> status)
}
} ~
pathPrefix("disable") {
pathEndOrSingleSlash {
put {
complete {
userService
.disableUser(WorkbenchUserId(userId), samRequestContext)
.map(status => (if (status.isDefined) OK else NotFound) -> status)
}
}
}
}
} ~
pathPrefix("disable") {
pathEndOrSingleSlash {
put {
complete {
userService
.disableUser(WorkbenchUserId(userId), samRequestContext)
.map(status => (if (status.isDefined) OK else NotFound) -> status)
}
} ~
// This will get removed once ID-87 is resolved
pathPrefix("repairAllUsersGroup") {
pathEndOrSingleSlash {
put {
complete {
userService
.addToAllUsersGroup(WorkbenchUserId(userId), samRequestContext)
.map(_ => OK)
}
}
}
}
} ~
// This will get removed once ID-87 is resolved
pathPrefix("repairAllUsersGroup") {
pathEndOrSingleSlash {
put {
complete {
userService
.addToAllUsersGroup(WorkbenchUserId(userId), samRequestContext)
.map(_ => OK)
}
} ~
pathPrefix("petServiceAccount") {
path(Segment) { project =>
delete {
complete {
cloudExtensions
.deleteUserPetServiceAccount(WorkbenchUserId(userId), GoogleProject(project), samRequestContext)
.map(_ => NoContent)
}
}
}
}
} ~
pathPrefix("petServiceAccount") {
path(Segment) { project =>
delete {
complete {
cloudExtensions
.deleteUserPetServiceAccount(WorkbenchUserId(userId), GoogleProject(project), samRequestContext)
.map(_ => NoContent)
}
}
}
}
}
}
}

Expand Down Expand Up @@ -152,31 +152,31 @@ trait AdminRoutes extends SecurityDirectives with SamRequestContextDirectives wi
}
}
} ~
pathPrefix(Segment / "memberEmails" / Segment) { case (policyName, userEmail) =>
val policyId = FullyQualifiedPolicyId(resource, AccessPolicyName(policyName))
pathEndOrSingleSlash {
withSubject(WorkbenchEmail(userEmail), samRequestContext) { subject =>
put {
requireAdminResourceAction(adminAddMember, resourceType, user, samRequestContext) {
complete {
resourceService
.addSubjectToPolicy(policyId, subject, samRequestContext)
.as(NoContent)
}
pathPrefix(Segment / "memberEmails" / Segment) { case (policyName, userEmail) =>
val policyId = FullyQualifiedPolicyId(resource, AccessPolicyName(policyName))
pathEndOrSingleSlash {
withSubject(WorkbenchEmail(userEmail), samRequestContext) { subject =>
put {
requireAdminResourceAction(adminAddMember, resourceType, user, samRequestContext) {
complete {
resourceService
.addSubjectToPolicy(policyId, subject, samRequestContext)
.as(NoContent)
}
} ~
delete {
requireAdminResourceAction(adminRemoveMember, resourceType, user, samRequestContext) {
complete {
resourceService
.removeSubjectFromPolicy(policyId, subject, samRequestContext)
.as(NoContent)
}
}
}
} ~
delete {
requireAdminResourceAction(adminRemoveMember, resourceType, user, samRequestContext) {
complete {
resourceService
.removeSubjectFromPolicy(policyId, subject, samRequestContext)
.as(NoContent)
}
}
}
}
}
}
}
}

Expand All @@ -194,25 +194,25 @@ trait AdminRoutes extends SecurityDirectives with SamRequestContextDirectives wi
}
}
} ~
pathPrefix(Segment) { policyName =>
val policyId = FullyQualifiedPolicyId(resource, AccessPolicyName(policyName))
pathEndOrSingleSlash {
put {
entity(as[AccessPolicyMembershipRequest]) { membershipUpdate =>
withResourceType(resourceTypeAdminName) { resourceTypeAdmin =>
complete {
resourceService
.overwriteAdminPolicy(resourceTypeAdmin, policyId.accessPolicyName, policyId.resource, membershipUpdate, samRequestContext)
.as(Created)
}
pathPrefix(Segment) { policyName =>
val policyId = FullyQualifiedPolicyId(resource, AccessPolicyName(policyName))
pathEndOrSingleSlash {
put {
entity(as[AccessPolicyMembershipRequest]) { membershipUpdate =>
withResourceType(resourceTypeAdminName) { resourceTypeAdmin =>
complete {
resourceService
.overwriteAdminPolicy(resourceTypeAdmin, policyId.accessPolicyName, policyId.resource, membershipUpdate, samRequestContext)
.as(Created)
}
}
} ~
delete {
complete(resourceService.deletePolicy(policyId, samRequestContext).as(NoContent))
}
}
} ~
delete {
complete(resourceService.deletePolicy(policyId, samRequestContext).as(NoContent))
}
}
}
}
}
}
Expand Down
Loading

0 comments on commit 4aaabfc

Please sign in to comment.