Closed dwelch2344 closed 9 years ago
I'm interested. I followed a similar approach and have also implemented it in a generated app as well. Were you able to get the Spring Social login to work when using OAuth2? I had a bit of trouble there and only have it working with cookie-based authentication.
If there's any interest from the JHipster team I'm between projects at work right now and have the time to work on it this week. I have this mostly working with Google and Facebook in my own app but have not yet done the work to edit the yeoman generator.
If there is any interest, there's a few things that I could use some input on:
I'd be happy to share an example of what I have so far and revise as necessary to incorporate social login into the project. David, you mentioned that you've also done this. If you're still interested perhaps we could work together on it.
+1
@jcr216 of course there is interest! As this is an option in the generator (with the cookie-based and OAuth2 options), this does not have big consequences on the rest of the codebase, which is of course the best for us. So to answer your questions in order:
If you have questions, anything, please add them to this thread or ping me by mail (firstname.lastname@gmail.com).
Sorry, been a hectic week. I'd be happy to collaborate on it!
Some thoughts:
I'm hoping to start work on a reference app this weekend. Would be happy to share.
Great, but there is no need for a sub generator: if the user selects "social login" you prompt him a new multiple choice question, with twitter, facebook, etc But first finish your reference app, then we'll see how best to transform it into a template
Ok I have a very rough version of this working. It supports login and registration using Google and Facebook. The fork is here. To run the app:
Regarding #2, you need to register an application with Google and Facebook (see the comments in the YML file). You also need to add http://localhost:8080 as an authorized redirection source. In case anyone wants to test this out without going through the required Google/Facebook setup, send me an email (my Github username at gmail dot com) and I'll share client ids/secrets that you can plugin to your YML.
Per Julien's suggestion, I did the work in the form of an updated sample rather than modify the templates. Per David's suggestion, I modeled the external accounts as a one-to-many to allow multiple external accounts to be associated with a single internal account (see T_EXTERNAL_ACCOUNT table.
A few things to note:
David, it sounds like you have some interesting ideas. You also have it working with the OAuth2 token based stuff whereas mine only works with session based logins. Feel free to use what I started and make massive changes. I spent longer than I'd care to admit screwing around with Spring Security. If you're in the same boat hopefully my work will give you a jumpstart. If you just want to start your own thing that's cool too.
@jcr216 you probably want to take your secret keys out of the repo, and/or change them! Sorry for telling you through a message thread, but I don't know how else to reach you. Thanks for all the great work!
D'oh! Thanks for the heads up. Totally forgot about that before I committed last night.
On Wed, Nov 5, 2014 at 9:27 AM, John Becker notifications@github.com wrote:
@jcr216 https://github.com/jcr216 you probably want to take your secret keys out of the repo, and/or change them! Sorry for telling you through a message thread, but I don't know how else to reach you. Thanks for all the great work!
— Reply to this email directly or view it on GitHub https://github.com/jhipster/generator-jhipster/issues/684#issuecomment-61814101 .
Besides accidently sharing my client secrets with the entire world last night, this is moving along well. Screenshots are available here.
Here's where the code is:
If anyone is interested in helping, here's what's left:
Mongo support: https://github.com/jcr216/jhipster-sample-app/tree/mongo
How to get user birthday via facebook/google using spring social class org.springframework.social.connect.UserProfile?
Long time no news. Will you intergrate this feature in jhipster? I would really appreciate it!
:+1:
@MartinLichtblau I would love to integrate it, but it's not finished yet (as far as I understand), and then the integration process can be quite long. So don't expect this for too soon! @jcr216 are you still working on this?
Hopefully @jcr216 replies :+1:
Here are two helpful webpages on the topic: UpToDate tutorial about spring Social with MVC HowTo define localhost as valid domain name P.S.: I tried your fork and it worked!
I just found out that facebook will shutdown Graph API v.1 in April 2015 and use their new v.2 instead. Spring Social is still working on a new version. But I tried the pre-version and your authentication still works.
I was a bit busy with the holidays and whatnot. I'm working on this again today.
I have the backend changes merged into the generator: https://github.com/jcr216/generator-jhipster. It compiles and runs and I can confirm that I didn't break the existing login system.
I need to make some changes to the frontend code given that the frontend has been reorganized since I originally wrote the social auth stuff.
I've finished adding the social changes to the generator. At this point, it's functional and builds an app that works out of the box with Google. The code for Facebook is there and was working in my modified sample app, I just haven't had a chance to test it after incorporating it into the generator.
There are still a few minor issues to resolve, but this is pretty close to becoming a pull request. If anyone has the time to test my changes that would be helpful.
I can put some time for testing. please let me know the repo or steps
I also have interest in this, and will find time to test in the next few days.
@svennela the repo is https://github.com/jcr216/generator-jhipster
Hi Peter,
how do i start? do you have any steps? or check list? please help with starting, will take it from their.
First clone the repo. After you've cloned the repo, use npm link
to replace the default generator with my version. Run yo jhipster
and select cookie based auth and at least one social provider. Next, add your client id and secret in application.ym. Finally, do mvn -DskipTests spring-boot:run
on the new application to fire it up.
Not sure why the tests are failing. I was getting something like "metric already registered" when I tried to run the tests (which is not at all related to the changes that I made).
I am able to link your repo but running into
when I did yo jhipster
Error: Cannot find module 'underscore'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.
Run npm install underscore
in your generator-jhipster directory
Thank you. I am creating appid in facebook. Do you know what is the call back URL?
A quick update. I spent some time on this last night. When I generated using cookie auth, SQL, mvn, grunt, java 8 the application starts without error and gives me the Buttons for Google and Facebook login. Unfortunately, I have something misconfigured currently at both providers.
With Google I need to register localhost as a redirect URI, but haven't found where to configure it on Googles site, and when clicking the Facebook button it sends me to http://localhost:8080/auth/facebook?scope=public_profile,email, which returns a 404.
I also generated a project using cookie auth, NoSQL, mvn, grunt and java 8, upon running it with mvn -DskipTests spring-boot:run I received the error below, setUser() is missing, but I have not attempted to debug it beyond that yet. Is mongo expected to work on this branch?
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project jhipster: Compilation failure
[ERROR]
.../src/main/java/com/mycompany/myapp/service/UserService.java:[86,28] cannot find symbol
[ERROR] symbol: method setUser(com.mycompany.myapp.domain.User)
[ERROR] location: variable externalAccount of type com.mycompany.myapp.domain.ExternalAccount
I'll continue looking at it tonight.
Did you setup the facebook graph api like mentioned here?
I think you'll need to set up an alias for local host in your /etc/hosts file for a fake domain and set up that domain in Facebook et al. Facebook doesn't let you use localhost.
On Jan 8, 2015, at 11:16 AM, Peter Eltgroth notifications@github.com wrote:
A quick update. I spent some time on this last night. When I generated using cookie auth, SQL, mvn, grunt, java 8 the application starts without error and gives me the Buttons for Google and Facebook login. Unfortunately, I have something misconfigured currently at both providers.
With Google I need to register localhost as a redirect URI, but haven't found where to configure it on Googles site, and when clicking the Facebook button it sends me to http://localhost:8080/auth/facebook?scope=public_profile,email, which returns a 404.
I also generated a project using cookie auth, NoSQL, mvn, grunt and java 8, upon running it with mvn -DskipTests spring-boot:run I received the error below, setUser() is missing, but I have not attempted to debug it beyond that yet. Is mongo expected to work on this branch?
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project jhipster: Compilation failure [ERROR] .../src/main/java/com/mycompany/myapp/service/UserService.java:[86,28] cannot find symbol [ERROR] symbol: method setUser(com.mycompany.myapp.domain.User) [ERROR] location: variable externalAccount of type com.mycompany.myapp.domain.ExternalAccount I'll continue looking at it tonight.
— Reply to this email directly or view it on GitHub.
I am new in the project. I am interested by the project. I've tried to test. I've followed instruction as suggested by jcr216. I did :
The error happens in the Class : UserRepository. The import of ExternalAccountProvider contains a strange package with does not exist.
import com.mycompany.myapp.domain.ExternalAccountProvider; import com.daytech.recrut.domain.User;
import org.joda.time.DateTime; import org.springframework.data.jpa.repository.JpaRepository; import java.util.Optional; import org.springframework.data.jpa.repository.Query;
import java.util.List; import java.util.Optional;
/**
@MartinLichtblau thanks for the link, I have set it up that way, and tried a few additional variations, but it is still not working.
@jjb3rd Facebook let me save localhost in App Domains (localhost), Site Url (http://localhost:8080/), and Valid OAuth redirect URIs (http://localhost:8080/). Do you know if this is a recent change? Or do they let you save localhost, but it will not work (which would be bad form on their part)?
@jcr216 Any suggestions on the Facebook config?
For Google, I have the Identity Toolkit API enabled, created a Client ID for web application with a Redirect URI of http://localhost:8080/auth/google, and configured the Consent Screen with my email and a Product Name of jhipster. After doing so, I:
and I get: Registration failed! Please try again later.
Per the logs below, it appears AccountResource.registerAccount() and UserService.createUserInformation() need refactoring to handle nulls in most of the fields (or perhaps I'm not getting as much information back from Google as expected). I'll take a crack at refactoring it in the next few days, unless you or someone else beats me to it.
[DEBUG] com.mycompany.myapp.aop.logging.LoggingAspect - Enter: com.mycompany.myapp.web.rest.AccountResource.registerAccount() with argument[s] = [UserDTO{login='peter', password='null', firstName='null', lastName='null', email='null', langKey='en', roles=null, externalAccounts=[]}, SecurityContextHolderAwareRequestWrapper[ org.springframework.security.web.context.HttpSessionSecurityContextRepository$Servlet3SaveToSessionRequestWrapper@49c4444f]]
[ERROR] com.mycompany.myapp.aop.logging.LoggingAspect - Exception in com.mycompany.myapp.web.rest.AccountResource.registerAccount() with cause = null
java.lang.NullPointerException: null
at com.mycompany.myapp.web.rest.AccountResource.registerAccount(AccountResource.java:205) ~[classes/:na]
at com.mycompany.myapp.web.rest.AccountResource$$FastClassBySpringCGLIB$$bb2cce5e.invoke(<generated>) ~[spring-core-4.1.3.RELEASE.jar:na]
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204) ~[spring-core-4.1.3.RELEASE.jar:4.1.3.RELEASE]
...
Becasue you can't login before you have activated, you have to define an smtp mail server in you .dev.yml which sends the activation mail. For gmail you have to activate IMAP or POP in email acc settings. And enable access for non-gmail apps. (I would prefer that users can directly login when the login with a social provider and just receive a mail notification.)
mail:
host: smtp.gmail.com
port: 587
user: user@gmail.com
password: 123pwnot
protocol: smtp
tls: true
auth: true
from: user@gmail.com
[INFO] Compiling 90 source files to C:\Programming\jhipster\jhip-social\target\classes [WARNING] /C:/Programming/jhipster/jhip-social/src/main/java/com/mycompany/myapp/config/SecurityConfiguration.java: C:\Programming\jhipster\jhip-social\src\main\java\com\mycompany\myapp\config\SecurityConfiguration.java uses unchecked or unsafe operations. [WARNING] /C:/Programming/jhipster/jhip-social/src/main/java/com/mycompany/myapp/config/SecurityConfiguration.java: Recompile with -Xlint:unchecked for details.
Not sure...when I tried to use localhost:8080 Facebook balked and said it had to be a fully qualified domain name...hence me tricking it with the /etc/hosts file. This was a little over a month ago and I thought it was a new policy at the time, but maybe they've relaxed it a bit.
On Jan 9, 2015, at 2:57 AM, Peter Eltgroth notifications@github.com wrote:
@MartinLichtblau thanks for the link, I have set it up that way, and tried a few additional variations, but it is still not working.
@jjb3rd Facebook let me save localhost in App Domains (localhost), Site Url (http://localhost:8080/), and Valid OAuth redirect URIs (http://localhost:8080/). Do you know if this is a recent change? Or do they let you save localhost, but it will not work (which would be bad form on their part)?
@jcr216 Any suggestions on the Facebook config?
For Google, I have the Identity Toolkit API enabled, created a Client ID for web application with a Redirect URI of http://localhost:8080/auth/google, and configured the Consent Screen with my email and a Product Name of jhipster. After doing so, I:
Click on the SIgn in with Google button Select my Google account Agree to the consent screen Enter 'peter' as a Login name on a Registration page and I get: Registration failed! Please try again later.
Per the logs below, it appears AccountResource.registerAccount() and UserService.createUserInformation() need refactoring to handle nulls in most of the fields (or perhaps I'm not getting as much information back from Google as expected). I'll take a crack at refactoring it in the next few days, unless you or someone else beats me to it.
[DEBUG] com.mycompany.myapp.aop.logging.LoggingAspect - Enter: com.mycompany.myapp.web.rest.AccountResource.registerAccount() with argument[s] = [UserDTO{login='peter', password='null', firstName='null', lastName='null', email='null', langKey='en', roles=null, externalAccounts=[]}, SecurityContextHolderAwareRequestWrapper[ org.springframework.security.web.context.HttpSessionSecurityContextRepository$Servlet3SaveToSessionRequestWrapper@49c4444f]] [ERROR] com.mycompany.myapp.aop.logging.LoggingAspect - Exception in com.mycompany.myapp.web.rest.AccountResource.registerAccount() with cause = null java.lang.NullPointerException: null at com.mycompany.myapp.web.rest.AccountResource.registerAccount(AccountResource.java:205) ~[classes/:na] at com.mycompany.myapp.web.rest.AccountResource$$FastClassBySpringCGLIB$$bb2cce5e.invoke(
) ~[spring-core-4.1.3.RELEASE.jar:na] at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204) ~[spring-core-4.1.3.RELEASE.jar:4.1.3.RELEASE] ... — Reply to this email directly or view it on GitHub.
I have run the application with the default configuration package com.mycompany.myapp. I want just to let you know that i think there is a problem when we change the package com.mycompanny.myapp when this is proposed to us in command line interface. If we change the package name, ExternalAccountProvider.java will not have the correct package in it. Could you tell me where to configure the facebookAppId and secret ?
@davykiala application.yml
FYI: I haven't gotten this working yet, but have had little time in the last week. I will get back to it as soon as I can, but don't know exactly when that will be.
I'am also interesting in this feature. Is anyone working on this ? Thanks
Sorry, still on my list, but swamped at work and home. Please join the effort, the posts above detail where I left off an and suggestions on how to get get beyond my state.
I want to integrate social login as you explain in project generated by jhipster 2.1.1. Which authentication option i have to choose. ❯ HTTP Session Authentication (stateful, default Spring Security mechanism) OAuth2 Authentication (stateless, with an OAuth2 server implementation) Token-based authentication (stateless, with a token)
I think it is OAuth2 Authentication (stateless, with OAuth2 server implementation). Is this suitable for an mobile client app ? I am creating a POC with a Jhipster project with login with social and want to create the mobile app client with ionic.
Hello, i am currently working on an implemetation of OpenId-Connect Authentication, since we would like a single-sign-on approach,but using facebook/google/etc. accounts for our company-internal applications is not an option. I did use some parts of this fork, especially the database part. I have it up and running, and would like to share my work. The question is - shall i create an entire new fork of jhipster ? I am pretty new to github ;-)
Here is a Sample-JHipster App https://github.com/iceman91176/jhipster-oidc-sample
Generator is also available -> https://github.com/iceman91176/generator-jhipster
Don't they all use OAuth2 now?
On Mar 3, 2015, at 2:46 AM, iceman91176 notifications@github.com wrote:
Hello, i am currently working on an implemetation of OpenId-Connect Authentication, since we would like a single-sign-on approach,but using facebook/google/etc. accounts for our company-internal applications is not an option. I did use some parts of this fork, especially the database part. I have it up and running, and would like to share my work. The question is - shall i create an entire new fork of jhipster ? I am pretty new to github ;-)
— Reply to this email directly or view it on GitHub.
More or less, yes. It probably could have been done with a spring-social extension for WSO2 identity server. But sice the authentication-stuff had been done before by us, it was easier to integrate it, than creating a new extension.
I'm closing this ticket as the work that has been done is not possible to merge, and as no work as been done for a long time. I'd love to merge this, so if anybody wants to implement this, feel free to open up a new ticket.
I was thinking of adapting the approach in the following article and adding it to the build process. I'm currently implementing it in a generated app at the moment. I haven't done much with Yeoman generators before, but if there's interest I'd be happy to contribute it.
http://www.petrikainulainen.net/programming/spring-framework/adding-social-sign-in-to-a-spring-mvc-web-application-configuration/