diff --git a/app/controllers/people_controller.rb b/app/controllers/people_controller.rb index 26c421793..4e4430c0d 100644 --- a/app/controllers/people_controller.rb +++ b/app/controllers/people_controller.rb @@ -13,15 +13,13 @@ class PeopleController < CrudController # self.permitted_relationships = %i[person_roles people_skills] - - - def show - require 'pry'; binding.pry # rubocop:disable Style/Semicolon,Lint/Debugger if format_odt? export return end + @person = Person.includes(projects: :project_technologies, + person_roles: [:role, :person_role_level]).find(params.fetch(:id)) super end diff --git a/app/models/person.rb b/app/models/person.rb index b7c9736ad..44755512d 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -27,8 +27,6 @@ class Person < ApplicationRecord include PgSearch::Model - # Include default devise modules. Others available are: - # :confirmable, :lockable, :timeoutable, :trackable and :omniauthable devise :omniauthable, omniauth_providers: [:openid_connect] belongs_to :company diff --git a/config/application.rb b/config/application.rb index 16f4689d1..d638d4fbb 100644 --- a/config/application.rb +++ b/config/application.rb @@ -25,7 +25,6 @@ class Application < Rails::Application # Middleware like session, flash, cookies can be added back manually. # Skip views, helpers and assets when generating a new resource. config.autoload_paths += %W( #{config.root}/app/uploaders) # - config.autoload_paths += %W(#{config.root}/lib) config.i18n.default_locale = :de config.active_record.verify_foreign_keys_for_fixtures = false @@ -48,11 +47,5 @@ def keycloak_disabled? ENV['KEYCLOAK_DISABLED'].present? end - config.middleware.use Rack::OAuth2::Server::Rails::Authorize - config.middleware.use Rack::OAuth2::Server::Resource::Bearer, 'OpenID Connect' do |req| - AccessToken.valid.find_by(token: req.access_token) || - req.invalid_token! - end - end end diff --git a/config/auth.yml b/config/auth.yml deleted file mode 100644 index fdcf2714f..000000000 --- a/config/auth.yml +++ /dev/null @@ -1,31 +0,0 @@ -# provider: db - -# Keycloak example -provider: openid-connect - -oidc: - client_id: pitc_skills_rails_backend - host: sso-test.puzzle.ch - host_port: 8180 - host_scheme: https - secret: 'r609dv7dl50164n4rlga121ott' - authorization_endpoint: '/auth/realms/pitc/protocol/openid-connect/auth' - token_endpoint: '/auth/realms/pitc/protocol/openid-connect/token' - user_subject: preferred_username - certs_url: https://sso-test.puzzle.ch/auth/realms/skills/protocol/openid-connect/certs - additional_scopes: - - email - - -# ldap example -# provider: ldap -# -# ldap: -# bind_dn: 'uid=binduser,ou=system,ou=users,dc=acme,dc=itc' -# bind_password: cGFzc3dvcmQ= # base64 encoded # echo -n 'password' | base64 -# encryption: 'simple_tls' -# hostnames: -# - 'ldap.example.com' -# - 'ldap-fallback.example.com' -# basename: 'ou=members,ou=users,dc=acme,dc=itc' -# portnumber: 636 diff --git a/db/schema.rb b/db/schema.rb index 0b6a1e53b..9acca065e 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -136,13 +136,7 @@ t.string "email" t.integer "department_id" t.string "shortname" - t.string "encrypted_password", default: "", null: false - t.string "reset_password_token" - t.datetime "reset_password_sent_at" - t.datetime "remember_created_at" t.index ["company_id"], name: "index_people_on_company_id" - t.index ["email"], name: "index_people_on_email", unique: true - t.index ["reset_password_token"], name: "index_people_on_reset_password_token", unique: true end create_table "people_skills", force: :cascade do |t| diff --git a/lib/oidc_client.rb b/lib/oidc_client.rb deleted file mode 100644 index ea083beb1..000000000 --- a/lib/oidc_client.rb +++ /dev/null @@ -1,60 +0,0 @@ -# frozen_string_literal: true - -# OpenID Connect Client -class OidcClient - - def external_login_url - state = SecureRandom.hex(16) - nonce = SecureRandom.hex(16) - authorization_uri = client.authorization_uri( - scope: config[:additional_scopes].presence, - state: state, - nonce: nonce - ) - [authorization_uri, state] - end - - def user_subject - config[:user_subject] - end - - def get_id_token(code:, state:) - client.authorization_code = code - access_token = client.access_token!(state: state) - OpenIDConnect::ResponseObject::IdToken.decode(access_token.id_token, host_public_key) - end - - private - - def client - @client ||= init_client - end - - def init_client - OpenIDConnect::Client.new( - identifier: config[:client_id], - secret: config[:secret], - host: config[:host], - port: config[:host_port] || 443, - scheme: config[:host_scheme] || 'https', - authorization_endpoint: config[:authorization_endpoint], - token_endpoint: config[:token_endpoint], - redirect_uri: cryptopus_return_url - ) - end - - def host_public_key - json = JSON.parse(URI.parse(config[:certs_url]).open.read) - JSON::JWK::Set.new json['keys'] - end - - def config - AuthConfig.oidc_settings - end - - def cryptopus_return_url - protocol = Rails.application.config.force_ssl ? 'https://' : 'http://' - "#{protocol}#{ENV['RAILS_HOST_NAME'] || 'localhost:3000'}/session/oidc" - end - -end