smbcloud-auth 0.7.5 → 1.0.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 +4 -4
- data/Cargo.lock +211 -204
- data/README.md +1 -1
- data/Rakefile +2 -18
- data/ext/auth/Cargo.toml +5 -5
- data/ext/auth/extconf.rb +0 -12
- data/ext/auth/src/lib.rs +10 -4
- data/lib/auth/version.rb +1 -1
- data/lib/auth.rb +8 -1
- metadata +10 -7
- data/.rubocop.yml +0 -21
- data/.ruby-version +0 -1
- data/ext/auth/build.rs +0 -11
data/README.md
CHANGED
data/Rakefile
CHANGED
|
@@ -9,24 +9,8 @@ GEMSPEC = Gem::Specification.load('auth.gemspec')
|
|
|
9
9
|
|
|
10
10
|
RbSys::ExtensionTask.new('auth', GEMSPEC) do |ext|
|
|
11
11
|
ext.lib_dir = 'lib/auth'
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
# macOS: the rb_sys/rake-compiler build emits the bundle as an MH_DYLIB with an
|
|
15
|
-
# empty LC_ID_DYLIB install name (a plain `cargo build` does not). dyld on macOS
|
|
16
|
-
# 15+/Tahoe rejects that with "load command string extends beyond end of load
|
|
17
|
-
# command", so the gem fails to load. Stamp a valid install name onto every
|
|
18
|
-
# bundle the build produces by enhancing the bundle file tasks themselves (which
|
|
19
|
-
# is what `rake native gem` runs, not the top-level `compile`). install_name_tool
|
|
20
|
-
# re-signs ad-hoc, ships on the macOS gem-build runners, and works across archs
|
|
21
|
-
# (cross-built x86_64 bundles too). Idempotent.
|
|
22
|
-
if RbConfig::CONFIG['host_os'] =~ /darwin/
|
|
23
|
-
Rake::Task.tasks.each do |t|
|
|
24
|
-
next unless t.name.end_with?('auth.bundle')
|
|
25
|
-
|
|
26
|
-
t.enhance do
|
|
27
|
-
sh 'install_name_tool', '-id', '@rpath/auth.bundle', t.name if File.exist?(t.name)
|
|
28
|
-
end
|
|
29
|
-
end
|
|
12
|
+
ext.cross_compile = true
|
|
13
|
+
ext.cross_platform = %w[x86_64-linux aarch64-linux arm64-darwin x86_64-darwin]
|
|
30
14
|
end
|
|
31
15
|
|
|
32
16
|
task default: :compile
|
data/ext/auth/Cargo.toml
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[package]
|
|
2
2
|
name = "auth"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "1.0.0"
|
|
4
4
|
edition = "2024"
|
|
5
5
|
authors = ["Seto Elkahfi <seto@smbcloud.xyz>"]
|
|
6
6
|
publish = false
|
|
@@ -9,7 +9,7 @@ publish = false
|
|
|
9
9
|
crate-type = ["cdylib"]
|
|
10
10
|
|
|
11
11
|
[dependencies]
|
|
12
|
-
magnus = { version = "0.
|
|
12
|
+
magnus = { version = "0.8" }
|
|
13
13
|
serde = { version = "1", features = ["derive"] }
|
|
14
14
|
serde_json = "1"
|
|
15
15
|
tokio = { version = "1", features = ["rt-multi-thread"] }
|
|
@@ -17,6 +17,6 @@ tokio = { version = "1", features = ["rt-multi-thread"] }
|
|
|
17
17
|
# smbcloud-auth was split into smbcloud-auth-sdk (pure HTTP SDK, no CLI plumbing).
|
|
18
18
|
# smbcloud-networking is an internal dep of the old smbcloud-auth crate and is
|
|
19
19
|
# not re-exported by smbcloud-auth-sdk, so it is dropped here.
|
|
20
|
-
smbcloud-auth-sdk = { version = "0
|
|
21
|
-
smbcloud-model = { version = "0
|
|
22
|
-
smbcloud-network = { version = "0
|
|
20
|
+
smbcloud-auth-sdk = { version = "1.0" }
|
|
21
|
+
smbcloud-model = { version = "1.0" }
|
|
22
|
+
smbcloud-network = { version = "1.0" }
|
data/ext/auth/extconf.rb
CHANGED
|
@@ -4,15 +4,3 @@ require 'mkmf'
|
|
|
4
4
|
require 'rb_sys/mkmf'
|
|
5
5
|
|
|
6
6
|
create_rust_makefile('auth/auth')
|
|
7
|
-
|
|
8
|
-
# rb-sys (fixup_libnames) appends `install_name_tool -id "" $(DLLIB)` to the
|
|
9
|
-
# generated Makefile, blanking the bundle's LC_ID_DYLIB install name. dyld on
|
|
10
|
-
# macOS 26/27 rejects an empty dylib-ID string ("load command string extends
|
|
11
|
-
# beyond end of load command"), so the extension fails to dlopen. Rewrite that
|
|
12
|
-
# step to stamp a valid @rpath id instead. This covers the `gem install`
|
|
13
|
-
# (extconf) build path; the Rakefile covers `rake native gem` builds.
|
|
14
|
-
if RUBY_PLATFORM.include?('darwin') && File.exist?('Makefile')
|
|
15
|
-
makefile = File.read('Makefile')
|
|
16
|
-
patched = makefile.gsub('install_name_tool -id ""', 'install_name_tool -id "@rpath/auth.bundle"')
|
|
17
|
-
File.write('Makefile', patched) if patched != makefile
|
|
18
|
-
end
|
data/ext/auth/src/lib.rs
CHANGED
|
@@ -17,10 +17,16 @@ struct LoginPayload {
|
|
|
17
17
|
message: Option<String>,
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
+
// Every helper here runs on the Ruby thread that called into the extension
|
|
21
|
+
// (tokio's `block_on` stays on the calling thread), so the handle is available.
|
|
22
|
+
fn ruby() -> Ruby {
|
|
23
|
+
Ruby::get().expect("smbcloud-auth called outside a Ruby thread")
|
|
24
|
+
}
|
|
25
|
+
|
|
20
26
|
fn parse_environment(value: String) -> Result<Environment, Error> {
|
|
21
27
|
value.parse().map_err(|_| {
|
|
22
28
|
Error::new(
|
|
23
|
-
|
|
29
|
+
ruby().exception_arg_error(),
|
|
24
30
|
format!("invalid environment `{value}`, expected `dev` or `production`"),
|
|
25
31
|
)
|
|
26
32
|
})
|
|
@@ -32,7 +38,7 @@ where
|
|
|
32
38
|
{
|
|
33
39
|
let runtime = Runtime::new().map_err(|err| {
|
|
34
40
|
Error::new(
|
|
35
|
-
|
|
41
|
+
ruby().exception_runtime_error(),
|
|
36
42
|
format!("failed to initialize tokio runtime: {err}"),
|
|
37
43
|
)
|
|
38
44
|
})?;
|
|
@@ -42,7 +48,7 @@ where
|
|
|
42
48
|
fn to_json<T: Serialize>(value: &T) -> Result<String, Error> {
|
|
43
49
|
serde_json::to_string(value).map_err(|err| {
|
|
44
50
|
Error::new(
|
|
45
|
-
|
|
51
|
+
ruby().exception_runtime_error(),
|
|
46
52
|
format!("failed to serialize response: {err}"),
|
|
47
53
|
)
|
|
48
54
|
})
|
|
@@ -52,7 +58,7 @@ fn raise_error_response(error: ErrorResponse) -> Error {
|
|
|
52
58
|
let payload = serde_json::to_string(&error).unwrap_or_else(|_| {
|
|
53
59
|
"{\"error\":{\"error_code\":0,\"message\":\"Unknown error.\"}}".to_string()
|
|
54
60
|
});
|
|
55
|
-
Error::new(
|
|
61
|
+
Error::new(ruby().exception_runtime_error(), payload)
|
|
56
62
|
}
|
|
57
63
|
|
|
58
64
|
fn login_payload(status: AccountStatus) -> LoginPayload {
|
data/lib/auth/version.rb
CHANGED
data/lib/auth.rb
CHANGED
|
@@ -2,7 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
require 'json'
|
|
4
4
|
require_relative 'auth/version'
|
|
5
|
-
|
|
5
|
+
# Fat native gems ship one extension per Ruby minor (lib/auth/3.4/auth.bundle);
|
|
6
|
+
# source and single-ABI builds put it directly under lib/auth/.
|
|
7
|
+
begin
|
|
8
|
+
RUBY_VERSION =~ /(\d+\.\d+)/
|
|
9
|
+
require_relative "auth/#{Regexp.last_match(1)}/auth"
|
|
10
|
+
rescue LoadError
|
|
11
|
+
require_relative 'auth/auth'
|
|
12
|
+
end
|
|
6
13
|
|
|
7
14
|
module Auth
|
|
8
15
|
end
|
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: smbcloud-auth
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 1.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Seto Elkahfi
|
|
8
8
|
bindir: exe
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date: 2026-10-
|
|
10
|
+
date: 2026-10-31 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
13
|
name: json
|
|
@@ -29,14 +29,20 @@ dependencies:
|
|
|
29
29
|
requirements:
|
|
30
30
|
- - "~>"
|
|
31
31
|
- !ruby/object:Gem::Version
|
|
32
|
-
version: 0.9
|
|
32
|
+
version: '0.9'
|
|
33
|
+
- - ">="
|
|
34
|
+
- !ruby/object:Gem::Version
|
|
35
|
+
version: 0.9.130
|
|
33
36
|
type: :runtime
|
|
34
37
|
prerelease: false
|
|
35
38
|
version_requirements: !ruby/object:Gem::Requirement
|
|
36
39
|
requirements:
|
|
37
40
|
- - "~>"
|
|
38
41
|
- !ruby/object:Gem::Version
|
|
39
|
-
version: 0.9
|
|
42
|
+
version: '0.9'
|
|
43
|
+
- - ">="
|
|
44
|
+
- !ruby/object:Gem::Version
|
|
45
|
+
version: 0.9.130
|
|
40
46
|
description: Ruby bindings for smbCloud Auth, powered by the shared Rust SDK and a
|
|
41
47
|
native Magnus extension.
|
|
42
48
|
email:
|
|
@@ -46,8 +52,6 @@ extensions:
|
|
|
46
52
|
- ext/auth/extconf.rb
|
|
47
53
|
extra_rdoc_files: []
|
|
48
54
|
files:
|
|
49
|
-
- ".rubocop.yml"
|
|
50
|
-
- ".ruby-version"
|
|
51
55
|
- CHANGELOG.md
|
|
52
56
|
- Cargo.lock
|
|
53
57
|
- Cargo.toml
|
|
@@ -55,7 +59,6 @@ files:
|
|
|
55
59
|
- Rakefile
|
|
56
60
|
- ext/.keep
|
|
57
61
|
- ext/auth/Cargo.toml
|
|
58
|
-
- ext/auth/build.rs
|
|
59
62
|
- ext/auth/extconf.rb
|
|
60
63
|
- ext/auth/src/lib.rs
|
|
61
64
|
- lib/auth.rb
|
data/.rubocop.yml
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
AllCops:
|
|
2
|
-
TargetRubyVersion: 3.1
|
|
3
|
-
NewCops: enable
|
|
4
|
-
Exclude:
|
|
5
|
-
- "vendor/**/*"
|
|
6
|
-
- "tmp/**/*"
|
|
7
|
-
- "target/**/*"
|
|
8
|
-
- "pkg/**/*"
|
|
9
|
-
|
|
10
|
-
# Native extension wrapper gems use a bare `module Auth; end` stub at the
|
|
11
|
-
# top level so Magnus can register the native methods into the right namespace.
|
|
12
|
-
# Having both that stub and the real `SmbCloud::Auth` implementation in one
|
|
13
|
-
# file is intentional — splitting them would break the require chain.
|
|
14
|
-
Style/OneClassPerFile:
|
|
15
|
-
Enabled: false
|
|
16
|
-
|
|
17
|
-
# Yard / CHANGELOG serve as the documentation source for this gem.
|
|
18
|
-
# Requiring top-level doc comments on every module and class adds noise
|
|
19
|
-
# without benefit for a thin wrapper library.
|
|
20
|
-
Style/Documentation:
|
|
21
|
-
Enabled: false
|
data/.ruby-version
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
../../../.ruby-version
|
data/ext/auth/build.rs
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
fn main() {
|
|
2
|
-
// On macOS, a Rust `cdylib` is emitted with an empty LC_ID_DYLIB install
|
|
3
|
-
// name. The dyld in macOS 15+/Tahoe (Darwin 27) validates this strictly and
|
|
4
|
-
// refuses to load the resulting `.bundle` with:
|
|
5
|
-
// "load command #4 string extends beyond end of load command"
|
|
6
|
-
// Give the dylib a valid install name at link time so the Ruby extension
|
|
7
|
-
// loads on the stricter loader.
|
|
8
|
-
if std::env::var("CARGO_CFG_TARGET_OS").as_deref() == Ok("macos") {
|
|
9
|
-
println!("cargo:rustc-cdylib-link-arg=-Wl,-install_name,@rpath/auth.bundle");
|
|
10
|
-
}
|
|
11
|
-
}
|