Skip to content
This repository has been archived by the owner on Jun 27, 2023. It is now read-only.

Redirecting to original URL #10

Open
jpoles1 opened this issue Oct 20, 2018 · 5 comments
Open

Redirecting to original URL #10

jpoles1 opened this issue Oct 20, 2018 · 5 comments

Comments

@jpoles1
Copy link

jpoles1 commented Oct 20, 2018

Hey, thanks for the great library, really nice to see a passport-like software for Golang.

I'm trying to use the Google authorization scheme, and I'd like to redirect my users to the page from which they started before being required to login. Google forbids any redirect URLs using wildcards and thus I cannot include my source URL in the redirect directly.

I've read that I should be able to include my source URL in the "state" which is returned, but I'm not certain that there's a way to go about doing so using Gocialite functions. Am I missing something? Thanks!

@danilopolani
Copy link
Owner

First of all, thank you!

I can see the issue, unfortunately I'll be busy in the next few weeks, but I hope to find time to figure out how to pass custom values in the state.

I'll keep you updated :)

@jpoles1
Copy link
Author

jpoles1 commented Oct 21, 2018

Excellent, thank you @danilopolani.

If you've got an approach in mind I can do my best to help out!

@jpoles1
Copy link
Author

jpoles1 commented Dec 6, 2018

@danilopolani any progress on this issue? Happy to help in whatever way I can, particularly if you can set me on the right path!

@jpoles1
Copy link
Author

jpoles1 commented Mar 14, 2019

@danilopolani any updates on this issue? If you have more info on how you had planned to solve this problem, I can try and work on a fix myself.

@danilopolani
Copy link
Owner

danilopolani commented Mar 26, 2019

Hello @jpoles1 ,
sorry for my delay in the answers, unfortunately I'm in a very busy time due to my new work and some personal stuff and I'm unable to steadily follow this project.

Since in Dispatcher.Handler() we do not return the Gocial instance (where we could put the redirect URL), adding it to response would be a breaking change. Nothing impossible, I can create a v2.0 with some other stuff, but requires time.

For the moment what about storing the URL / parameters in a cookie? Not the best solution, but it could work, with Gin you can achieve it with SetCookie.

In the next version I would add a params (name to choose) map which will be a [string]interface{} in the Gocial struct where you can save whatever you want, so when you can handle callback you can do:

// Handle callback and check for errors
user, token, params, err := gocial.Handle(state, code)
if err != nil {
	c.Writer.Write([]byte("Error: " + err.Error()))
	return
}

redirectURL := params["redirect"].(string)

What do you think about it?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants