gitlab-glaz 0.0.1-arm64-darwin

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 131087981caf6d2c1f63451d10c0cc9accd8e63d189361bdb369d57d933cf2e2
4
+ data.tar.gz: df663e4ab85dd1501cad3860711f2f6531408ac61a11b18debcb7e0a117cdaa4
5
+ SHA512:
6
+ metadata.gz: 7a2967c556e83fe99b0edfc052c54e3268585758ee0fc9fdf82df624088b304e895b08a21f1bedfff547c20842c5470d2b3317bc3d8dce81b036f41d451ef840
7
+ data.tar.gz: b6424a88725993757055a273782d438775bd88f3d9354c826a9527be4c3403205be47ec93a2764672481687f6ca65963e6155310667887a89715ec7601d3a10a
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2024-present GitLab B.V.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,71 @@
1
+ # GitLab GLAZ Gem
2
+
3
+ > [!WARNING]
4
+ > This gem is currently designed entirely for internal use at GitLab.
5
+
6
+ Ruby bindings for the [Glaz](https://gitlab.com/gitlab-org/auth/glaz) authorization engine. It wraps the Rust-backed `glaz-ruby` crate via [Magnus](https://github.com/matsadler/magnus) FFI, exposing the Glaz `CheckEngine` to Ruby without leaving the Ruby process.
7
+
8
+ ## Requirements
9
+
10
+ - Ruby >= 3.1
11
+ - Rust toolchain (for building the native extension)
12
+
13
+ ## Installation
14
+
15
+ Add to your Gemfile:
16
+
17
+ ```ruby
18
+ gem 'gitlab-glaz', path: 'gems/gitlab-glaz'
19
+ ```
20
+
21
+ ## Building
22
+
23
+ The gem contains a Rust extension that must be compiled before use:
24
+
25
+ ```shell
26
+ bundle exec rake compile
27
+ ```
28
+
29
+ This compiles the Rust crate in `ext/glaz/` and places the resulting native library under `lib/glaz/`.
30
+
31
+ ## Usage
32
+
33
+ ```ruby
34
+ require 'gitlab-glaz'
35
+
36
+ # Use the Glaz CheckEngine via the compiled native extension
37
+ ```
38
+
39
+ ## Architecture
40
+
41
+ | Layer | Technology | Purpose |
42
+ | ------- | ----------- | --------- |
43
+ | Ruby API | `lib/gitlab-glaz.rb` | Entry point, loads the native extension |
44
+ | FFI bridge | [Magnus](https://github.com/matsadler/magnus) + [rb-sys](https://github.com/oxidize-rb/rb-sys) | Bridges Ruby ↔ Rust |
45
+ | Rust extension | `ext/glaz/` | Thin `#[magnus::init]` shim that delegates to `glaz-ruby` |
46
+ | Core engine | [`glaz-ruby`](https://gitlab.com/gitlab-org/auth/glaz) | Rust crate implementing the Glaz authorization engine |
47
+
48
+ ## Development
49
+
50
+ The workspace root [`Cargo.toml`](Cargo.toml) declares all shared Rust dependencies. The extension crate lives in [`ext/glaz/`](ext/glaz/).
51
+
52
+ To build only the Rust extension:
53
+
54
+ ```shell
55
+ cargo build --release
56
+ ```
57
+
58
+ To run the full compile via Rake (used during gem installation):
59
+
60
+ ```shell
61
+ bundle exec rake
62
+ ```
63
+
64
+ ## Releasing a new version
65
+
66
+ To release a new version, create a merge request and use the `Release` template, following its instructions.
67
+ Once merged, the new version with precompiled, native gems will automatically be published to RubyGems.
68
+
69
+ ## License
70
+
71
+ Released under the [MIT License](LICENSE).
@@ -0,0 +1,12 @@
1
+ [package]
2
+ name = "glaz"
3
+ version.workspace = true
4
+ edition.workspace = true
5
+
6
+ [lib]
7
+ name = "glaz"
8
+ crate-type = ["cdylib"]
9
+
10
+ [dependencies]
11
+ glaz-module = { workspace = true }
12
+ magnus = { workspace = true }
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "mkmf"
4
+ require "rb_sys/mkmf"
5
+
6
+ create_rust_makefile("gitlab/glaz/glaz") do |r|
7
+ r.auto_install_rust_toolchain = true
8
+ end
@@ -0,0 +1,48 @@
1
+ use magnus::{Error, Ruby, exception, prelude::*};
2
+
3
+ #[magnus::wrap(class = "Glaz::Engine::CheckPermission")]
4
+ struct CheckPermission {
5
+ engine: glaz_module::PermissionCheckEngine,
6
+ }
7
+
8
+ impl CheckPermission {
9
+ fn initialize() -> Result<Self, Error> {
10
+ glaz_module::PermissionCheckEngine::new()
11
+ .map(|engine| Self { engine })
12
+ .map_err(|e| Error::new(exception::runtime_error(), format!("{e}")))
13
+ }
14
+
15
+ fn check_permission(&self, proto_bytes: magnus::RString) -> Result<magnus::RHash, Error> {
16
+ let bytes = unsafe { proto_bytes.as_slice() };
17
+
18
+ let result = self.engine.check_permission(bytes).map_err(map_error)?;
19
+
20
+ let ruby = Ruby::get()
21
+ .map_err(|_| Error::new(exception::runtime_error(), "Ruby runtime unavailable"))?;
22
+ let hash = ruby.hash_new();
23
+ hash.aset(ruby.sym_new("allowed"), result.allowed)?;
24
+ hash.aset(ruby.sym_new("reason"), result.reason)?;
25
+ Ok(hash)
26
+ }
27
+ }
28
+
29
+ fn map_error(e: glaz_module::GlazError) -> Error {
30
+ use glaz_module::GlazError::*;
31
+ match e {
32
+ InvalidArgument(_) => Error::new(exception::arg_error(), format!("{e}")),
33
+ Runtime(_) => Error::new(exception::runtime_error(), format!("{e}")),
34
+ }
35
+ }
36
+
37
+ #[magnus::init]
38
+ fn init(ruby: &Ruby) -> Result<(), Error> {
39
+ let glaz = ruby.define_module("Glaz")?;
40
+ let engine = glaz.define_module("Engine")?;
41
+ let class = engine.define_class("CheckPermission", ruby.class_object())?;
42
+ class.define_singleton_method("new", magnus::function!(CheckPermission::initialize, 0))?;
43
+ class.define_method(
44
+ "check_permission",
45
+ magnus::method!(CheckPermission::check_permission, 1),
46
+ )?;
47
+ Ok(())
48
+ }
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Native-gem installs ship a per-Ruby-ABI .so under lib/gitlab/glaz/<X.Y>/glaz.so.
4
+ # Source-gem installs (or local `rake compile` output) put it at lib/gitlab/glaz/glaz.{so,bundle}.
5
+ # Try the version-specific path first, fall back to the flat layout.
6
+ def load_rust_extension
7
+ ruby_version = /(\d+\.\d+)/.match(RUBY_VERSION)
8
+ require "gitlab/glaz/#{ruby_version}/glaz"
9
+ rescue LoadError
10
+ require "gitlab/glaz/glaz"
11
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Gitlab
4
+ module Glaz
5
+ VERSION = "0.0.1"
6
+ end
7
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "glaz/version"
4
+ require_relative 'glaz/loader'
5
+ require "proto/service_pb"
6
+
7
+ load_rust_extension
8
+
9
+ module Gitlab
10
+ module Glaz
11
+ module_function
12
+
13
+ def check_permission(subject_uuid:, object_uuid:, permission:, context: {})
14
+ request = ::Glaz::CheckPermissionRequest.encode(
15
+ ::Glaz::CheckPermissionRequest.new(
16
+ subject: subject_uuid,
17
+ object: object_uuid,
18
+ permission: permission,
19
+ context: context.to_json
20
+ )
21
+ )
22
+
23
+ ::Glaz::Engine::CheckPermission.new.check_permission(request)
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
4
+ # source: service.proto
5
+
6
+ require 'google/protobuf'
7
+
8
+ descriptor_data = "\n\rservice.proto\x12\x04glaz\"?\n\x0e\x45xplainRequest\x12\x0f\n\x07subject\x18\x01 \x01(\t\x12\x0e\n\x06object\x18\x02 \x01(\t\x12\x0c\n\x04role\x18\x03 \x01(\x05\"2\n\x0f\x45xplainResponse\x12\x0f\n\x07\x61llowed\x18\x01 \x01(\x08\x12\x0e\n\x06reason\x18\x02 \x01(\t\"2\n\x0f\x45valuateRequest\x12\x0f\n\x07subject\x18\x01 \x01(\t\x12\x0e\n\x06object\x18\x02 \x01(\t\"3\n\x10\x45valuateResponse\x12\x0f\n\x07\x61llowed\x18\x01 \x01(\x08\x12\x0e\n\x06reason\x18\x02 \x01(\t\"^\n\x16\x43heckPermissionRequest\x12\x0f\n\x07subject\x18\x01 \x01(\t\x12\x0e\n\x06object\x18\x02 \x01(\t\x12\x12\n\npermission\x18\x03 \x01(\t\x12\x0f\n\x07\x63ontext\x18\x04 \x01(\t\":\n\x17\x43heckPermissionResponse\x12\x0f\n\x07\x61llowed\x18\x01 \x01(\x08\x12\x0e\n\x06reason\x18\x02 \x01(\t2\xd9\x01\n\x14\x41uthorizationService\x12\x36\n\x07\x45xplain\x12\x14.glaz.ExplainRequest\x1a\x15.glaz.ExplainResponse\x12\x39\n\x08\x45valuate\x12\x15.glaz.EvaluateRequest\x1a\x16.glaz.EvaluateResponse\x12N\n\x0f\x43heckPermission\x12\x1c.glaz.CheckPermissionRequest\x1a\x1d.glaz.CheckPermissionResponseb\x06proto3"
9
+
10
+ pool = ::Google::Protobuf::DescriptorPool.generated_pool
11
+ pool.add_serialized_file(descriptor_data)
12
+
13
+ module Glaz
14
+ ExplainRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("glaz.ExplainRequest").msgclass
15
+ ExplainResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("glaz.ExplainResponse").msgclass
16
+ EvaluateRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("glaz.EvaluateRequest").msgclass
17
+ EvaluateResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("glaz.EvaluateResponse").msgclass
18
+ CheckPermissionRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("glaz.CheckPermissionRequest").msgclass
19
+ CheckPermissionResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("glaz.CheckPermissionResponse").msgclass
20
+ end
metadata ADDED
@@ -0,0 +1,131 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gitlab-glaz
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: arm64-darwin
6
+ authors:
7
+ - group::authorization
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2026-05-20 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: google-protobuf
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '3.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '3.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rb_sys
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 0.9.126
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 0.9.126
41
+ - !ruby/object:Gem::Dependency
42
+ name: gitlab-styles
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '14.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '14.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.12'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.12'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rubocop
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.81'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.81'
83
+ description: Wraps the Rust-backed GitLab Authorization Service (GLAZ) exposed via
84
+ magnus FFI
85
+ email:
86
+ - engineering@gitlab.com
87
+ executables: []
88
+ extensions: []
89
+ extra_rdoc_files: []
90
+ files:
91
+ - LICENSE
92
+ - README.md
93
+ - ext/glaz/Cargo.toml
94
+ - ext/glaz/extconf.rb
95
+ - ext/glaz/src/lib.rs
96
+ - lib/gitlab/glaz.rb
97
+ - lib/gitlab/glaz/3.1/glaz.bundle
98
+ - lib/gitlab/glaz/3.2/glaz.bundle
99
+ - lib/gitlab/glaz/3.3/glaz.bundle
100
+ - lib/gitlab/glaz/3.4/glaz.bundle
101
+ - lib/gitlab/glaz/4.0/glaz.bundle
102
+ - lib/gitlab/glaz/loader.rb
103
+ - lib/gitlab/glaz/version.rb
104
+ - lib/proto/service_pb.rb
105
+ homepage: https://gitlab.com/gitlab-org/ruby/gems/gitlab-glaz
106
+ licenses:
107
+ - MIT
108
+ metadata: {}
109
+ post_install_message:
110
+ rdoc_options: []
111
+ require_paths:
112
+ - lib
113
+ required_ruby_version: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '3.1'
118
+ - - "<"
119
+ - !ruby/object:Gem::Version
120
+ version: 4.1.dev
121
+ required_rubygems_version: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - ">="
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ requirements: []
127
+ rubygems_version: 3.5.23
128
+ signing_key:
129
+ specification_version: 4
130
+ summary: Ruby client for the GLAZ authorization engine
131
+ test_files: []