better_auth-sinatra 0.1.0 → 0.5.0

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: c8cfbde43e94311d211b9d355ed4fed778af108b0f6d149e4b3a6611ab3f9e90
4
- data.tar.gz: 95e66c4b67168cfcb669ecfcf3aaa65798cbec20e8fd1d3b19e2833209520f0d
3
+ metadata.gz: 6e397c76a26c557d40766a167af0802864e065505fefbd287449bc703ac53ae5
4
+ data.tar.gz: daee9e299b6a30d4ac8d3746cc53fd874fcee622c48770d6f1adfa0cd242dffc
5
5
  SHA512:
6
- metadata.gz: d158fe7e73c3a9622ebee45408fe2e6762f6372c36c310bf7b79cc1b58454c0cf507c4656d44bbbf49a7d95f84a41da1c3662bebf357fa0f9a1ddcac97e88115
7
- data.tar.gz: 78125ddabbd5ea6fa93bf2f7447154ef1ba9f308bfc71c0244bdc99f970fe309488829c84bf19b7b7bce7007a11302f1f869fc19da3d57994d601d08ce9380a7
6
+ metadata.gz: b483064bb5e5eb20665716b6ebff6fe5945248565663586f4dbc5d8335b1dc10e3485820f8214d6a278aee2667d72accbe18fb009d491a8fc90bbdb185a00265
7
+ data.tar.gz: b4455e509198c51fe568001ffb791f66e26ef323b55b7f37906540b0513be2a1669bf81ea91ebe3f6356edd9e44d645b990e3a64844460ffc914f570082fc964
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.1.1 - 2026-04-29
4
+
5
+ - Fixed mounted base-path propagation when creating the Sinatra auth instance.
6
+ - Fixed session helper request preparation and migration dialect normalization for PostgreSQL and SQLite aliases.
7
+
3
8
  ## 0.1.0
4
9
 
5
10
  - Initial Sinatra adapter.
@@ -14,7 +14,7 @@ module BetterAuth
14
14
  config = BetterAuth::Sinatra.configuration.copy
15
15
  yield config if block_given?
16
16
  config.base_path = mount_path
17
- options = config.to_auth_options.merge(overrides)
17
+ options = config.to_auth_options.merge(overrides).merge(base_path: mount_path)
18
18
  auth_instance = auth || BetterAuth.auth(options)
19
19
 
20
20
  set :better_auth_auth, auth_instance
@@ -32,6 +32,8 @@ module BetterAuth
32
32
  end
33
33
 
34
34
  def resolve_better_auth_session
35
+ auth = better_auth_auth
36
+ auth.context.prepare_for_request!(request) if auth.context.respond_to?(:prepare_for_request!)
35
37
  context = BetterAuth::Endpoint::Context.new(
36
38
  path: request.path_info,
37
39
  method: request.request_method,
@@ -39,7 +41,7 @@ module BetterAuth
39
41
  body: {},
40
42
  params: params,
41
43
  headers: {"cookie" => request.env["HTTP_COOKIE"]},
42
- context: better_auth_auth.context,
44
+ context: auth.context,
43
45
  request: request
44
46
  )
45
47
  BetterAuth::Session.find_current(context, disable_refresh: true)
@@ -12,6 +12,7 @@ module BetterAuth
12
12
  module_function
13
13
 
14
14
  def render(options, dialect:)
15
+ dialect = normalize_dialect(dialect)
15
16
  config = configuration_for(options)
16
17
  statements = BetterAuth::Schema::SQL.create_statements(config, dialect: dialect)
17
18
  [
@@ -24,6 +25,7 @@ module BetterAuth
24
25
  end
25
26
 
26
27
  def generate(options, dialect:, migrations_path: DEFAULT_MIGRATIONS_PATH, timestamp: Time.now.utc.strftime("%Y%m%d%H%M%S"))
28
+ dialect = normalize_dialect(dialect)
27
29
  FileUtils.mkdir_p(migrations_path)
28
30
  path = File.join(migrations_path, "#{timestamp}_create_better_auth_tables.sql")
29
31
  return path if File.exist?(path)
@@ -40,7 +42,7 @@ module BetterAuth
40
42
  end
41
43
 
42
44
  connection = adapter.connection
43
- dialect = adapter.dialect.to_sym
45
+ dialect = normalize_dialect(adapter.dialect)
44
46
  files = Dir[File.join(migrations_path, "*.sql")].sort
45
47
  ensure_schema_migrations!(connection, dialect)
46
48
  applied = applied_migrations(connection, dialect)
@@ -117,6 +119,17 @@ module BetterAuth
117
119
  def literal(value)
118
120
  "'#{value.to_s.gsub("'", "''")}'"
119
121
  end
122
+
123
+ def normalize_dialect(value)
124
+ case value.to_s.downcase
125
+ when "postgresql"
126
+ :postgres
127
+ when "sqlite3"
128
+ :sqlite
129
+ else
130
+ value.to_sym
131
+ end
132
+ end
120
133
  end
121
134
  end
122
135
  end
@@ -23,7 +23,7 @@ namespace :better_auth do
23
23
  desc "Create the Better Auth SQL migration"
24
24
  task :migration do
25
25
  BetterAuth::Sinatra.load_app_config
26
- dialect = ENV.fetch("BETTER_AUTH_DIALECT", "postgres").to_sym
26
+ dialect = BetterAuth::Sinatra::Migration.normalize_dialect(ENV["BETTER_AUTH_DIALECT"] || ENV["BETTER_AUTH_DATABASE_DIALECT"] || "postgres")
27
27
  config = BetterAuth::Sinatra.migration_configuration
28
28
  path = BetterAuth::Sinatra::Migration.generate(config, dialect: dialect)
29
29
  puts "create #{path}"
@@ -2,6 +2,6 @@
2
2
 
3
3
  module BetterAuth
4
4
  module Sinatra
5
- VERSION = "0.1.0"
5
+ VERSION = "0.5.0"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: better_auth-sinatra
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sebastian Sala