Class: OmniAuth::Strategies::Nordea

Inherits:
Object
  • Object
show all
Includes:
OmniAuth::Strategy
Defined in:
lib/omniauth/strategies/nordea.rb,
lib/omniauth/strategies/nordea/message.rb,
lib/omniauth/strategies/nordea/request.rb,
lib/omniauth/strategies/nordea/response.rb

Defined Under Namespace

Classes: Message, Request, Response, ValidationError

Constant Summary collapse

PRODUCTION_ENDPOINT =
"https://netbank.nordea.com/pnbeid/eidn.jsp"
TEST_ENDPOINT =
"https://netbank.nordea.com/pnbeidtest/eidn.jsp"

Instance Method Summary collapse

Instance Method Details

#callback_phaseObject


40
41
42
43
44
45
46
47
48
49
50
# File 'lib/omniauth/strategies/nordea.rb', line 40

def callback_phase
  if request.params["B02K_CUSTID"] && !request.params["B02K_CUSTID"].empty?
    message = OmniAuth::Strategies::Nordea::Response.new(request.params)
    message.validate!(options.mac)
    super
  else
    fail!(:invalid_credentials)
  end
rescue ValidationError => e
  fail!(:invalid_mac, e)
end

#request_phaseObject


52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/omniauth/strategies/nordea.rb', line 52

def request_phase
  message = OmniAuth::Strategies::Nordea::Request.new(
    "A01Y_ACTION_ID" => "701",
    "A01Y_VERS"      => "0002",
    "A01Y_RCVID"     => options.rcvid,
    "A01Y_LANGCODE"  => "LV",
    "A01Y_STAMP"     => "yyyymmddhhmmssxxxxxx",
    "A01Y_IDTYPE"    => "02",
    "A01Y_RETLINK"   => callback_with_status_url("success"),
    "A01Y_CANLINK"   => callback_with_status_url("cancelled"),
    "A01Y_REJLINK"   => callback_with_status_url("rejected")
  )
  message.sign!(options.mac, options.hash_algorithm)

  # Build redirect form
  form = OmniAuth::Form.new(title: I18n.t("omniauth.nordea.please_wait"), url: options.endpoint)

  message.each_pair do |k,v|
    form.html "<input type=\"hidden\" name=\"#{k}\" value=\"#{v}\" />"
  end

  form.button I18n.t("omniauth.nordea.click_here_if_not_redirected")

  form.instance_variable_set("@html",
    form.to_html.gsub("</form>", "</form><script type=\"text/javascript\">document.forms[0].submit();</script>"))
  form.to_response
end