How to use Kerberos in a NodeJS server? - node.js

I need to migrate a .net kerberos application to a nodejs environment. The application currently takes an incoming request from a .net client and based on the domain and user within domain they are provided with a spgeno token if authenticated to use service. The client then uses this token for all requests to a webservice. I would like to replicate in nodejs however the modules are either poorly documented https://github.com/christkv/kerberos & https://github.com/auth0/kerberos-server or are focused on client side kerberos and not the server side usage. I don't know c++ otherwise I would write bindings to the c/c++ interface so I can call from javascript code. Does anyone have any suggestions on how to undertake migration? Are there any good resources or modules that can be used that will help me?

Related

How can i hide API Key in an Electron JS Project?

i'm working on an electron js app & i need to connect it to an API
knowing that the source code of an electron-js app is visible it's a huge security risk to leave the API key there !
how can i solve this problem ?
Instead of having the electron app (whether from the page or from the main process) make a request to the API directly, you can have it make a request to your own server instead - then, your server can make the request to the API, so that the key is only visible to your server, and isn't exposed publicly anywhere.
This will also let you gate requests from clients - if, for example, the credentials a client sends don't match what you need, or if they make too many requests in too short a time, you can cut them off.
You can't. If API key is shared, it's probably designed to be used in the backend.
The solution for that is to create a backend API for proxying API calls. Such proxying API should utilize authentication, so each user must send individual credentials.
How about obfuscate it using a utility like js-beautify.

Setting up a proxy server to make calls to API

I am access third party API from javascript framework but it gives me Access-Control-Allow-Origin. After going through API documentation they suggested to set up a proxy server to make calls to API behind the scenes
It is really understandable that at the time API call we are passing some confidential parameters which will revel in JavaScript as it is client side
I am using azure, so on that basis somebody can guide me how we can create proxy server to make calls to API
You can use the proxy feature in Azure Functions. It is really easy to get started with, an probably powerful enough to do what you need.
https://learn.microsoft.com/en-us/azure/azure-functions/functions-proxies

SMART on FHIR #asymmetrik/sof-strategy introspectionUrl workflow

I am looking for sample about Asymmetric SMART on FHIR. Can someone help where/how the introspectionUrl generated using #asymmetrik/sof-strategy?
The introspection url is part of an OAuth2 server that needs to be setup and configured by someone building the FHIR server. We use that module in both our repos (https://github.com/Asymmetrik/node-fhir-server-core, https://github.com/Asymmetrik/graphql-fhir), but it requires an external OAuth2 server. You can read a little more on that here, https://github.com/Asymmetrik/node-fhir-server-core/wiki/Access-Control#available-built-in-options, and here, http://hl7.org/fhir/smart-app-launch/.
If you are not integrating with someone else's SMART enabled OAuth2 server, you can check out projects like https://github.com/mitreid-connect/OpenID-Connect-Java-Spring-Server. We used this server for one of our demo server's in the past and it will give you the endpoint's you need for #asymmetrik/sof-strategy.

Secure REST APIs from non-browser client

I'm developing a web application using Java EE and some open source components (Spring, Struts 2, jQuery, and so on). Some of my web pages require authentication (Spring Security) and other not. I write some REST APIs (Restlet) and I use them from my pages by AJAX calls (jQuery). I know that other web sites can not use my REST APIs unless I enable CORS and this is what I want.
However any non-browser client (curl, Java applications, and so on) can call my REST APIs: how can I forbid this? I can not use authentication for all REST APIs because I use some of them in web pages that should not require authentication. I know that some APIs (like Facebook SDK) require an application-id in order to enable calls, but anyone can steal the key from the Javascript code included in my web pages.
I would like to recognize from the server side if an HTTP request has been sent from a browser or other client applications in order to apply some kind of authentication only in the second case. As I concern, any client application can set any HTTP header, so I can not HTTP headers, can I? I think that my problem should be a common problem, so maybe I miss something.
There's nothing you can do.
Most folks are worried about unauthorized users using their applications. You're worried about unauthorized programs.
Yet everything that a program needs to communicate with your server, it will be told (by the server as in a token, or by the user as in a credential).
Why are you afraid of "non-browser" clients? Why do you care what client they use? How is a non-browser client different than a normal browser for your use cases?
Answer that question, and you'll find better answers.
Are you afraid they'll "screen scrape" your site, quickly download it with something like wget? Then you can put in some server side rule gating their access (if IP x.y.z.w makes more than Q requests per BLEEM of time, then discard request/sleep 10s/send content REALLY slowly).
Those kinds of measures are what you have to do. You can't "secure" the client, it's not your client to secure. You have to secure your server, and address the concerns head on.
Remember rule #1 of client/server design: "Never trust the client". On the internet, no one knows you're a bot.

Securing a RESTful API

For my current side project, which is a modular web management system (which could contain modules for database management, cms, project management, resource management, time tracking, etc…), I want to expose the entire system as a RESTful API as I think that will make the system as more usable. The system itself is going to be coded in ASP.MET MVC3 however if I make all the data/actions available through a RESTful API, that should make the system very easy to use with PHP, Ruby, Python, etc… (they could even make there own interface to manage certain data if they wanted).
However, the one thing that seems hard to do easily (from the user's using the RESTful API point of view) with a RESTful API is security with ajax functionality. If I wanted something that was complex to setup and use, I would just create SOAP services but the whole drive for using a RESTful API is that it is very easy. The most common way of securing a RESTful API with with a key that is associated with a user. This works fine when all the calls are done on the server side however once you start doing ajax functionality, that changes. I would want the RESTful API to be able to be called directly from javascript however anyone who are firebug would easily be able to access the key the user is using allow that person access to the system. Is there a better way the secure a RESTful API where it does not make the user of the RESTful API do complex things just to set it up?
For one thing, you can't prevent the user of your API to not expose his key.
But, if you are writing a client for your API, I would suggest using your server side to do any requests to the API, while your HTML pages provide the data from the user. If you absolutely must use Javascript to make calls to the API and you still have a server side that populates the page in question, then you can obscure the actual key via a one-way digest algorithm in a timestamp-dependant way, while generating the page, and make it that your api checks that digest in a time-dependant way too.
Also, I'd suggest that you take a look into OAuth Nonces and timestamps a bit more deeply. Twitter and other API providers obviously have this problem too, so they must be doing something with the Nonce values.
It is possible to make some signature in request from javascript. But I'm hot sure, how 'RESTfull' urls would be with this extra info. And there you have the same problem: anyone who can see your making-signature-algorithm can make his own signature, witch you server will accept as well.
SSL stands for secure socket layer. It is crucial for security in REST API design. This will secure your API and make it less vulnerable to malicious attacks.
Other security measures you should take into consideration include: making the communication between server and client private and ensuring that anyone consuming the API doesn’t get more than what they request.
SSL certificates are not hard to load to a server and are available for free mostly during the first year. They are not expensive to buy in cases where they are not available for free.
The clear difference between the URL of a REST API that runs over SSL and the one which does not is the “s” in HTTP:
https :// mysite.com/posts runs on SSL.
http :// mysite.com/posts does not run on SSL.

Resources