shakha 0.1.4 → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2b5eb8fae72d4a779316f8266fc29f1078bf5b31c11a5d90ae922f46d3e37928
4
- data.tar.gz: 95bc2e261d8a08c818ad75b4beefc8e5a4fa97802ef5cf28afdfbe7a895cdcc1
3
+ metadata.gz: 111afb5f4917b2fb01033e9b93c37fabc0b099a886c7cce7eb80d4485e69e9a1
4
+ data.tar.gz: '008356dd3f1538432a84ff2e83c2b6d32e3ec5962ed252c79c8dc3229677c16d'
5
5
  SHA512:
6
- metadata.gz: 0ee17e65c726cb0564e720fb73648b74567fcfb1edae5befbd14a16942ca877d5c007cfc8b622fed8c949211de3bf5b792fdff1190482bfdd414351b451e6204
7
- data.tar.gz: 2205e02b9c9ebde26def46da665011571a5071a50bd79eaf6bb2d7075aed353d2d3b52eff1d6986113bf612ce2a6e2244e200e53b4aadf2b4c7fba8020ed354b
6
+ metadata.gz: 369843a745888523d8d3392e1111804d7113247005654de91c2fc75436a5a799ea505ad20858dbc057f9e81f5f3179dcaec77cd084923f3a1ae0121bcdb45960
7
+ data.tar.gz: 8bb91783e33cbac949565f21abded2d958b652b95f62b62f3d51eaabeaaf979224163376c98e58d25ecae57fbd41556f4a0db7c2415316e24e3778700e06af1e
@@ -5,7 +5,6 @@ module Shakha
5
5
  include ErrorHandler
6
6
  include ControllerHelpers
7
7
  include RateLimiter
8
- include Auditable
9
8
 
10
9
  protect_from_forgery with: :exception
11
10
 
@@ -6,6 +6,7 @@ require "uri"
6
6
  module Shakha
7
7
  class AuthController < ApplicationController
8
8
  include PKCEMixin
9
+ include Auditable
9
10
 
10
11
  skip_before_action :verify_authenticity_token, only: [:callback, :token]
11
12
 
@@ -177,7 +178,9 @@ module Shakha
177
178
  session_record = Shakha::Session.create!(
178
179
  user: user,
179
180
  client: client,
180
- jti: SecureRandom.uuid
181
+ jti: SecureRandom.uuid,
182
+ ip_address: request.remote_ip,
183
+ user_agent: request.user_agent
181
184
  )
182
185
 
183
186
  cookies.encrypted[:shakha_session_token] = {
@@ -2,6 +2,7 @@
2
2
 
3
3
  module Shakha
4
4
  class SessionController < ApplicationController
5
+ include Auditable
5
6
  skip_before_action :verify_authenticity_token, only: [:check]
6
7
 
7
8
  def index
@@ -61,11 +62,7 @@ module Shakha
61
62
 
62
63
  cookies.delete(:shakha_session_token) if session.token == current_session&.token
63
64
 
64
- ActiveSupport::Notifications.instrument("shakha.session_revoked", {
65
- session_id: session.id,
66
- user_id: current_user.id,
67
- ip: request.remote_ip
68
- })
65
+ log_session_revoked(session)
69
66
 
70
67
  render json: { status: "revoked" }
71
68
  end
@@ -5,15 +5,15 @@ module Shakha
5
5
  extend ActiveSupport::Concern
6
6
 
7
7
  included do
8
- after_action :log_sign_in, only: [:callback]
9
- after_action :log_sign_out, only: [:destroy]
10
- after_action :log_token_exchange, only: [:token]
8
+ after_action :log_sign_in
9
+ after_action :log_sign_out
10
+ after_action :log_token_exchange
11
11
  end
12
12
 
13
13
  private
14
14
 
15
15
  def log_sign_in
16
- return unless response.successful? && @current_user
16
+ return unless action_name == "callback" && response.successful? && @current_user
17
17
 
18
18
  ActiveSupport::Notifications.instrument("shakha.sign_in", {
19
19
  user_id: @current_user&.id,
@@ -20,7 +20,7 @@ module Shakha
20
20
  end
21
21
 
22
22
  def check_rate_limit(key, max:, period:)
23
- return unless Shakha.config.rate_limiting_enabled?
23
+ return unless Shakha.config.rate_limiting_enabled
24
24
 
25
25
  cache_key = "shakha-rate:#{key}:#{request.remote_ip}"
26
26
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Shakha
4
- VERSION = "0.1.4"
4
+ VERSION = "0.1.6"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shakha
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Asrat