use of com.netflix.spinnaker.fiat.model.resources.Permissions in project fiat by spinnaker.
the class ApplicationResourcePermissionSource method getPermissions.
@Override
@Nonnull
public Permissions getPermissions(@Nonnull Application resource) {
Permissions storedPermissions = resource.getPermissions();
if (storedPermissions == null || !storedPermissions.isRestricted()) {
return Permissions.EMPTY;
}
Map<Authorization, Set<String>> authorizations = Arrays.stream(Authorization.values()).collect(toMap(identity(), storedPermissions::get));
// CREATE permissions are not allowed on the resource level.
authorizations.remove(Authorization.CREATE);
return Permissions.Builder.factory(authorizations).build();
}
use of com.netflix.spinnaker.fiat.model.resources.Permissions in project fiat by spinnaker.
the class DefaultApplicationResourceProvider method loadAll.
@Override
protected Set<Application> loadAll() throws ProviderException {
try {
List<Application> front50Applications = front50Service.getAllApplications();
List<Application> clouddriverApplications = clouddriverService.getApplications();
// Stream front50 first so that if there's a name collision, we'll keep that one instead of
// the clouddriver application (since front50 might have permissions stored on it, but the
// clouddriver version definitely won't)
List<Application> applications = Streams.concat(front50Applications.stream(), clouddriverApplications.stream()).filter(distinctByKey(a -> a.getName().toUpperCase())).collect(toImmutableList());
applications.forEach(application -> {
Permissions permissions = permissionProvider.getPermissions(application);
// Check to see if we need to fallback permissions to the configured fallback
application.setPermissions(executeFallbackPermissionsResolver.shouldResolve(permissions) ? executeFallbackPermissionsResolver.resolve(permissions) : permissions);
});
if (allowAccessToUnknownApplications) {
// unknown applications by default
return applications.stream().filter(a -> a.getPermissions().isRestricted()).collect(toImmutableSet());
} else {
return ImmutableSet.copyOf(applications);
}
} catch (RuntimeException e) {
throw new ProviderException(this.getClass(), e);
}
}
use of com.netflix.spinnaker.fiat.model.resources.Permissions in project fiat by spinnaker.
the class ChaosMonkeyApplicationResourcePermissionSource method getPermissions.
@Nonnull
@Override
public Permissions getPermissions(@Nonnull Application application) {
Permissions.Builder builder = new Permissions.Builder();
Permissions permissions = application.getPermissions();
if (permissions.isRestricted()) {
if (isChaosMonkeyEnabled(application)) {
builder.add(Authorization.READ, roles).add(Authorization.WRITE, roles).build();
}
}
return builder.build();
}
use of com.netflix.spinnaker.fiat.model.resources.Permissions in project front50 by spinnaker.
the class ApplicationPermissionsService method syncUsers.
private void syncUsers(Permission newPermission, Permission oldPermission) {
if (!fiatClientConfigurationProperties.isEnabled() || !fiatService.isPresent()) {
return;
}
// Specifically using an empty list here instead of null, because an empty list will update
// the anonymous user's app list.
Set<String> roles = new HashSet<>();
Optional.ofNullable(newPermission).ifPresent(newPerm -> {
Permissions permissions = newPerm.getPermissions();
if (permissions != null && permissions.isRestricted()) {
roles.addAll(permissions.allGroups());
}
});
Optional.ofNullable(oldPermission).ifPresent(oldPerm -> {
Permissions permissions = oldPerm.getPermissions();
if (permissions != null && permissions.isRestricted()) {
roles.addAll(permissions.allGroups());
}
});
if (fiatConfigurationProperties.getRoleSync().isEnabled()) {
try {
fiatService.get().sync(new ArrayList<>(roles));
} catch (RetrofitError e) {
log.warn("Error syncing users", e);
}
}
}
Aggregations