Hide jhipster config file or parameters from admin frontend - jhipster

We built a jhipster app, and like it, but its admin panel has all the configuration values available for all admins,is it a way to hide application-prod.yml or hide some values of it?

The configuration properties displayed in admin panel are exposed by /management/configprops endpoint which is implemented by Spring Boot Actuator.
Actuator can be configured in application*.yml to sanitize sensible values: https://docs.spring.io/spring-boot/docs/current/reference/html/howto.html#howto-sanitize-sensible-values

Related

Customizing Zuul url endpoints for services in JHipster

I have a group of microservices, called "client-Foo", where Foo is the name for some particular third-party client.
Using those names as-is creates some really ugly endpoint urls, so I want to translate them to a much nicer hierarchal form.
I added a custom PatternServiceRouteMapper that take the serviceId client-Foo and turns it into the url client/Foo.
This gives the url I want, but also breaks the service mapping because it also changes the registered serviceId to client/Foo; thus, when Zuul goes to route it fails because there is no client/Foo service, its id is client-Foo!
I cannot hardcode any paths because the application requires an arbitrary number of different "client-*" services.
By looking at ZuulProxyAutoConfiguration, you can see that you can replace some beans to achieve your goal and in particular you should consider providing your own implementation of RouteLocator interface or extend DiscoveryClientRouteLocator class.
Your service instances could also register in Eureka server with additional data in metadataMap that your RouteLocator could use.
I would simply add a configuration defined Zuul route :
zuul:
routes:
client-foo: /foo/**
Also I would advise against having a dash in a service-id as it can confuse the config server api (in /config/foo-profile.yml where profile is the spring profile for which you want to get the config).

Azure App Services - login to test page

I'm trying to login to the App Services test page so I can open the help page but I can't seem to find the login credentials anywhere. Any idea how can I log in? I used Mobile Services before where I can find this pretty easily: https://blogs.msdn.microsoft.com/musings_on_alm_and_software_development_processes/2014/10/23/azure-mobile-services-prompts-you-for-a-username-and-password/ but this article seems outdated for App Services.
That is the default configuration Home page. There is the .UseDefaultConfiguration() method invoked in the Startup.MobileApp.cs. The part of that is the AddMobileAppHomeController() which depends on the corresponding Microsoft.Azure.Mobile.Server.Controllers.HomeController reference. You may want to remove that from the configuration and add the configuration and the view that you want to see (i am not sure that MobileAppHomeController page you see can be customized). Reference

Mount Split gem dashboard within Rails_Admin

I have a Rails 4.2 app that uses rails_admin to manage CRUD actions for its models. It requires current_user.admin? == true for access.
I have just added A/B testing using the Split gem. I want to use the same authorization to allow admin only to view the split dashboard and thought the easiest way might be to create the route within the admin panel such that the dashboard would be available at example.com/admin/split.
I can mount the Split::Dashboard at 'admin/split' but that simply bypasses the admin authorization altogether.
Instead, I want to add a button/link with the rails_admin dashboard that redirects to admin/split where the dashboard is mounted within rails_admin.
Help appreciated.
split's webinterface is a sinatra app. It will not know anything about the rails_admin engine just by mounting it into the same url path. Check out the doc for the split interface https://github.com/splitrb/split#web-interface.
and https://steve.dynedge.co.uk/2011/12/09/controlling-access-to-routes-and-rack-apps-in-rails-3-with-devise-and-warden/
Rack::Auth::Basic will obviously not work for you, since it's basic http auth. So you have to use the second method by sticking you custom request middleware. The current_user will not be available there, since it's added by typical auth gems into the rails controllers. However if your lib is using warden for authentication ( like devise does), the info will be in request.env['warden']. Otherwise you will have to get the session id out the request.env["rack.session"]

Using API Apps with Swagger in dev/test/production environments

I'm migrating a combined Azure Website (with both Controllers and ApiControllers) to a split Web App and API App. Let's call it MyApp.
I've created MyAppDevApi, MyAppTestApi, and MyAppProductionApi API Apps (in different App Services) to host the three environments, expecting to promote code from one environment to another.
So far, I've only deployed to MyAppDevApi, since I'm just getting started.
When I do Add/Azure API App Client to my UI-only project to start referring to the API app, and I point it to MyAppDevApi, it uses AutoRest to create classes in my code. These classes now all have the name MyAppDevApi, rather than just MyAppApi, which is the actual namespace of the code I'm deploying to every environment. Obviously, I can't check that in... how can I promote that through Test and Prod?
There's nothing in the Swagger JSON that refers to this name, so it must be on the AutoRest side (I think).
Has anyone come up with a strategy or work-around to deal with this multiple-environment promotion issue with API Apps?
Edit
So far the best thing I've come up with is to download the Swagger from the API App to a local file (which, again, has only the namespace from the original code, not from the name of the API App), and then import it into the Web App. This will generate classes in the Web App that have the naming I expect.
The problem is that I then have to edit the generated MyAppApi.cs file's _baseUri property to pull from an AppSetting, have the different web.config.dev, .test, .prod, and then do the web.config transform. I mean, that'll work, but then every time I change the API App's interface, I'll regenerate... and then I'll have remember to change the _baseUri again... and someone, sometime is going to forget to do this and then deploy to production. It's really, really fragile.
So... anyone have a better idea?
I'm not quite sure why you're creating three different apps, one for each environment? One application is fine and use web.config transforms for each environment. This is the general way I do all of my apps and works fine.
Information about how to apply web.config transforms can be found here which may help in your situation.
Hope that helps.
Well, here's how I've solved this:
Download Swagger file from API App to local hard drive.
Import local Swagger file into Web App to generate classes that have the naming from my code, not from the environment.
Use AppSettings to specify the environment-specific settings to point to the API App. This can be either a web.config transform, or you can just specify them in the Azure Portal on the Web App in Application Settings.
Instantiate the generated API App Client using the constructor that takes in a URL to point to the API App (these are at class level, hence static):
private readonly static Uri apiAppUrl = new Uri(CloudConfigurationManager.GetSetting("ApiAppUrl"));
private readonly static MyAppApi myAppApi = new MyAppApi(apiAppUrl);
I'd still love a solution to this that doesn't require downloading the Swagger file, but, all in all, if that's the only workaround necessary, it's not all that bad.

Backbone.js & Node.js: Looking for a best practice for application settings

I'm building a web application based on backbone.js as the frontend and node.js as the backend.
I am looking for best practices on loading and saving the application settings/configuration a backbone/node environment. The idea is to allow an admin user to view/edit the settings, and of course these settings will silently be loaded when any user is accessing the application through the web.
I was thinking of creating a backbone model called 'settings', which will be loaded once the application starts. Then add a settings view where admins can view and edit at will. Not all the settings will be pre-loaded, only when the admin tried to access them (for eg. settings that are relevant for the backend will only be shown in the admin edit page, and not pre-loaded on application start)
Note: These settings will be saved in a MongoDB document.
How do you guys manage your web application settings/configurations?
Any data that is going to be accessible through the client and retrieved from your database should be represented by a backbone model. Your intuition of creating a 'settings' backbone model will allow you to display the data retrieved from your MongoDB backend. Then, when the settings are updated in your view, you can save the backbone model, which will in turn update the settings in your db.
Since you are dealing with settings/configurations that can affect your application, you just want to make sure that you do correct validation on anyone trying to access that specific page.

Resources