Module: WebIde::DefaultOauthApplication
- Defined in:
- lib/web_ide/default_oauth_application.rb
Class Method Summary collapse
- .ensure_oauth_application! ⇒ Object
- .oauth_application ⇒ Object
- .oauth_application_callback_urls ⇒ Object
- .oauth_application_id ⇒ Object
- .oauth_callback_url ⇒ Object
- .reset_oauth_application_settings ⇒ Object
Class Method Details
.ensure_oauth_application! ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/web_ide/default_oauth_application.rb', line 30 def ensure_oauth_application! return if oauth_application should_expire_cache = false application_settings.transaction do # note: This should run very rarely and should be safe for us to do a lock # https://gitlab.com/gitlab-org/gitlab/-/merge_requests/132496#note_1587293087 application_settings.lock! # note: `lock!`` breaks application_settings cache and will trigger another query. # We need to double check here so that requests previously waiting on the lock can # now just skip. next if oauth_application application = Authn::OauthApplication.new(default_settings) application.save! application_settings.update!(web_ide_oauth_application: application) should_expire_cache = true end # note: This needs to happen outside the transaction, but only if we actually changed something ::Gitlab::CurrentSettings.expire_current_application_settings if should_expire_cache end |
.oauth_application ⇒ Object
6 7 8 |
# File 'lib/web_ide/default_oauth_application.rb', line 6 def oauth_application application_settings.web_ide_oauth_application end |
.oauth_application_callback_urls ⇒ Object
18 19 20 21 22 |
# File 'lib/web_ide/default_oauth_application.rb', line 18 def oauth_application_callback_urls return [] unless oauth_application URI.extract(oauth_application.redirect_uri, %w[http https]).uniq end |
.oauth_application_id ⇒ Object
14 15 16 |
# File 'lib/web_ide/default_oauth_application.rb', line 14 def oauth_application_id oauth_application ? oauth_application.id : nil end |
.oauth_callback_url ⇒ Object
10 11 12 |
# File 'lib/web_ide/default_oauth_application.rb', line 10 def oauth_callback_url Gitlab::Routing.url_helpers.ide_oauth_redirect_url end |
.reset_oauth_application_settings ⇒ Object
24 25 26 27 28 |
# File 'lib/web_ide/default_oauth_application.rb', line 24 def reset_oauth_application_settings return unless oauth_application oauth_application.update!(default_settings) end |