WIn32 api and storing login securely - winapi

I am creating a win32 application in C++. The user will need to login with username and password. These will be used to authenticate to a web server and then the application will communicate with the web server. I would like the user to only need to input credentials the first time opening the app by having the username and password saved somewhere. How should I accomplish this? I could just save it in some plaintext file. But it looks like from searches that there is something called DPAPI? I'm not sure what is appropriate for my use. This is my first time creating a win32 application.

Related

Create and return Github token from bash

The first time we run hub, it asks for our Github username and password. This is never stored. Instead, hub uses it to create a personal access token that gets saved in your account and then it uses that token for subsequent uses.
Is there a way to achieve the same from a bash script, without registering an application and all that?
This script will be public.
without registering an application
Not exactly, since it is part of the oauth workflow.
But from a simple shell, you can store your GitHub username and password in a credential helper like libsecret (Mac) or manager (Windows).
In that case, you won't have to enter said credentials again and you don't have to register anything directly on GitHub.

Parse.com validating user credentials every launch

On apps like twitter and snapchat, if you changed the password from the web, it wouldn’t allow you to get into the app without re-authenticating with the new password. When changing your password with Parse Open Source Framework, does it implement this functionality automatically on mobile or would the developer need to implement it themselves?
You have to do it by yourself. Check the following tutorial, section Handling an Invalidated Session:
https://parse.com/tutorials/integrating-facebook-in-android

Know windows username via WebScripting [duplicate]

I have a site which is built in ASP.net and C#. Let's call it webapp. it uses a Form system to log on into it, and cannot be changed easliy.
I got a request to change the log in to some kind of windows authentication. I'll explain.
Our windows login uses active directory for users to log into their windows account. their login name is sXXXXXXX. X are numbers.
in my webapp, I want to take the users numbers from their active directory login, and check if those exist in the webapp database. if it exists, they will automatically log in. If it doesn't, they will be referred to the regular login page for the webapp system which is currently in use.
I tried changing my IIS to disable anonymous login and enabling windows authentication, therefore making the user browser to send it's current logged in user name to my webapp. I changed the web config as well from "Forms" to "Windows", which made my whole webapp obsolete as the whole forms system did not work.
My question is this - is there a different way for the browser only to send the username to my webapp? I thought maybe javascript, I just don't know how to implement that, if it's even possible. I know it's not very secure, but all this platform and system is built outside the internet, it's on a private network.
<script language="javascript">
var username = '<%HttpContext.Current.User.Identity.Name %>';
</script>
The only way you could get at the user's domain credentials via javascript would be by deploying some type of ActiveX component to expose that data to the browser. I wouldn't recommend that.
I would look at implementing a Login page for forms authentication that authenticates the user on the page load using HttpContext.Current.User.
The way forms works is that if an unauthenticated user attempts to access an access-controlled page and have not logged in (no cookie), they will be redirected to a login page that gives the facility to log in (this sets a cookie on the client-side). The user is then directed to the page they initially requested. You would simply be automating the login part.
If you have a mixture of pass-through and user who need to manually login you could check their client IP address to see if it matches one on your domain or not.
The solution I found for getting the username sent to the server was:
string winlogon = Request.ServerVariables["LOGON_USER"];
After enabled Windows Authentication Mode in IIS.

How to read files from Dropbox on remote server using Ruby?

I want to run automated scripts to read files from a Dropbox folder on our server. I started looking into the dropbox gems that are out there, and they all seem to require the user to authenticate a session by opening a browser. This obviously doesn't make sense for an automated task. Is there a way to do this without requiring a user to actually open the browser manually?
The reason that they all require a web browser is that Dropbox uses OAuth v1. There is a way around this that may not be 100% in spirit with the Dropbox API T&C.
I would start by creating a Dropbox account that will be the user account you use from the scripts. Manually login as this user and go to the authorization URL for your app and approve it.
In your scripts you'll create an HTTP connection that uses that user id and password to login. You'll need to keep the information in the response that describes the user's session. Use the session information to create a second HTTP connection to the authorization URL. Since the app is already authorized, you'll just need to capture the session token from the redirect URL.
The definite downside to this is that the password for the user is in your script. :P

How to authenticate facebook command line app (Ruby)

I'm trying to build a simple ruby command line facebook client that will display all of the user's friends to the screen (fb_friends.rb) and I am using the fb_graph ruby gem: https://github.com/nov/fb_graph
The problem is, the method user.friends needs to have the user authenticate the application first.
I've read a similar question here: Ruby Command line application to update Facebook Status
And from what I understand, you cannot authenticate a user in the command line.
My question is: Is there any other way to authenticate the user?
What I'm thinking: On authentication, the default web browser of the user's system will pop out, then the user will grant access and authenticate, now the browser window will close and the user will return to the command line app and there he can see the list of his friends.
Is that possible?
Thanks
This isn't currently possible with Open Graph applications without sharing a server-side authentication token. Facebook requires you maintain control (and not share) your Applications authentication token. If a user were to abuse the command line application, and make a large number of requests to the server, using your app ID and token, you would be the one on the hook.
The best way to accomplish your goal is with a server under your control in between your command line application and the Facebook graph api. The command-line api could direct the user to your website where they would hit the "Facebook Connect" button. The user would authenticate the application with your server, and you could provide them with a token they could pair with their user ID to post status updates or retrieve friends through your server.
The command-line api would interact with your server, and your server with the Facebook Graph API.
A strong side benefit of this approach is that if Facebook's API changes, your clients would not break (no need to change your own server's API).

Resources