Steamex v0.0.9 Steamex.Auth.Plug View Source
A Plug for handling the return_to request for a Steam auth attempt.
If you are using Phoenix, please see Steamex.Auth.Phoenix
.
You should mount this plug at the URL you pass as the return_to
when
calling Steamex.Auth.auth_url/2
. If the payload from Steam is validated,
the user’s steamid64 will be put in the session key :steamex_steamid64
.
If you need to look up a user in your DB (for instance), you could then write a plug to access this session key and find/create a user in your app, which you can then put in conn.assigns.
If validation fails, this plug will return a 403 with an empty body. Validation generally should only fail in cases of tampering or Steam being down, so this generally should not affect user experience.
By default, this plug redirects to “/“ after a successful authentication, but this can be overridden by setting in your config:
config :steamex, Steamex,
redirect_to: "/profile/me"
You can also override this behavior by adding a “redirect_to” query parameter to the return_to URL. If auth is successful, this plug will redirect to the given path. Non-path values (such as external URLs) will be ignored.