Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Logging in through MK AND SWB should not redirect to Publiclab #7121

Closed
Uzay-G opened this issue Jan 6, 2020 · 32 comments
Closed

Logging in through MK AND SWB should not redirect to Publiclab #7121

Uzay-G opened this issue Jan 6, 2020 · 32 comments
Labels
feature explains that the issue is to add a new feature

Comments

@Uzay-G
Copy link
Member

Uzay-G commented Jan 6, 2020

The authentication system for Mapknitter, Publiclab and Spectral Workbench are quite intertwined and I noticed that logging it to Mapknitter through oauth (at least Github) redirected to the publiclab dashboard instead of back to Mapknitter. Here's a video with the problem:

redirection-problem

Is there a way we could implement a redirect to the website we are currently on instead and do you find this useful? I would love to help! 👍

@Uzay-G Uzay-G added the feature explains that the issue is to add a new feature label Jan 6, 2020
@VladimirMikulic
Copy link
Contributor

I've thought of this issue too. It's annoying when you get redirected every time when you log in via Google/Github...

@Uzay-G
Copy link
Member Author

Uzay-G commented Jan 6, 2020

Yeah I totally agree.

@jywarren
Copy link
Member

jywarren commented Jan 6, 2020 via email

@SidharthBansal
Copy link
Member

Hi @Uzay-G I was referring to the same thing yesterday in your pr. We need a test to ensure correct behavior for MK and SWB(no redirect back to PL). Can you please add tests demonstrating it also?

@SidharthBansal SidharthBansal added this to the Login/SignUp & OAuth milestone Jan 7, 2020
@SidharthBansal
Copy link
Member

@jywarren there were some changes in May-July in plots2 due to which all 4 providers are redirecting back to MK and SWB. We are trying to rectify this on priority. I really appreciate your patience.

@SidharthBansal
Copy link
Member

SidharthBansal commented Jan 7, 2020 via email

@jywarren
Copy link
Member

jywarren commented Jan 7, 2020 via email

@SidharthBansal
Copy link
Member

I think this will be solved after #3367

@SidharthBansal
Copy link
Member

@Uzay-G please provide tests for MK and SWB

@SidharthBansal
Copy link
Member

If this issue still requires changes then please provide changes too

@Uzay-G
Copy link
Member Author

Uzay-G commented Jan 13, 2020

@Uzay-G please provide tests for MK and SWB

@SidharthBansal could you help me with this? I don't think it's possible to test logging in through Publiclab from MK or SWB

@SidharthBansal SidharthBansal changed the title Logging in through Mapknitter should not redirect to Publiclab Logging in through MK AND SWB should not redirect to Publiclab Jan 13, 2020
@SidharthBansal
Copy link
Member

Let's focus on completing login milestone asap. So, that we can start working on other projects like comments, stats too together

@SidharthBansal
Copy link
Member

You can take as much time as you want. Don't need to take tension.

@Uzay-G
Copy link
Member Author

Uzay-G commented Jan 13, 2020

Hey! I checked out the file and I was wondering what type of tests you wanted me to add. Do you want me to add tests for trying to log in with banned users and things like that?

@SidharthBansal
Copy link
Member

SidharthBansal commented Jan 13, 2020 via email

@Uzay-G
Copy link
Member Author

Uzay-G commented Jan 13, 2020

Yeah it does. I am looking at the example you sent and will try and code some tests 👍

@SidharthBansal
Copy link
Member

SidharthBansal commented Jan 13, 2020 via email

@Uzay-G
Copy link
Member Author

Uzay-G commented Jan 13, 2020

Hey! Don't some of these tests: https://github.com/publiclab/plots2/blob/d06f59460edf0424a6edbfc4000ac8444145fc5d/test/integration/openid_test.rb already do authentication requests from MK or SWB?

@SidharthBansal
Copy link
Member

SidharthBansal commented Jan 14, 2020 via email

@Uzay-G
Copy link
Member Author

Uzay-G commented Jan 15, 2020

All of the tests in the file are only for SWB, should I replicate them for MK?

@SidharthBansal
Copy link
Member

SidharthBansal commented Jan 15, 2020 via email

@Uzay-G
Copy link
Member Author

Uzay-G commented Jan 15, 2020

The tests are quite confusing... I have done the missing tests for MK based on what already existed for SWB but I am not sure what I can add and how I can test through the open_id. What other tests should I add to the files?

@SidharthBansal
Copy link
Member

SidharthBansal commented Jan 15, 2020 via email

@Uzay-G
Copy link
Member Author

Uzay-G commented Jan 15, 2020

Alright I will open the pull request 👍

@SidharthBansal
Copy link
Member

Now we can continue with other tests

@Uzay-G
Copy link
Member Author

Uzay-G commented Jan 15, 2020

What type of tests would you like me to add?

