Skip to content

Commit

Permalink
refactor(retrofit2): refactor the code to align with the retrofit2 up…
Browse files Browse the repository at this point in the history
…grade of fiat-api
  • Loading branch information
kirangodishala committed Dec 9, 2024
1 parent 56feaa9 commit a383ae3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import com.netflix.spinnaker.fiat.shared.FiatPermissionEvaluator;
import com.netflix.spinnaker.fiat.shared.FiatService;
import com.netflix.spinnaker.fiat.shared.FiatStatus;
import com.netflix.spinnaker.kork.retrofit.Retrofit2SyncCall;
import com.netflix.spinnaker.security.AuthenticatedRequest;
import io.micrometer.core.annotation.Counted;
import java.util.Collection;
Expand Down Expand Up @@ -59,7 +60,7 @@ public Collection<? extends GrantedAuthority> login(String userid) {

return AuthenticatedRequest.allowAnonymous(
() -> {
getFiatServiceForLogin().loginUser(userid, "");
Retrofit2SyncCall.execute(getFiatServiceForLogin().loginUser(userid));
return resolveAuthorities(userid);
});
}
Expand All @@ -73,7 +74,7 @@ public Collection<? extends GrantedAuthority> loginWithRoles(

return AuthenticatedRequest.allowAnonymous(
() -> {
getFiatServiceForLogin().loginWithRoles(userid, roles);
Retrofit2SyncCall.execute(getFiatServiceForLogin().loginWithRoles(userid, roles));
return resolveAuthorities(userid);
});
}
Expand All @@ -84,7 +85,7 @@ public void logout(String userid) {
return;
}

getFiatServiceForLogin().logoutUser(userid);
Retrofit2SyncCall.execute(getFiatServiceForLogin().logoutUser(userid));
permissionEvaluator.invalidatePermission(userid);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import com.netflix.spinnaker.kork.core.RetrySupport;
import com.netflix.spinnaker.kork.exceptions.SpinnakerException;
import com.netflix.spinnaker.kork.exceptions.SystemException;
import com.netflix.spinnaker.kork.retrofit.Retrofit2SyncCall;
import com.netflix.spinnaker.kork.retrofit.exceptions.SpinnakerHttpException;
import com.netflix.spinnaker.kork.retrofit.exceptions.SpinnakerServerException;
import com.netflix.spinnaker.security.AuthenticatedRequest;
Expand Down Expand Up @@ -78,9 +79,7 @@ public void login(final String userId) {
try {
AuthenticatedRequest.allowAnonymous(
() -> {
// TODO(jvz): FiatService::loginUser should have only one parameter as Retrofit no
// longer requires this body parameter
getFiatServiceForLogin().loginUser(userId, "");
Retrofit2SyncCall.execute(getFiatServiceForLogin().loginUser(userId));
permissionEvaluator.invalidatePermission(userId);
return null;
});
Expand All @@ -95,7 +94,7 @@ public void loginWithRoles(final String userId, final Collection<String> roles)
try {
AuthenticatedRequest.allowAnonymous(
() -> {
getFiatServiceForLogin().loginWithRoles(userId, roles);
Retrofit2SyncCall.execute(getFiatServiceForLogin().loginWithRoles(userId, roles));
permissionEvaluator.invalidatePermission(userId);
return null;
});
Expand All @@ -108,7 +107,7 @@ public void loginWithRoles(final String userId, final Collection<String> roles)
public void logout(String userId) {
if (fiatStatus.isEnabled()) {
try {
getFiatServiceForLogin().logoutUser(userId);
Retrofit2SyncCall.execute(getFiatServiceForLogin().logoutUser(userId));
permissionEvaluator.invalidatePermission(userId);
} catch (SpinnakerServerException e) {
throw UpstreamBadRequest.classifyError(e);
Expand All @@ -119,7 +118,7 @@ public void logout(String userId) {
public void sync() {
if (fiatStatus.isEnabled()) {
try {
getFiatServiceForLogin().sync(List.of());
Retrofit2SyncCall.execute(getFiatServiceForLogin().sync(List.of()));
} catch (SpinnakerServerException e) {
throw UpstreamBadRequest.classifyError(e);
}
Expand Down

0 comments on commit a383ae3

Please sign in to comment.