Giter Club home page Giter Club logo

Comments (10)

mathieuprog avatar mathieuprog commented on September 27, 2024

For anyone who might need this, kinda obvious but in the meanwhile this can be done:

  plug :check_if_known_provider when action in [:request]
  plug Ueberauth

  @known_providers ~w(google)

  def check_if_known_provider(conn, _params) do
    provider = Map.fetch!(conn.params, "provider")

    if provider in @known_providers do
      conn
    else
      conn
      |> send_resp(400, "")
      |> halt()
    end
  end

from ueberauth.

yordis avatar yordis commented on September 27, 2024

I couldn't replicate the issue: #191

from ueberauth.

fuelen avatar fuelen commented on September 27, 2024

@yordis I think that's because all routes in the test router are defined explicitly, while we use this

scope "/auth", MyApp do
  pipe_through :browser

  get "/:provider", AuthController, :request
  get "/:provider/callback", AuthController, :callback
end

copied from ueberauth_google README

from ueberauth.

Hajto avatar Hajto commented on September 27, 2024

#193
Here is my proposed solution to the problem. It sets the error that can be handled in the the user callback and presets the status.

The question is:

  • Do we remove the status set?
  • Should we halt the connection?

This boils down to two solutions:

  • Should we leave this error to be handled by the user?
  • Should it always return 404?

Imo the visual way of handling this will depend on the application so I think I should remove the status and let the user handle the error however the library user wants.

from ueberauth.

fuelen avatar fuelen commented on September 27, 2024

I'd suggest raising an exception which implements Plug.Exception protocol, where the status is specified as 404.
In this case application will render a developer-defined error page.

from ueberauth.

Hajto avatar Hajto commented on September 27, 2024

That is a lovely idea, I will try to incorporate it.

from ueberauth.

Hajto avatar Hajto commented on September 27, 2024

image

from ueberauth.

Hajto avatar Hajto commented on September 27, 2024

I did push the proposal. Once it gets traction and gets approved I will write proper tests for this scenario.

from ueberauth.

fuelen avatar fuelen commented on September 27, 2024

@yordis sorry, but commit with the test you've merged doesn't solve the issue. It tests the following line

match(_, do: send_resp(conn, 404, "oops"))

and not the code I've mentioned above:

  get "/:provider", AuthController, :request

from ueberauth.

yordis avatar yordis commented on September 27, 2024

@fuelen I understand that it doesn't solve your problem, but that test failed with the changes that broke some people production code (which is the reason why I merged).

Another word, I am not proving that your situation is resolved.

from ueberauth.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.