@SidharthBansal
Copy link
Member

SidharthBansal commented Jan 15, 2020 via email

@Uzay-G
Copy link
Member Author

Uzay-G commented Jan 15, 2020

Doesn't this one solve that:

test 'Mapknitter openid authentication request for Github Provider' do
# test using Github Provider button on MK or SWB
# log in
post '/user_sessions', params: { user_session: { username: users(:jeff).username, password: 'secretive' } }
follow_redirect!
get '/openid', params: {
'openid.claimed_id': "https://mapknitter.org/openid/#{users(:jeff).username}/github",
'openid.identity': "https://mapknitter.org/openid/#{users(:jeff).username}/github",
'openid.mode': 'checkid_setup',
'openid.ns': 'http://specs.openid.net/auth/2.0',
'openid.ns.sreg': 'http://openid.net/extensions/sreg/1.1',
'openid.realm': 'https://mapknitter.org/',
'openid.return_to': "https://mapknitter.org/session/new?authenticity_token=RcLcGH3lzSTCC24UpPnNm56sllNaMrHg5%2FSrQzNxB%2B4%3D&back_to=&open_id=#{users(:jeff).username}/github&return_to=",
'openid.sreg.required': 'nickname,email,fullname'
}
assert_nil flash[:error]
assert_response :found
assert_routing({ path: path, method: :get }, { controller: 'openid', action: 'index' })
## now same with POST
# More complete parameters:
# {"authenticity_token"=>"RcLcGH3lzSTCC24UpPnNm56sllNaMrHg5/SrQzNxB+4=", "back_to"=>"/", "open_id"=>"warren", "openid.assoc_handle"=>"{HMAC-SHA1}{5b1d5a10}{bGMKfQ==}", "openid.claimed_id"=>"http://localhost:3000/openid/warren", "openid.identity"=>"http://localhost:3000/openid/warren", "openid.mode"=>"check_authentication", "openid.ns"=>"http://specs.openid.net/auth/2.0", "openid.ns.sreg"=>"http://openid.net/extensions/sreg/1.1", "openid.op_endpoint"=>"http://localhost:3000/openid", "openid.response_nonce"=>"2018-06-10T17:04:16ZSTb7YI", "openid.return_to"=>"http://localhost:3001/session/new?authenticity_token=RcLcGH3lzSTCC24UpPnNm56sllNaMrHg5%2FSrQzNxB%2B4%3D&back_to=%2F&open_id=warren&return_to=%2F", "openid.sig"=>"cElPJYRTb7IDCsZe3eLx639cchg=", "openid.signed"=>"assoc_handle,claimed_id,identity,mode,ns,ns.sreg,op_endpoint,response_nonce,return_to,signed,sreg.email,sreg.nickname", "openid.sreg.email"=>"jeff@unterbahn.com", "openid.sreg.nickname"=>"warren", "return_to"=>"/"}
post '/openid?openid.claimed_id=' + users(:jeff).username, params: {
'openid.claimed_id': "https://mapknitter.org/openid/#{users(:jeff).username}/github",
'openid.identity': "https://mapknitter.org/openid/#{users(:jeff).username}/github",
'openid.mode': 'checkid_setup',
'openid.ns': 'http://specs.openid.net/auth/2.0',
'openid.ns.sreg': 'http://openid.net/extensions/sreg/1.1',
'openid.realm': 'https://mapknitter.org/',
'openid.return_to': "https://mapknitter.org/session/new?authenticity_token=RcLcGH3lzSTCC24UpPnNm56sllNaMrHg5%2FSrQzNxB%2B4%3D&back_to=&open_id=#{users(:jeff).username}/github&return_to=",
'openid.sreg.required': 'nickname,email,fullname'
}
assert_nil flash[:error]
assert_response :found
assert_routing({ path: path, method: :post }, { controller: 'openid', action: 'index' })
# Then, 'openid authentication approval goes to decision page' -- based on same session
# log in
post '/user_sessions', params: { user_session: { username: users(:jeff).username, password: 'secretive' } }
follow_redirect!
post '/openid/decision', params: {
"authenticity_token": "RcLcGH3lzSTCC24UpPnNm56sllNaMrHg5%2FSrQzNxB%2B4%3D",
"yes": "Yes"
}
# redirects back to originating site
assert_match /https:\/\/mapknitter.org\/session\/new/, @response.redirect_url
end

Maybe I am wrong. What do you think?

@SidharthBansal
Copy link
Member

Please abandon the current task. I think we can go to the system tests now

@SidharthBansal
Copy link
Member

Sorry I can't give points for this as it was already solved

@Uzay-G
Copy link
Member Author

Uzay-G commented Jan 15, 2020

Yeah no problem 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature explains that the issue is to add a new feature
Projects
None yet
Development

No branches or pull requests

4 participants