Skip to content

Commit

Permalink
Fixes #23994: Some more missing change for user
Browse files Browse the repository at this point in the history
  • Loading branch information
fanf committed Jan 9, 2024
1 parent fc2d457 commit 088edcc
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ package com.normation.plugins.apiauthorizations

import better.files._
import com.normation.rudder.AuthorizationType
import com.normation.rudder.RudderAccount
import com.normation.rudder.User
import com.normation.rudder.UserService
import com.normation.rudder.api.ApiAccount
import com.normation.rudder.api.ApiAccountId
import com.normation.rudder.api.ApiAccountKind
Expand All @@ -15,6 +12,9 @@ import com.normation.rudder.api.ApiVersion
import com.normation.rudder.facts.nodes.NodeSecurityContext
import com.normation.rudder.rest.RestTestSetUp
import com.normation.rudder.rest.TraitTestApiFromYamlFiles
import com.normation.rudder.users.AuthenticatedUser
import com.normation.rudder.users.RudderAccount
import com.normation.rudder.users.UserService
import java.nio.file.Files
import net.liftweb.common.Loggable
import org.joda.time.DateTime
Expand Down Expand Up @@ -56,7 +56,7 @@ class UserApiTest extends Specification with TraitTestApiFromYamlFiles with Logg

val userService: UserService = new UserService {
// use an user that has access to the api, we do not test authorization checks in this file
val user1 = new User {
val user1 = new AuthenticatedUser {
val account = RudderAccount.Api(accounts(ApiAccountId("user1")))
def checkRights(auth: AuthorizationType) = true
def getApiAuthz = ApiAuthorization.RW
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@
package bootstrap.rudder.plugin

import bootstrap.liftweb.RudderConfig
import bootstrap.liftweb.UserAuthorisationLevel
import com.normation.plugins.PluginStatus
import com.normation.plugins.RudderPluginModule
import com.normation.plugins.usermanagement.CheckRudderPluginEnableImpl
import com.normation.plugins.usermanagement.UserManagementPluginDef
import com.normation.plugins.usermanagement.UserManagementService
import com.normation.plugins.usermanagement.api.UserManagementApiImpl
import com.normation.rudder.users.UserAuthorisationLevel

/*
* The user authorization level
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ import com.normation.rudder.api.ApiVersion
import com.normation.rudder.api.HttpAction.DELETE
import com.normation.rudder.api.HttpAction.GET
import com.normation.rudder.api.HttpAction.POST
import com.normation.rudder.facts.nodes.NodeSecurityContext
import com.normation.rudder.repository.json.DataExtractor.CompleteJson
import com.normation.rudder.rest._
import com.normation.rudder.rest.EndpointSchema.syntax._
Expand Down Expand Up @@ -208,7 +209,11 @@ class UserManagementApiImpl(
val file = userService.authConfig
val updatedUsers = users.map(u => {
file.users.get(u.id) match {
case None => (u.id, RudderUserDetail(RudderAccount.User(u.id, ""), u.status, Set(), ApiAuthorization.None))
case None =>
(
u.id,
RudderUserDetail(RudderAccount.User(u.id, ""), u.status, Set(), ApiAuthorization.None, NodeSecurityContext.None)
)
case Some(x) => (x.getUsername, x)
}
})
Expand Down Expand Up @@ -304,7 +309,7 @@ class UserManagementApiImpl(
implicit val action = "deleteUser"

val value: Box[JValue] = for {
_ <- userManagementService.remove(id, authzToken.actor).toBox
_ <- userManagementService.remove(id, authzToken.qc.actor).toBox
_ <- reload().toBox
} yield {
"username" -> id
Expand Down

0 comments on commit 088edcc

Please sign in to comment.