Skip to content

Commit 59760d1

Browse files
committed
🏷️ RBS types
1 parent e6d1f2a commit 59760d1

File tree

7 files changed

+141
-0
lines changed

7 files changed

+141
-0
lines changed

sig/omniauth-ldap.rbs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Top-level signature file for the gem. Detailed signatures live in the files below:
2+
# - sig/omniauth/ldap/version.rbs
3+
# - sig/omniauth/ldap/adaptor.rbs
4+
# - sig/omniauth/strategies/ldap.rbs
5+
# This file is intentionally minimal to avoid duplicating declarations.

sig/omniauth/ldap/adaptor.rbs

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
module OmniAuth
2+
module LDAP
3+
class Adaptor
4+
class LdapError < ::StandardError
5+
end
6+
7+
class ConfigurationError < ::StandardError
8+
end
9+
10+
class AuthenticationError < ::StandardError
11+
end
12+
13+
class ConnectionError < ::StandardError
14+
end
15+
16+
VALID_ADAPTER_CONFIGURATION_KEYS: Array[Symbol]
17+
MUST_HAVE_KEYS: Array[untyped]
18+
METHOD: Hash[Symbol, Symbol?]
19+
20+
attr_accessor bind_dn: String?
21+
attr_accessor password: String?
22+
23+
# Net::LDAP is provided by the net-ldap gem; we reference it here for clarity.
24+
attr_reader connection: Net::LDAP
25+
attr_reader uid: String?
26+
attr_reader base: String?
27+
# auth is the hash passed to Net::LDAP#auth or similar
28+
attr_reader auth: Hash[Symbol, untyped]
29+
# filter is an LDAP filter string when configured
30+
attr_reader filter: String?
31+
32+
# Validate that required keys exist in the configuration
33+
def self.validate: (?Hash[Symbol, untyped]) -> void
34+
def initialize: (?Hash[Symbol, untyped]) -> void
35+
36+
# Perform a search and optionally bind; returns the matched entry or false
37+
def bind_as: (?Hash[Symbol, untyped]) -> (Net::LDAP::Entry? | false)
38+
39+
private
40+
41+
# Returns a Net::LDAP encryption symbol (e.g. :simple_tls, :start_tls) or nil
42+
def ensure_method: (untyped) -> Symbol?
43+
44+
# Returns an array of SASL auth hashes
45+
def sasl_auths: (?Hash[Symbol, untyped]) -> Array[Hash[Symbol, untyped]]
46+
47+
# Returns initial credential (string) and a proc that accepts a challenge and returns the response
48+
# Use Array[untyped] here to avoid tuple syntax issues in some linters; the runtime value
49+
# is commonly a two-element array [initial_credential, proc].
50+
def sasl_bind_setup_digest_md5: (?Hash[Symbol, untyped]) -> Array[untyped]
51+
def sasl_bind_setup_gss_spnego: (?Hash[Symbol, untyped]) -> Array[untyped]
52+
end
53+
end
54+
end

sig/omniauth/ldap/version.rbs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
module OmniAuth
2+
module LDAP
3+
module Version
4+
VERSION: String
5+
end
6+
7+
# Traditional constant alias
8+
VERSION: String
9+
end
10+
end
11+

sig/omniauth/strategies/ldap.rbs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
module OmniAuth
2+
module Strategies
3+
class LDAP
4+
OMNIAUTH_GTE_V2: bool
5+
6+
# CONFIG is a read-only mapping of string keys to mapping definitions
7+
CONFIG: Hash[String, untyped]
8+
9+
# The request_phase either returns a Rack-compatible response or the form response.
10+
def request_phase: () -> (Rack::Response | Array[untyped] | String)
11+
12+
# The callback_phase may call super (untyped) or return a failure symbol
13+
def callback_phase: () -> untyped
14+
15+
# Accepts an adaptor and returns a Net::LDAP::Filter or similar
16+
def filter: (OmniAuth::LDAP::Adaptor) -> Net::LDAP::Filter
17+
18+
# Map a user object (Net::LDAP::Entry-like) into a Hash for the auth info
19+
def self.map_user: (Hash[String, untyped], untyped) -> Hash[String, untyped]
20+
21+
def missing_credentials?: () -> bool
22+
end
23+
end
24+
end

sig/rbs/net-ldap.rbs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Minimal stubs for net-ldap types used by the gem
2+
module Net
3+
class LDAP
4+
def initialize: (Hash[Symbol, untyped]) -> void
5+
def open: () { (self) -> untyped } -> untyped
6+
def search: (?Hash[Symbol, untyped]) -> Array[Net::LDAP::Entry]
7+
def bind: (?Hash[Symbol, untyped]) -> bool
8+
end
9+
10+
class LDAP::Entry
11+
def dn: () -> String
12+
end
13+
14+
class LDAP::Filter
15+
def self.construct: (String) -> Net::LDAP::Filter
16+
def self.eq: (String, String) -> Net::LDAP::Filter
17+
end
18+
end
19+

sig/rbs/net-ntlm.rbs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Minimal stubs for net-ntlm types used by the gem
2+
module Net
3+
module NTLM
4+
class Message
5+
def self.parse: (untyped) -> Net::NTLM::Message
6+
def response: (?Hash[Symbol, untyped], ?Hash[Symbol, untyped]) -> Net::NTLM::Message
7+
end
8+
9+
class Message::Type1
10+
def serialize: () -> String
11+
end
12+
13+
def self.encode_utf16le: (String) -> String
14+
end
15+
end
16+

sig/rbs/sasl.rbs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Minimal stubs for SASL bindings used in tests
2+
module SASL
3+
class Preferences
4+
def initialize: (?Hash[Symbol, untyped]) -> void
5+
end
6+
7+
class SASL
8+
def initialize: (String, SASL::Preferences) -> void
9+
def receive: (String, untyped) -> [untyped, untyped]
10+
end
11+
end
12+

0 commit comments

Comments
 (0)