Class: AnoubisSsoServer::System
- Inherits:
-
ApplicationRecord
- Object
- Anoubis::ApplicationRecord
- ApplicationRecord
- AnoubisSsoServer::System
- Defined in:
- app/models/anoubis_sso_server/system.rb
Overview
Default System class
Instance Method Summary collapse
-
#after_destroy_sso_server_system ⇒ Object
Fires after System was destroyed.
-
#after_save_sso_server_system ⇒ Object
Fires after System was saved to SQL database and setup system cache in Redis database for fast access.
-
#before_save_sso_server_system ⇒ Object
Fires before System was saved to SQL database.
-
#before_validation_sso_server_system_on_create ⇒ Object
Fires before create system.
-
#jwk ⇒ Hash
Returns JWK information.
-
#setup_private_system_id ⇒ String
Procedure setup private user identifier.
-
#setup_public_system_id ⇒ String
Procedure setup public user identifier.
Instance Method Details
#after_destroy_sso_server_system ⇒ Object
Fires after System was destroyed. Clears all systems caches.
64 65 66 67 |
# File 'app/models/anoubis_sso_server/system.rb', line 64 def after_destroy_sso_server_system redis.del "#{redis_prefix}system:#{public}" redis.del "#{redis_prefix}jwks" end |
#after_save_sso_server_system ⇒ Object
Fires after System was saved to SQL database and setup system cache in Redis database for fast access.
57 58 59 60 |
# File 'app/models/anoubis_sso_server/system.rb', line 57 def after_save_sso_server_system redis.set("#{redis_prefix}system:#{public}", { uuid: uuid, public: public, request_uri: request_uri, jwk: jwk, ttl: ttl }.to_json ) redis.del "#{redis_prefix}jwks" end |
#before_save_sso_server_system ⇒ Object
Fires before System was saved to SQL database. Delete old system cache if public identifier was changed.
51 52 53 |
# File 'app/models/anoubis_sso_server/system.rb', line 51 def before_save_sso_server_system redis.del "#{redis_prefix}system:#{public_was}" if public_was && public != public_was end |
#before_validation_sso_server_system_on_create ⇒ Object
Fires before create system. Procedure generates public and private UUID and RSA keypair
19 20 21 22 23 24 25 26 |
# File 'app/models/anoubis_sso_server/system.rb', line 19 def before_validation_sso_server_system_on_create self.uuid = setup_private_system_id self.public = setup_public_system_id unless public self.request_uri = [] unless request_uri keys = JWT::JWK.new(OpenSSL::PKey::RSA.new(2048)) self.jwk = keys.export include_private: true end |
#jwk ⇒ Hash
Returns JWK information
45 46 47 |
# File 'app/models/anoubis_sso_server/system.rb', line 45 def jwk @jwk ||= super.deep_symbolize_keys! end |
#setup_private_system_id ⇒ String
Procedure setup private user identifier. Procedure can be redefined.
31 32 33 |
# File 'app/models/anoubis_sso_server/system.rb', line 31 def setup_private_system_id SecureRandom.uuid end |
#setup_public_system_id ⇒ String
Procedure setup public user identifier. Used for open API. Procedure can be redefined.
38 39 40 |
# File 'app/models/anoubis_sso_server/system.rb', line 38 def setup_public_system_id SecureRandom.uuid end |