From 4df257aec1f0b080e1157a56597363475c277f85 Mon Sep 17 00:00:00 2001 From: Bilel Kihal <61744974+Bilelkihal@users.noreply.github.com> Date: Tue, 5 Dec 2023 09:49:56 +0000 Subject: [PATCH 1/6] Make orcid and keycloak sso disabled in login page --- app/views/login/index.html.haml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/login/index.html.haml b/app/views/login/index.html.haml index 499a7ad1a..1f9a9fbd1 100644 --- a/app/views/login/index.html.haml +++ b/app/views/login/index.html.haml @@ -23,8 +23,8 @@ %div.d-flex.justify-content-center.flew-wrap - omniauth_providers_info.each do |provider, config| = button_to "/auth/#{config[:name] || config[:strategy] || provider}", - class: 'btn btn-lg', style:'width: 70px', title: "Login with #{provider.to_s.humanize}", 'data-turbo': false do + class: 'btn btn-lg',disabled: !config[:enable] ,style:'width: 70px', title: "Login with #{provider.to_s.humanize}", 'data-turbo': false do; - if config[:icon] = inline_svg config[:icon] - - else + - else = provider.to_s.humanize \ No newline at end of file From 68d23bee5518a4425b8144691ea27aefe7e76bb5 Mon Sep 17 00:00:00 2001 From: Bilel Kihal <61744974+Bilelkihal@users.noreply.github.com> Date: Tue, 5 Dec 2023 12:45:02 +0000 Subject: [PATCH 2/6] fix login using email --- app/controllers/login_controller.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/controllers/login_controller.rb b/app/controllers/login_controller.rb index aa50c31b9..945d524c0 100755 --- a/app/controllers/login_controller.rb +++ b/app/controllers/login_controller.rb @@ -16,9 +16,14 @@ def index # logs in a user def create + if params[:user][:username] =~ /\A[^@\s]+@[^@\s]+\z/ #this is a regular expression to check if the input is an email or not + username = LinkedData::Client::Models::User.find_by_email(params[:user][:username]).first.username + else + username = params[:user][:username] + end @errors = validate(params[:user]) if @errors.size < 1 - logged_in_user = LinkedData::Client::Models::User.authenticate(params[:user][:username], params[:user][:password]) + logged_in_user = LinkedData::Client::Models::User.authenticate(username, params[:user][:password]) if logged_in_user && !logged_in_user.errors login(logged_in_user) redirect = "/" From 4b612ec6ace5deabaab56d53e4593b538ac2880b Mon Sep 17 00:00:00 2001 From: Bilel Kihal <61744974+Bilelkihal@users.noreply.github.com> Date: Tue, 5 Dec 2023 14:06:40 +0000 Subject: [PATCH 3/6] add tooltip for disabled login sso --- app/assets/images/icons/github.svg | 6 +++--- app/assets/images/icons/google.svg | 6 +++--- app/assets/images/icons/keycloak.svg | 17 +++++++++++------ app/assets/images/icons/orcid.svg | 6 +++--- app/assets/stylesheets/login.scss | 7 +++++++ app/views/login/index.html.haml | 21 +++++++++++++-------- 6 files changed, 40 insertions(+), 23 deletions(-) diff --git a/app/assets/images/icons/github.svg b/app/assets/images/icons/github.svg index 06f3dcd7d..656a9dede 100644 --- a/app/assets/images/icons/github.svg +++ b/app/assets/images/icons/github.svg @@ -1,3 +1,3 @@ - - - \ No newline at end of file + + + diff --git a/app/assets/images/icons/google.svg b/app/assets/images/icons/google.svg index f710f4020..01b25ab73 100644 --- a/app/assets/images/icons/google.svg +++ b/app/assets/images/icons/google.svg @@ -1,3 +1,3 @@ - - - \ No newline at end of file + + + diff --git a/app/assets/images/icons/keycloak.svg b/app/assets/images/icons/keycloak.svg index 8b3cfb86c..e9f3a43a9 100644 --- a/app/assets/images/icons/keycloak.svg +++ b/app/assets/images/icons/keycloak.svg @@ -1,6 +1,11 @@ - - - - - \ No newline at end of file + + + + + + + + + + + diff --git a/app/assets/images/icons/orcid.svg b/app/assets/images/icons/orcid.svg index 86a1ea871..0f367e7e9 100644 --- a/app/assets/images/icons/orcid.svg +++ b/app/assets/images/icons/orcid.svg @@ -1,3 +1,3 @@ - - - \ No newline at end of file + + + diff --git a/app/assets/stylesheets/login.scss b/app/assets/stylesheets/login.scss index 342c754eb..1b0c72489 100644 --- a/app/assets/stylesheets/login.scss +++ b/app/assets/stylesheets/login.scss @@ -51,4 +51,11 @@ margin-top: 10px; margin-bottom: 20px; width: 357px; +} +.disabled-login-sso{ + width: 40px; + margin: 7px 10px; +} +.login-active-sso path{ + fill: var(--primary-color) } \ No newline at end of file diff --git a/app/views/login/index.html.haml b/app/views/login/index.html.haml index 1f9a9fbd1..cb54cb0dc 100644 --- a/app/views/login/index.html.haml +++ b/app/views/login/index.html.haml @@ -19,12 +19,17 @@ %p.dont-have-account = t('login.no_account') %a.text-decoration-none{:href => new_user_path}= t('login.register') - %hr.divider.w-100 - %div.d-flex.justify-content-center.flew-wrap + %hr.divider.w-100.mb-4.mt-4 + %div.d-flex.justify-content-around.flew-wrap - omniauth_providers_info.each do |provider, config| - = button_to "/auth/#{config[:name] || config[:strategy] || provider}", - class: 'btn btn-lg',disabled: !config[:enable] ,style:'width: 70px', title: "Login with #{provider.to_s.humanize}", 'data-turbo': false do; - - if config[:icon] - = inline_svg config[:icon] - - else - = provider.to_s.humanize \ No newline at end of file + - if config[:enable] + = button_to "/auth/#{config[:name] || config[:strategy] || provider}", + class: 'btn btn-lg',disabled: !config[:enable] ,style:'width: 70px', title: "Login with #{provider.to_s.humanize}", 'data-turbo': false do; + - if config[:icon] + = inline_svg "icons/#{config[:icon]}", class: 'login-active-sso' + - else + = provider.to_s.humanize + - else + .disabled-login-sso + = render Display::InfoTooltipComponent.new(text: "#{provider.to_s.humanize} is disabled", icon: config[:icon]) + \ No newline at end of file From 73f7e84a98b3254c4bed0c48d45580ffba34d6df Mon Sep 17 00:00:00 2001 From: Bilel Kihal <61744974+Bilelkihal@users.noreply.github.com> Date: Tue, 5 Dec 2023 14:20:58 +0000 Subject: [PATCH 4/6] extract is_email function in login controller --- app/controllers/login_controller.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/controllers/login_controller.rb b/app/controllers/login_controller.rb index 945d524c0..e58ef1af1 100755 --- a/app/controllers/login_controller.rb +++ b/app/controllers/login_controller.rb @@ -16,7 +16,7 @@ def index # logs in a user def create - if params[:user][:username] =~ /\A[^@\s]+@[^@\s]+\z/ #this is a regular expression to check if the input is an email or not + if is_email(params[:user][:username]) username = LinkedData::Client::Models::User.find_by_email(params[:user][:username]).first.username else username = params[:user][:username] @@ -158,5 +158,9 @@ def validate(params) return errors end + def is_email(email) + email =~ /\A[^@\s]+@[^@\s]+\z/ + end + end From 5986aec9551417a9e3817315a16116a679a9579d Mon Sep 17 00:00:00 2001 From: Bilel Kihal <61744974+Bilelkihal@users.noreply.github.com> Date: Tue, 5 Dec 2023 15:35:22 +0000 Subject: [PATCH 5/6] Update sample env file after updating $OMNIAUTH_PROVIDERS --- config/bioportal_config_env.rb.sample | 97 ++++++++------------------- 1 file changed, 29 insertions(+), 68 deletions(-) diff --git a/config/bioportal_config_env.rb.sample b/config/bioportal_config_env.rb.sample index a3d950e1f..ebcc4d115 100644 --- a/config/bioportal_config_env.rb.sample +++ b/config/bioportal_config_env.rb.sample @@ -1,77 +1,63 @@ -# coding: utf-8 - # Organization info $ORG = ENV['ORG'] $ORG_URL = ENV['ORG_URL'] - # Site name (required) $SITE = ENV['SITE'] - # Full string for site, EX: "NCBO BioPortal", do not modify -$ORG_SITE = ($ORG.nil? || $ORG.empty?) ? $SITE : "#{$ORG} #{$SITE}" - +$ORG_SITE = $ORG.nil? || $ORG.empty? ? $SITE : "#{$ORG} #{$SITE}" # The URL for the BioPortal Rails UI (this application) $UI_URL = ENV['UI_URL'] - - # If you are running a PURL server to provide URLs for ontologies in your BioPortal instance, enable this option $PURL_ENABLED = false - # The PURL URL is generated using this prefix + the abbreviation for an ontology. # The PURL URL generation algorithm can be altered in app/models/ontology_wrapper.rb -$PURL_PREFIX = "http://purl.bioontology.org/ontology" - +$PURL_PREFIX = 'http://purl.bioontology.org/ontology' # If your BioPortal installation includes Annotator set this to false $ANNOTATOR_DISABLED = false - # Unique string representing the UI's id for use with the BioPortal Core $API_KEY = ENV['API_KEY'] - # BioPortal API service address $REST_URL = ENV['API_URL'] - # Annotator REST service address -#$ANNOTATOR_URL = "http://services.stageportal.lirmm.fr/annotator" +# $ANNOTATOR_URL = "http://services.stageportal.lirmm.fr/annotator" $ANNOTATOR_URL = ENV['ANNOTATOR_URL'] - # NCBO annotator URL and apikey $NCBO_ANNOTATORPLUS_ENABLED = ENV['NCBO_ANNOTATORPLUS_ENABLED'] $NCBO_ANNOTATOR_URL = ENV['NCBO_ANNOTATOR_URL'] $NCBO_API_KEY = ENV['NCBO_API_KEY'] - # Fairness Assessment. $FAIRNESS_DISABLED = ENV['FAIRNESS_DISABLED'] -$FAIRNESS_URL = ENV['FAIRNESS_URL'] - - +$FAIRNESS_URL = ENV['FAIRNESS_URL'] # Announcements sympa mailing list REQUEST address, EX: list-request@lists.example.org -$ANNOUNCE_LIST_SERVICE ||= "SERVICE_EXAMPLE" -$ANNOUNCE_SERVICE_HOST ||= "service@test.com" -$ANNOUNCE_LIST||= "users-list@test" - +$ANNOUNCE_LIST_SERVICE ||= 'SERVICE_EXAMPLE' +$ANNOUNCE_SERVICE_HOST ||= 'service@test.com' +$ANNOUNCE_LIST ||= 'users-list@test' # Used to define other bioportal that can be mapped to # Example to map to ncbo bioportal : {"ncbo" => {"api" => "http://data.bioontology.org", "ui" => "http://bioportal.bioontology.org", "apikey" => ""} # Then create the mapping using the following class in JSON : "http://purl.bioontology.org/ontology/MESH/C585345": "ncbo:MESH" # Where "ncbo" is the namespace used as key in the interportal_hash $INTERPORTAL_HASH = {} - +$NOT_DOWNLOADABLE = {} # OAuth2 authentication $OMNIAUTH_PROVIDERS = { github: { client_id: 'CLIENT_ID', client_secret: 'CLIENT_SECRET', - icon: 'icons/github.svg', + icon: 'github.svg', + enable: true }, google: { strategy: :google_oauth2, client_id: 'CLIENT_ID', client_secret: 'CLIENT_SECRET', - icon: 'icons/google.svg', + icon: 'google.svg', + enable: true }, orcid: { client_id: 'CLIENT_SECRET', client_secret: 'CLIENT_SECRET', - icon: 'icons/orcid.svg' + icon: 'orcid.svg', + enable: false }, keycloak: { strategy: :keycloak_openid, @@ -79,65 +65,46 @@ $OMNIAUTH_PROVIDERS = { client_secret: 'YOUR_KEYCLOAK_CLIENT_SECRET', client_options: { site: 'KEYCLOAK_SITE', realm: 'KEYCLOAK_REALM' }, name: 'keycloak', - icon: 'icons/keycloak.svg' + icon: 'keycloak.svg', + enable: false } }.freeze - # Don't load and don't display recent mappings if false, in case of too many mappings (take longer to load homepage) $DISPLAY_RECENT = false - # If true then the UI will get available recognize at API_URL/annotators/recognizers $MULTIPLE_RECOGNIZERS = false - # Remove download for these ontologies. Default: # ["CPT","ICD10","ICNP","ICPC2P","MDDB","MEDDRA","MSHFRE","MSHSPA_1","NDDF","NDFRT","NIC","RCD","SCTSPA","SNOMEDCT","WHO-ART"] $RESTRICTED_DOWNLOADS = [] - # Ontolobridge endpoint url -$ONTOLOBRIDGE_BASE_URL = "https://ontolobridge.ccs.miami.edu/api-test/requests" - +$ONTOLOBRIDGE_BASE_URL = 'https://ontolobridge.ccs.miami.edu/api-test/requests' # Ontolobridge authentication token -$ONTOLOBRIDGE_AUTHENTICATION_TOKEN = "Token Uq2pae73ktMtmgjUgtnhEOuHxr9sZeuK" - +$ONTOLOBRIDGE_AUTHENTICATION_TOKEN = 'Token Uq2pae73ktMtmgjUgtnhEOuHxr9sZeuK' # Ontologies for which to enable the new term request (Ontolobridge) tab $NEW_TERM_REQUEST_ONTOLOGIES = [] - # Legacy REST core service address (BioPortal v3.x and lower) -$LEGACY_REST_URL = "http://example.org:8080/bioportal" - - +$LEGACY_REST_URL = 'http://example.org:8080/bioportal' # Release version text (appears in footer of all pages, except 404 and 500 errors) $RELEASE_VERSION = ENV['RELEASE_VERSION'] - # Enable Slices, filtering of ontologies based on subdomain and ontology groups $ENABLE_SLICES = false - # Google Analytics ID (optional) $ANALYTICS_ID = ENV['ANALYTICS_ID'] - - - # Enable client request caching $CLIENT_REQUEST_CACHING = true - - # Email settings ActionMailer::Base.smtp_settings = { - :address => "", # smtp server address, ex: smtp.example.org - :port => 25, # smtp server port - :domain => "", # fqdn of rails server, ex: rails.example.org + address: '', # smtp server address, ex: smtp.example.org + port: 25, # smtp server port + domain: '' # fqdn of rails server, ex: rails.example.org } - # Announcements mailman mailing list REQUEST address, EX: list-request@lists.example.org # NOTE: You must use the REQUEST address for the mailing list. ONLY WORKS WITH MAILMAN LISTS. $ANNOUNCE_LIST = ENV['SUPPORT_EMAIL'] - # Email addresses used for sending notifications (errors, feedback, support) $SUPPORT_EMAIL = ENV['SUPPORT_EMAIL'] - # Email used to send notifications $NOTIFICATION_EMAIL = ENV['SUPPORT_EMAIL'] - # reCAPTCHA # In order to use reCAPTCHA on the account creation and feedback submission pages: # 1. Obtain a reCAPTCHA v2 key from: https://www.google.com/recaptcha/admin @@ -149,15 +116,12 @@ $NOTIFICATION_EMAIL = ENV['SUPPORT_EMAIL'] # # 3. Set the USE_RECAPTCHA option to 'true' ENV['USE_RECAPTCHA'] = 'false' - # Custom BioPortal logging require 'log' - # URL where BioMixer GWT app is located -#$BIOMIXER_URL = "http://bioportal-integration.bio-mixer.appspot.com" +# $BIOMIXER_URL = "http://bioportal-integration.bio-mixer.appspot.com" $BIOMIXER_URL = ENV['BIOMIXER_URL'] $BIOMIXER_APIKEY = ENV['BIOMIXER_APIKEY'] - ## # Custom Ontology Details # Custom details can be added on a per ontology basis using a key/value pair as columns of the details table @@ -166,14 +130,11 @@ $BIOMIXER_APIKEY = ENV['BIOMIXER_APIKEY'] # $ADDITIONAL_ONTOLOGY_DETAILS = { "STY" => { "Additional Detail" => "Text to be shown in the right-hand column." } } ## $ADDITIONAL_ONTOLOGY_DETAILS = {} - -#Front notice appears on the front page only and is closable by the user. It remains closed for seven days (stored in cookie) +# Front notice appears on the front page only and is closable by the user. It remains closed for seven days (stored in cookie) $FRONT_NOTICE = '' - # Site notice appears on all pages and remains closed indefinitely. Stored below as a hash with a unique key and a string message # EX: $SITE_NOTICE = { :unique_key => 'Put your message here (can include html if you use single quotes).' } -$SITE_NOTICE = { } - +$SITE_NOTICE = {} $HOME_PAGE_LOGOS = { supported_by: [ { @@ -247,12 +208,12 @@ $FOOTER_LINKS = { } } } - $UI_THEME = ENV['UI_THEME'] || 'ontoportal' - $HOSTNAME = ENV['API_URL'] if $HOSTNAME $HOSTNAME = ENV['API_URL'].split('data.').last # add custom stage server configuration if needed (e.g bioportal_config_development_stageportal.lirmm.fr) - require_relative "bioportal_config_development_#{$HOSTNAME}" if File.exist?("config/bioportal_config_development_#{$HOSTNAME}") -end \ No newline at end of file + if File.exist?("config/bioportal_config_development_#{$HOSTNAME}") + require_relative "bioportal_config_development_#{$HOSTNAME}" + end +end From 515b42c0d8288d95a0476e4ee6abbbe74abeffe8 Mon Sep 17 00:00:00 2001 From: Syphax Bouazzouni Date: Thu, 7 Dec 2023 13:53:42 +0100 Subject: [PATCH 6/6] update bioportal_config_test.rb with new oauth config --- config/bioportal_config_test.rb | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/config/bioportal_config_test.rb b/config/bioportal_config_test.rb index 2ec4457ab..be327b655 100644 --- a/config/bioportal_config_test.rb +++ b/config/bioportal_config_test.rb @@ -14,20 +14,23 @@ # config/initializers/omniauth_providers.rb $OMNIAUTH_PROVIDERS = { github: { - client_id: 'id', - client_secret: 'secret', - icon: 'icons/github.svg' + client_id: 'CLIENT_ID', + client_secret: 'CLIENT_SECRET', + icon: 'github.svg', + enable: true }, google: { strategy: :google_oauth2, - client_id: 'id', - client_secret: 'secret', - icon: 'icons/google.svg' + client_id: 'CLIENT_ID', + client_secret: 'CLIENT_SECRET', + icon: 'google.svg', + enable: true }, orcid: { - client_id: 'YOUR_ORCID_CLIENT_ID', - client_secret: 'YOUR_ORCID_CLIENT_SECRET', - icon: 'icons/orcid.svg' + client_id: 'CLIENT_SECRET', + client_secret: 'CLIENT_SECRET', + icon: 'orcid.svg', + enable: false }, keycloak: { strategy: :keycloak_openid, @@ -35,7 +38,8 @@ client_secret: 'YOUR_KEYCLOAK_CLIENT_SECRET', client_options: { site: 'KEYCLOAK_SITE', realm: 'KEYCLOAK_REALM' }, name: 'keycloak', - icon: 'icons/keycloak.svg' + icon: 'keycloak.svg', + enable: false } }.freeze