Module: OauthApplications

Extended by:
ActiveSupport::Concern
Included in:
Admin::ApplicationsController, Groups::Settings::ApplicationsController, Oauth::ApplicationsController
Defined in:
app/controllers/concerns/oauth_applications.rb

Constant Summary collapse

CREATED_SESSION_KEY =
:oauth_applications_created

Instance Method Summary collapse

Instance Method Details

#application_paramsObject



41
42
43
44
45
# File 'app/controllers/concerns/oauth_applications.rb', line 41

def application_params
  params
    .require(:authn_oauth_application)
    .permit(*permitted_params)
end

#get_created_sessionObject



22
23
24
# File 'app/controllers/concerns/oauth_applications.rb', line 22

def get_created_session
  session.delete(CREATED_SESSION_KEY) || false
end

#load_scopesObject



26
27
28
29
30
31
32
33
34
35
# File 'app/controllers/concerns/oauth_applications.rb', line 26

def load_scopes
  @scopes ||= Doorkeeper::OAuth::Scopes.from_array(
    Doorkeeper.configuration.scopes.to_a - [
      ::Gitlab::Auth::AI_WORKFLOW.to_s,
      ::Gitlab::Auth::DYNAMIC_USER.to_s,
      ::Gitlab::Auth::SELF_ROTATE_SCOPE.to_s,
      ::Gitlab::Auth::MCP_SCOPE.to_s
    ]
  )
end

#permitted_paramsObject



37
38
39
# File 'app/controllers/concerns/oauth_applications.rb', line 37

def permitted_params
  %i[name redirect_uri scopes confidential]
end

#prepare_scopesObject



12
13
14
15
16
# File 'app/controllers/concerns/oauth_applications.rb', line 12

def prepare_scopes
  scopes = params.fetch(:authn_oauth_application, {}).fetch(:scopes, nil)

  params[:authn_oauth_application][:scopes] = scopes.join(' ') if scopes
end

#set_created_sessionObject



18
19
20
# File 'app/controllers/concerns/oauth_applications.rb', line 18

def set_created_session
  session[CREATED_SESSION_KEY] = true
end