blipit 0.1.0 → 0.1.1

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: 3f949d1c6a29c26aea5036c4cb3298cd599f14f2ca5019946e72003fb9a53e87
4
- data.tar.gz: b1e38bd23ac52d4fe74f5ec0b44e3b5c2f0d6b30a5ad6e092af833f49bbc006c
3
+ metadata.gz: 725f1f7935b92f07ead1f9c8dc944077671d90708857ad933b56f3f99898803e
4
+ data.tar.gz: 30cc8ca3193055b99770d4ec0120baa128b3b10ee30c4a379cec1a6ab8cc176f
5
5
  SHA512:
6
- metadata.gz: 601637f0986ab8b4da74b5d6c7b656da8cb9c47193da167510c587185d66fa138610db8273fdf13e39bf886e5392c28ddd55f6fdfe21b32786c13d6ce8d5e7f0
7
- data.tar.gz: 4ec6d0bafe9bd2dc3c186b43ee4a9c63becbe4351bf5bd30cd447b8abc5f94224d2cba1fe6812bb188aa32ede4f0e246a99459b39a0e2b4847e0df69514153a9
6
+ metadata.gz: e6808a51c08d76b523c739fdba9b5ed1539ea4a2638daa18a9e4f35c4142ca454d4f8140f5dabeab73f084247107465eaac95b48fb31f7db2b409927aede1533
7
+ data.tar.gz: 316d73b300b658fb392e2af61049fadc48acc6f593dbbed58490019c03d5d48d4ec83358d766bb5a07337a96d2f3100f6ea1c7251e745a2b951b1df3613aa5a9
data/README.md CHANGED
@@ -42,7 +42,7 @@ Blipit.add_breadcrumb("cache cleared", category: "cache")
42
42
  Blipit.capture_security("login_failed", email, outcome: "wrong password", ip: request.remote_ip, user_agent: request.user_agent)
43
43
  ```
44
44
 
45
- `kind` is one of `login_failed`, `login_blocked`, `login_succeeded`, `password_reset` or any short name you choose. Failed and blocked logins are reported as warnings.
45
+ `kind` is one of `login_failed`, `login_blocked`, `login_succeeded`, `password_reset_requested` or `privilege_granted`; any other kind arrives as a plain message. Login attempts need the project's secret key (init with it on the server) and the Scale plan; with the public key ingest refuses them with 403 `security_needs_secret_key`.
46
46
 
47
47
  ## Performance
48
48
 
@@ -1,3 +1,3 @@
1
1
  module Blipit
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
data/lib/blipit.rb CHANGED
@@ -4,6 +4,9 @@ require_relative "blipit/version"
4
4
  module Blipit
5
5
  DEFAULT_ENDPOINT = "https://in.blipit.io"
6
6
  WARNING_KINDS = %w[login_failed login_blocked].freeze
7
+ PUBLIC_KEY_WARNING = "[blipit] login attempts need the project's secret key (blipit_sk_...). " \
8
+ "This SDK was started with the public key, so capture_security sends nothing. " \
9
+ "Use the secret key on the server."
7
10
 
8
11
  class << self
9
12
  def dsn(key, project, endpoint = DEFAULT_ENDPOINT)
@@ -14,6 +17,7 @@ module Blipit
14
17
 
15
18
  def init(key:, project:, environment: nil, release: nil, traces_sample_rate: 0.0, endpoint: DEFAULT_ENDPOINT, **options)
16
19
  raise ArgumentError, "Blipit.init needs the project's public key" if key.nil? || key.to_s.empty?
20
+ @public_key = key.to_s.start_with?("blipit_pk_")
17
21
  raise ArgumentError, "Blipit.init needs the project id" if project.nil? || project.to_s.empty?
18
22
 
19
23
  Sentry.init do |config|
@@ -48,6 +52,11 @@ module Blipit
48
52
  end
49
53
 
50
54
  def capture_security(kind, actor, outcome: nil, actor_id: nil, ip: nil, user_agent: nil, target: nil)
55
+ if @public_key
56
+ warn(PUBLIC_KEY_WARNING) unless @public_key_warned
57
+ @public_key_warned = true
58
+ return
59
+ end
51
60
  payload = {
52
61
  kind: kind,
53
62
  actor: actor,
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blipit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Louward Labs