Class: PrxAuth::Rails::SessionsController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/prx_auth/rails/sessions_controller.rb

Constant Summary collapse

ID_NONCE_SESSION_KEY =
"id_prx_openid_nonce"
DEFAULT_SCOPES =
"openid"

Instance Method Summary collapse

Instance Method Details

#auth_errorObject



46
47
48
# File 'app/controllers/prx_auth/rails/sessions_controller.rb', line 46

def auth_error
  @auth_error_message = params.require(:error)
end

#createObject



50
51
52
53
54
55
56
57
58
59
60
# File 'app/controllers/prx_auth/rails/sessions_controller.rb', line 50

def create
  valid_and_matching = valid_nonce? && users_match?
  clear_nonce!

  if valid_and_matching
    (access_token)
    redirect_to (current_user)
  else
    redirect_to auth_error_sessions_path(error: params[:error] || "unknown_error")
  end
end

#destroyObject



41
42
43
44
# File 'app/controllers/prx_auth/rails/sessions_controller.rb', line 41

def destroy
  sign_out_user
  redirect_to after_sign_out_path
end

#newObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'app/controllers/prx_auth/rails/sessions_controller.rb', line 15

def new
  config = PrxAuth::Rails.configuration

  scope =
    if config.prx_scope.present?
      "#{DEFAULT_SCOPES} #{config.prx_scope}"
    else
      DEFAULT_SCOPES
    end

  id_auth_params = {
    client_id: config.prx_client_id,
    nonce: fetch_nonce,
    response_type: "id_token token",
    scope: scope,
    prompt: "necessary"
  }

  url = "//" + config.id_host + "/authorize?" + id_auth_params.to_query

  redirect_to url, allow_other_host: true
end

#showObject



38
39
# File 'app/controllers/prx_auth/rails/sessions_controller.rb', line 38

def show
end