Comments (5)
👍
from ueberauth.
The Ueberauth.Strategy has a different role than what this module provides, this module is constructing the route matching.
I've seen quite a few pubs that provide a macro to setup routes. I'll catch up with @scrogson and see what options we can rustle up
from ueberauth.
In either case, the generated module should be one that the user explicitly defines, then they plug that in the router
from ueberauth.
For example, it seems the entire code generation could be a normal UeberAuth
plug module, which accepts options from the plug, i.e.:
defmodule UeberAuth do
def init(opts) do
opts = Application.get_env(:ueberauth, Ueberauth)
parts = Enum.map(opts[:providers], fn { name, { strategy, options } } ->
request_path = Dict.get(options, :request_path, Path.join(["/", base_path, to_string(name)]))
callback_path = Dict.get(options, :callback_path, Path.join(["/", base_path, to_string(name), "callback"]))
methods = Dict.get(options, :callback_methods, ["GET"]) |> Enum.map(&(String.upcase(to_string(&1))))
%{
strategy_name: name,
strategy: strategy,
callback_path: callback_path,
request_path: request_path,
callback_methods: methods,
options: options
}
end
def call(conn, opts), do: run!(conn, opts[:base_path], opts[:callback_path], opts)
defp run!(%Conn{path_info: [base_path | _]}, base_path, _callback_path, opts) do
conn
|> Plug.Conn.put_private(:ueberauth_request_options, opts)
|> Strategy.run_request(opts[:strategy])
end
defp run!(%Plug.Conn{path_info: [cb_path | _]} = conn, _base, cb_path, opts) do
if conn.method in opts[:callback_methods] do
conn
|> Plug.Conn.put_private(:ueberauth_request_options, opts)
|> Strategy.run_callback(opts[:strategy])
else
conn
end
end
defp run!(conn, _), do: conn # if we don't match anything just fall through
end
from ueberauth.
Thanks for the feedback @chrismccord.
from ueberauth.
Related Issues (20)
- nil given for :email. Comparison with nil is forbidden as it is unsafe. Instead write a query with is_nil/1, for example: is_nil(s.email) HOT 1
- OAuth2 needs new maintainers HOT 4
- State nonce cookie should properly be signed HOT 2
- How can run Ueberauth plug directly? HOT 3
- Custom `callback_port` and `callback_scheme` not used HOT 1
- Callback URL not mounted right when router has nested paths
- Can't set strategy options at runtime HOT 2
- Line Login v2.1 update request which I've done HOT 4
- Gracefully handle unknown providers HOT 10
- callback_port config compiled into plug at compile time HOT 10
- App.Auth.AuthController.request/2 is undefined or private HOT 1
- minor: mix package versions are out of date
- New hex.pm release? HOT 1
- Incorrect callback_url when using Bandit.PhoenixAdapter
- put_session successful, but get_session failed HOT 1
- function MyAppWeb.OAuthController.request/2 is undefined or private HOT 1
- Support for nonces HOT 1
- FR: Support multiple usages of the same strategy in config HOT 13
- Incomplete docs to configure pipeline and check that user is authenticated HOT 3
- Latest release breaks existing paths HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ueberauth.