-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ass a unrestricted endpoint to get a user's profile
Signed-off-by: David BRAQUART <[email protected]>
- Loading branch information
Showing
7 changed files
with
102 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
src/main/java/org/gridsuite/useradmin/server/service/AdminRightService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/** | ||
* Copyright (c) 2024, RTE (http://www.rte-france.com) | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
*/ | ||
package org.gridsuite.useradmin.server.service; | ||
|
||
import org.gridsuite.useradmin.server.UserAdminApplicationProps; | ||
import org.gridsuite.useradmin.server.UserAdminException; | ||
import org.springframework.stereotype.Service; | ||
|
||
import java.util.List; | ||
import java.util.Objects; | ||
|
||
import static org.gridsuite.useradmin.server.UserAdminException.Type.FORBIDDEN; | ||
|
||
/** | ||
* @author David Braquart <david.braquart at rte-france.com | ||
*/ | ||
@Service | ||
public class AdminRightService { | ||
|
||
private final UserAdminApplicationProps applicationProps; | ||
|
||
public AdminRightService(final UserAdminApplicationProps applicationProps) { | ||
this.applicationProps = Objects.requireNonNull(applicationProps); | ||
} | ||
|
||
public List<String> getAdmins() { | ||
return applicationProps.getAdmins(); | ||
} | ||
|
||
public boolean isAdmin(@lombok.NonNull String sub) { | ||
return this.getAdmins().contains(sub); | ||
} | ||
|
||
public void assertIsAdmin(@lombok.NonNull String sub) throws UserAdminException { | ||
if (!this.isAdmin(sub)) { | ||
throw new UserAdminException(FORBIDDEN); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,5 +14,5 @@ powsybl-ws: | |
|
||
useradmin: | ||
admins: | ||
# - admin1 | ||
- bdduser | ||
# - admin2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters