View Source PowAssent.Plug.Reauthorization (PowAssent v0.4.18)

This plug can reauthorize a user who signed in through a provider.

The plug is dependent on a :handler that has the following methods:

  • reauthorize?/2 - verifies the request for reauthorization condition. If the condition exists for the request (usually the sign in path), the reauthorization cookie will be fetched and deleted, the reauthorize/2 callback will be called, and the connection halted.

  • clear_reauthorization?/2 - verifies the request for clear reauthorization condition. If the condition exists (usually the session delete path) then the cookie is deleted.

  • reauthorize/3 - the callback to handle the request when a reauthorization condition exists. Usually this would redirect the user.

See PowAssent.Phoenix.ReauthorizationPlugHandler for a Phoenix example.

Example

plug PowAssent.Plug.Reauthorization,
  handler: MyApp.ReauthorizationHandler

Configuration options

  • :handler - the handler module. Should either be a module or a tuple {module, options}.

  • :reauthorization_cookie_key - reauthorization key name. This defaults to "authorization_provider". If :otp_app is used it'll automatically prepend the key with the :otp_app value.

  • :reauthorization_cookie_opts - keyword list of cookie options, see Plug.Conn.put_resp_cookie/4 for options. The default options are [max_age: max_age, path: "/"] where :max_age is 30 days.