Shiro - How to represent an anonymous/guest user with permissions? - shiro

Our company is providing a service where a user can register and upload files. After login, a user can see access his uploaded files, upload more files, analyze them etc.
This works fine but we would also like to provide something like an anonymous/guest login, where users still can upload files but which are not accessible any more as soon as the session expires (after about 8 hours).
How would I implement something like that with Shiro? I know Shiro has the notion of an anonymous user but it seems I am not able to add permissions to him.

You can just create a real user for this (with user/pass guest/guest) and add the correct permissions to it.

Related

Google Drive API, download and get content files from a account server

So, i want to get all content in google drive. It only using one account, can we access it everytime in app without need to login it? How?
I also tried to read the documentation but still didn't find out
The only way I can think of right now is save the refresh token of an account on server side and every time an user uses the app give them a new access token.
This way it should suit your needs, one account no login.
Take a look at this for refresh token

How to get programmatic access a site that requires login without password?

Update: It appears that when there's no API or token, software seems to simply ask the user for their account credentials, and probably has to store this information. I guess it can't be a huge security risk, since people are willing to share this information with apps like Mint:
So, my conclusion is that it is OK to ask users for credentials to other services if they can be secured safely and the user desires the service provided.
Many, many apps use others apps such as Facebook in order to get data from it, usually to verify the user is real and to get relevant profile data (e.g. a dating app would want age, gender, etc.).
When using such an app, I do not have to enter in my Facebook credentials. The app simply opens up my Facebook/asks for permission to access it, and voila it's done.
There seems to be a lot of documentation for well known companies like Facebook, Twitter, and PayPal on how to do this.
But how is it done for an arbitrary website that requires a user/profile, e.g. this website: http://ae.com/web/index.jsp
Unsurprisingly, if I google for FaceBook, there's a heap of resources, and even it's own dedicated tag (https://developers.facebook.com/docs/facebook-login/access-tokens).
However, if I start googling for American Eagle, e.g. "https://www.google.com/search?client=safari&rls=en&q=american+eagle+access+token&ie=UTF-8&oe=UTF-8", I get nothing relevant at all.
If I understand your question right, that you want to enable facebook login for your website,
you still need to create a facebook app. then use the access tokens in your website. so when user clicks on login with facebook, the app will be asking for permissions and finally you will get the access token and you can use that in your site to log in.

how to get an access code when a facebook user is not involved

I am the owner of a facebook like page. I want to grab the news feed using php and output it on my website. I know that I can do this using a valid access token:
https://graph.facebook.com/my_app_id_here/feed?access_token=My_access_token_here
Problem access tokens expire so I know I need to authenticate periodically to get a new access token.
This is where the problem and confusion arises for me. When I read the authentication guide in the facebook dev docs all it talks about is first authenticating the user to get a authorization code from the user and then authenticating the app using the app secret, app id and auth code fromthe user. But this doesn't apply to my situation - I never have a authorization code form the user - all I'm trying to do is access the feed from a php script running on my server....a user is never involved.
Any ideas anyone?
User has to approve your application only once, and later use they can just access your app and use it without approving
Since you are the owner of the like page, I guess you are also the administrator. What you can do in this case is create an offline access token for this (and only for that) user.
You can then use this access token for your script. No user needs to authenticate anything if you only want to grab the feed of your page with the access token of your administrator.
This token never expires except for changing the user's password or taking away permissions again. Look at this answer to see how to create such an offline access token!
It seems offline_access is no longer available. Now you only get a short-lived access_token and you can ask for a long lived one, which is also renewable. You can't get a permanent one though.

username conflicts when allowing users to log in via facebook

I would like to allow visitors to my website to log in using Facebook as opposed to requiring them to register - which is accomplished easily enough with the information here:
https://developers.facebook.com/docs/guides/web/
However, I would also like to keep the option of registration open. In other words, when a user first visits, he has the option of either registering with me, OR simply logging in using facebook. A profile on my site is then created for them, and everything is wonderful.
My thoughts are, for facebookers, to use their facebook username. However, this might cause issues when someone whose facebook username is "foo" visits for the first time and logs in using facebook, if somebody else has already registered with the username "foo".
Has anybody else run into this issue? What's the best way to mitigate it? Should I just use facebook registration instead?
I randomly generate a username (UUID, actually) when they login using alternate auth (Facebook, Twitter or OpenID). You can then allow them to choose a username at a later point from a profile page.
If you want, you can flag auto-generated usernames, so they won't display, which would be confusing.
I also use the same process, but reversed, to allow logged in users to match up an external account when already logged in.

How to use Facebook connect to login in to my database?

I have a mysql membership database run by a Perl script. Account creation or login requires an email address and password. The Perl script then sets cookies (password cookie has encrypted value) which allow users to create, own and modify records. A members table contains user information. I've gone through the FacebookConnect information as well as the forum. Maybe I cannot see the forest for the trees, or maybe this is not possible. In order to use FacebookConnect for logins/account creation, I need to be able to send the user email and password to the the Perl script so that the proper cookies are set. If it were an http it would look like this:
http://domain.com/cgi-bin/perlscript.pl?_cgifunction=login&email=ddd#somedomain.com&password=somepassword.
Any hints or advice would be greatly appreciated.
What you are trying to do isn't really possible in the way that you're describing it.
Facebook Connect basically provides you with a single piece of information: whether your visitor is logged in to their Facebook account or not. If they are, you can get their Facebook ID, if not, you can show them a button (or whatever) and ask them to log into Facebook.
Generally a good approach when using Facebook Connect as an authentication method for your site is to have an internal id for the user's member account, and store a user's Facebook ID alongside that. When a user comes to your site, and they are already logged in to Facebook, you just use their Facebook ID to retrieve the local account. Otherwise you show them your login form to log in locally, and/or a Facebook login button.
The problem you're running into here is that you cannot get someone's email address from Facebook, as it is purposely hidden to protect privacy. If your membership scripts provide only the email/password log-in method, then what you need to do is modify these scripts to create the authentication cookie when given a properly authenticated Facebook ID.
Essentially you'll have two login functions... one for a Facebook login, and one for a regular login. Either function should properly created the local authentication cookie.