Function bodies 2,478 total
fetch_jwks method · ruby · L79-L90 (12 LOC)lib/magi/archive/mcp/auth.rb
def fetch_jwks(force: false)
return @jwks_cache if jwks_cache_valid? && !force
url = config.url_for("/.well-known/jwks.json")
http_client = configure_ssl(HTTP)
response = http_client.get(url)
unless response.status.success?
raise JWKSError,
"JWKS fetch failed: HTTP #{response.code}"
endfetch_jwks method · ruby · L79-L90 (12 LOC)lib/magi/archive/mcp/auth.rb
def fetch_jwks(force: false)
return @jwks_cache if jwks_cache_valid? && !force
url = config.url_for("/.well-known/jwks.json")
http_client = configure_ssl(HTTP)
response = http_client.get(url)
unless response.status.success?
raise JWKSError,
"JWKS fetch failed: HTTP #{response.code}"
endfetch_jwks method · ruby · L79-L90 (12 LOC)lib/magi/archive/mcp/auth.rb
def fetch_jwks(force: false)
return @jwks_cache if jwks_cache_valid? && !force
url = config.url_for("/.well-known/jwks.json")
http_client = configure_ssl(HTTP)
response = http_client.get(url)
unless response.status.success?
raise JWKSError,
"JWKS fetch failed: HTTP #{response.code}"
endfetch_jwks method · ruby · L79-L90 (12 LOC)lib/magi/archive/mcp/auth.rb
def fetch_jwks(force: false)
return @jwks_cache if jwks_cache_valid? && !force
url = config.url_for("/.well-known/jwks.json")
http_client = configure_ssl(HTTP)
response = http_client.get(url)
unless response.status.success?
raise JWKSError,
"JWKS fetch failed: HTTP #{response.code}"
endfetch_jwks method · ruby · L79-L90 (12 LOC)lib/magi/archive/mcp/auth.rb
def fetch_jwks(force: false)
return @jwks_cache if jwks_cache_valid? && !force
url = config.url_for("/.well-known/jwks.json")
http_client = configure_ssl(HTTP)
response = http_client.get(url)
unless response.status.success?
raise JWKSError,
"JWKS fetch failed: HTTP #{response.code}"
endfetch_jwks method · ruby · L79-L90 (12 LOC)lib/magi/archive/mcp/auth.rb
def fetch_jwks(force: false)
return @jwks_cache if jwks_cache_valid? && !force
url = config.url_for("/.well-known/jwks.json")
http_client = configure_ssl(HTTP)
response = http_client.get(url)
unless response.status.success?
raise JWKSError,
"JWKS fetch failed: HTTP #{response.code}"
endverify_token method · ruby · L108-L141 (34 LOC)lib/magi/archive/mcp/auth.rb
def verify_token(token)
# Decode header to get kid (key ID)
header = JWT.decode(token, nil, false)[1]
kid = header["kid"]
raise VerificationError, "Token missing kid claim" unless kid
# Find matching public key in JWKS
jwks = fetch_jwks
jwk = jwks.find { |k| k["kid"] == kid }
raise VerificationError, "No matching key found for kid: #{kid}" unless jwk
# Convert JWK to public key
public_key = jwk_to_public_key(jwk)
# Verify token
payload, = JWT.decode(
token,
public_key,
true,
{
algorithm: "RS256",
iss: config.issuer,
verify_iss: true,
verify_iat: true,
verify_exp: true
}
)
payload
rescue JWT::DecodeError => e
raise VerificationError, "Token verification failed: #{e.message}"
endMethodology: Repobility · https://repobility.com/research/state-of-ai-code-2026/
verify_token method · ruby · L108-L141 (34 LOC)lib/magi/archive/mcp/auth.rb
def verify_token(token)
# Decode header to get kid (key ID)
header = JWT.decode(token, nil, false)[1]
kid = header["kid"]
raise VerificationError, "Token missing kid claim" unless kid
# Find matching public key in JWKS
jwks = fetch_jwks
jwk = jwks.find { |k| k["kid"] == kid }
raise VerificationError, "No matching key found for kid: #{kid}" unless jwk
# Convert JWK to public key
public_key = jwk_to_public_key(jwk)
# Verify token
payload, = JWT.decode(
token,
public_key,
true,
{
algorithm: "RS256",
iss: config.issuer,
verify_iss: true,
verify_iat: true,
verify_exp: true
}
)
payload
rescue JWT::DecodeError => e
raise VerificationError, "Token verification failed: #{e.message}"
endverify_token method · ruby · L108-L141 (34 LOC)lib/magi/archive/mcp/auth.rb
def verify_token(token)
# Decode header to get kid (key ID)
header = JWT.decode(token, nil, false)[1]
kid = header["kid"]
raise VerificationError, "Token missing kid claim" unless kid
# Find matching public key in JWKS
jwks = fetch_jwks
jwk = jwks.find { |k| k["kid"] == kid }
raise VerificationError, "No matching key found for kid: #{kid}" unless jwk
# Convert JWK to public key
public_key = jwk_to_public_key(jwk)
# Verify token
payload, = JWT.decode(
token,
public_key,
true,
{
algorithm: "RS256",
iss: config.issuer,
verify_iss: true,
verify_iat: true,
verify_exp: true
}
)
payload
rescue JWT::DecodeError => e
raise VerificationError, "Token verification failed: #{e.message}"
endverify_token method · ruby · L108-L141 (34 LOC)lib/magi/archive/mcp/auth.rb
def verify_token(token)
# Decode header to get kid (key ID)
header = JWT.decode(token, nil, false)[1]
kid = header["kid"]
raise VerificationError, "Token missing kid claim" unless kid
# Find matching public key in JWKS
jwks = fetch_jwks
jwk = jwks.find { |k| k["kid"] == kid }
raise VerificationError, "No matching key found for kid: #{kid}" unless jwk
# Convert JWK to public key
public_key = jwk_to_public_key(jwk)
# Verify token
payload, = JWT.decode(
token,
public_key,
true,
{
algorithm: "RS256",
iss: config.issuer,
verify_iss: true,
verify_iat: true,
verify_exp: true
}
)
payload
rescue JWT::DecodeError => e
raise VerificationError, "Token verification failed: #{e.message}"
endverify_token method · ruby · L108-L141 (34 LOC)lib/magi/archive/mcp/auth.rb
def verify_token(token)
# Decode header to get kid (key ID)
header = JWT.decode(token, nil, false)[1]
kid = header["kid"]
raise VerificationError, "Token missing kid claim" unless kid
# Find matching public key in JWKS
jwks = fetch_jwks
jwk = jwks.find { |k| k["kid"] == kid }
raise VerificationError, "No matching key found for kid: #{kid}" unless jwk
# Convert JWK to public key
public_key = jwk_to_public_key(jwk)
# Verify token
payload, = JWT.decode(
token,
public_key,
true,
{
algorithm: "RS256",
iss: config.issuer,
verify_iss: true,
verify_iat: true,
verify_exp: true
}
)
payload
rescue JWT::DecodeError => e
raise VerificationError, "Token verification failed: #{e.message}"
endverify_token method · ruby · L108-L141 (34 LOC)lib/magi/archive/mcp/auth.rb
def verify_token(token)
# Decode header to get kid (key ID)
header = JWT.decode(token, nil, false)[1]
kid = header["kid"]
raise VerificationError, "Token missing kid claim" unless kid
# Find matching public key in JWKS
jwks = fetch_jwks
jwk = jwks.find { |k| k["kid"] == kid }
raise VerificationError, "No matching key found for kid: #{kid}" unless jwk
# Convert JWK to public key
public_key = jwk_to_public_key(jwk)
# Verify token
payload, = JWT.decode(
token,
public_key,
true,
{
algorithm: "RS256",
iss: config.issuer,
verify_iss: true,
verify_iat: true,
verify_exp: true
}
)
payload
rescue JWT::DecodeError => e
raise VerificationError, "Token verification failed: #{e.message}"
endverify_token method · ruby · L108-L141 (34 LOC)lib/magi/archive/mcp/auth.rb
def verify_token(token)
# Decode header to get kid (key ID)
header = JWT.decode(token, nil, false)[1]
kid = header["kid"]
raise VerificationError, "Token missing kid claim" unless kid
# Find matching public key in JWKS
jwks = fetch_jwks
jwk = jwks.find { |k| k["kid"] == kid }
raise VerificationError, "No matching key found for kid: #{kid}" unless jwk
# Convert JWK to public key
public_key = jwk_to_public_key(jwk)
# Verify token
payload, = JWT.decode(
token,
public_key,
true,
{
algorithm: "RS256",
iss: config.issuer,
verify_iss: true,
verify_iat: true,
verify_exp: true
}
)
payload
rescue JWT::DecodeError => e
raise VerificationError, "Token verification failed: #{e.message}"
endrefresh_token! method · ruby · L146-L150 (5 LOC)lib/magi/archive/mcp/auth.rb
def refresh_token!
@token = nil
@token_expires_at = nil
token
endrefresh_token! method · ruby · L146-L150 (5 LOC)lib/magi/archive/mcp/auth.rb
def refresh_token!
@token = nil
@token_expires_at = nil
token
endAbout: code-quality intelligence by Repobility · https://repobility.com
refresh_token! method · ruby · L146-L150 (5 LOC)lib/magi/archive/mcp/auth.rb
def refresh_token!
@token = nil
@token_expires_at = nil
token
endrefresh_token! method · ruby · L146-L150 (5 LOC)lib/magi/archive/mcp/auth.rb
def refresh_token!
@token = nil
@token_expires_at = nil
token
endrefresh_token! method · ruby · L146-L150 (5 LOC)lib/magi/archive/mcp/auth.rb
def refresh_token!
@token = nil
@token_expires_at = nil
token
endrefresh_token! method · ruby · L146-L150 (5 LOC)lib/magi/archive/mcp/auth.rb
def refresh_token!
@token = nil
@token_expires_at = nil
token
endrefresh_token! method · ruby · L146-L150 (5 LOC)lib/magi/archive/mcp/auth.rb
def refresh_token!
@token = nil
@token_expires_at = nil
token
endclear_cache! method · ruby · L153-L160 (8 LOC)lib/magi/archive/mcp/auth.rb
def clear_cache!
@token = nil
@token_expires_at = nil
@username = nil
@resolved_role = nil
@jwks_cache = nil
@jwks_cached_at = nil
endclear_cache! method · ruby · L153-L160 (8 LOC)lib/magi/archive/mcp/auth.rb
def clear_cache!
@token = nil
@token_expires_at = nil
@username = nil
@resolved_role = nil
@jwks_cache = nil
@jwks_cached_at = nil
endclear_cache! method · ruby · L153-L160 (8 LOC)lib/magi/archive/mcp/auth.rb
def clear_cache!
@token = nil
@token_expires_at = nil
@username = nil
@resolved_role = nil
@jwks_cache = nil
@jwks_cached_at = nil
endWant fix-PRs on findings? Install Repobility's GitHub App · github.com/apps/repobility-bot
clear_cache! method · ruby · L153-L160 (8 LOC)lib/magi/archive/mcp/auth.rb
def clear_cache!
@token = nil
@token_expires_at = nil
@username = nil
@resolved_role = nil
@jwks_cache = nil
@jwks_cached_at = nil
endclear_cache! method · ruby · L153-L160 (8 LOC)lib/magi/archive/mcp/auth.rb
def clear_cache!
@token = nil
@token_expires_at = nil
@username = nil
@resolved_role = nil
@jwks_cache = nil
@jwks_cached_at = nil
endclear_cache! method · ruby · L153-L160 (8 LOC)lib/magi/archive/mcp/auth.rb
def clear_cache!
@token = nil
@token_expires_at = nil
@username = nil
@resolved_role = nil
@jwks_cache = nil
@jwks_cached_at = nil
endclear_cache! method · ruby · L153-L160 (8 LOC)lib/magi/archive/mcp/auth.rb
def clear_cache!
@token = nil
@token_expires_at = nil
@username = nil
@resolved_role = nil
@jwks_cache = nil
@jwks_cached_at = nil
endjwks_cache_valid? method · ruby · L165-L169 (5 LOC)lib/magi/archive/mcp/auth.rb
def jwks_cache_valid?
return false if @jwks_cache.nil? || @jwks_cached_at.nil?
Time.now < (@jwks_cached_at + config.jwks_cache_ttl)
endjwks_cache_valid? method · ruby · L165-L169 (5 LOC)lib/magi/archive/mcp/auth.rb
def jwks_cache_valid?
return false if @jwks_cache.nil? || @jwks_cached_at.nil?
Time.now < (@jwks_cached_at + config.jwks_cache_ttl)
endjwks_cache_valid? method · ruby · L165-L169 (5 LOC)lib/magi/archive/mcp/auth.rb
def jwks_cache_valid?
return false if @jwks_cache.nil? || @jwks_cached_at.nil?
Time.now < (@jwks_cached_at + config.jwks_cache_ttl)
endjwks_cache_valid? method · ruby · L165-L169 (5 LOC)lib/magi/archive/mcp/auth.rb
def jwks_cache_valid?
return false if @jwks_cache.nil? || @jwks_cached_at.nil?
Time.now < (@jwks_cached_at + config.jwks_cache_ttl)
endRepobility · severity-and-effort ranking · https://repobility.com
jwks_cache_valid? method · ruby · L165-L169 (5 LOC)lib/magi/archive/mcp/auth.rb
def jwks_cache_valid?
return false if @jwks_cache.nil? || @jwks_cached_at.nil?
Time.now < (@jwks_cached_at + config.jwks_cache_ttl)
endjwks_cache_valid? method · ruby · L165-L169 (5 LOC)lib/magi/archive/mcp/auth.rb
def jwks_cache_valid?
return false if @jwks_cache.nil? || @jwks_cached_at.nil?
Time.now < (@jwks_cached_at + config.jwks_cache_ttl)
endjwks_cache_valid? method · ruby · L165-L169 (5 LOC)lib/magi/archive/mcp/auth.rb
def jwks_cache_valid?
return false if @jwks_cache.nil? || @jwks_cached_at.nil?
Time.now < (@jwks_cached_at + config.jwks_cache_ttl)
endfetch_token method · ruby · L173-L188 (16 LOC)lib/magi/archive/mcp/auth.rb
def fetch_token
url = config.url_for("/auth")
payload = config.auth_payload
http_client = configure_ssl(HTTP)
response = http_client.post(
url,
json: payload,
headers: { "Content-Type" => "application/json" }
)
unless response.status.success?
error_msg = parse_error_response(response)
raise AuthenticationError,
"Token fetch failed (HTTP #{response.code}): #{error_msg}"
endfetch_token method · ruby · L173-L188 (16 LOC)lib/magi/archive/mcp/auth.rb
def fetch_token
url = config.url_for("/auth")
payload = config.auth_payload
http_client = configure_ssl(HTTP)
response = http_client.post(
url,
json: payload,
headers: { "Content-Type" => "application/json" }
)
unless response.status.success?
error_msg = parse_error_response(response)
raise AuthenticationError,
"Token fetch failed (HTTP #{response.code}): #{error_msg}"
endfetch_token method · ruby · L173-L188 (16 LOC)lib/magi/archive/mcp/auth.rb
def fetch_token
url = config.url_for("/auth")
payload = config.auth_payload
http_client = configure_ssl(HTTP)
response = http_client.post(
url,
json: payload,
headers: { "Content-Type" => "application/json" }
)
unless response.status.success?
error_msg = parse_error_response(response)
raise AuthenticationError,
"Token fetch failed (HTTP #{response.code}): #{error_msg}"
endfetch_token method · ruby · L173-L188 (16 LOC)lib/magi/archive/mcp/auth.rb
def fetch_token
url = config.url_for("/auth")
payload = config.auth_payload
http_client = configure_ssl(HTTP)
response = http_client.post(
url,
json: payload,
headers: { "Content-Type" => "application/json" }
)
unless response.status.success?
error_msg = parse_error_response(response)
raise AuthenticationError,
"Token fetch failed (HTTP #{response.code}): #{error_msg}"
endfetch_token method · ruby · L173-L188 (16 LOC)lib/magi/archive/mcp/auth.rb
def fetch_token
url = config.url_for("/auth")
payload = config.auth_payload
http_client = configure_ssl(HTTP)
response = http_client.post(
url,
json: payload,
headers: { "Content-Type" => "application/json" }
)
unless response.status.success?
error_msg = parse_error_response(response)
raise AuthenticationError,
"Token fetch failed (HTTP #{response.code}): #{error_msg}"
endMethodology: Repobility · https://repobility.com/research/state-of-ai-code-2026/
fetch_token method · ruby · L173-L188 (16 LOC)lib/magi/archive/mcp/auth.rb
def fetch_token
url = config.url_for("/auth")
payload = config.auth_payload
http_client = configure_ssl(HTTP)
response = http_client.post(
url,
json: payload,
headers: { "Content-Type" => "application/json" }
)
unless response.status.success?
error_msg = parse_error_response(response)
raise AuthenticationError,
"Token fetch failed (HTTP #{response.code}): #{error_msg}"
endfetch_token method · ruby · L173-L188 (16 LOC)lib/magi/archive/mcp/auth.rb
def fetch_token
url = config.url_for("/auth")
payload = config.auth_payload
http_client = configure_ssl(HTTP)
response = http_client.post(
url,
json: payload,
headers: { "Content-Type" => "application/json" }
)
unless response.status.success?
error_msg = parse_error_response(response)
raise AuthenticationError,
"Token fetch failed (HTTP #{response.code}): #{error_msg}"
endparse_error_response method · ruby · L207-L212 (6 LOC)lib/magi/archive/mcp/auth.rb
def parse_error_response(response)
data = JSON.parse(response.body.to_s)
data["error"] || data["message"] || "Unknown error"
rescue JSON::ParserError
response.body.to_s
endparse_error_response method · ruby · L207-L212 (6 LOC)lib/magi/archive/mcp/auth.rb
def parse_error_response(response)
data = JSON.parse(response.body.to_s)
data["error"] || data["message"] || "Unknown error"
rescue JSON::ParserError
response.body.to_s
endparse_error_response method · ruby · L207-L212 (6 LOC)lib/magi/archive/mcp/auth.rb
def parse_error_response(response)
data = JSON.parse(response.body.to_s)
data["error"] || data["message"] || "Unknown error"
rescue JSON::ParserError
response.body.to_s
endparse_error_response method · ruby · L207-L212 (6 LOC)lib/magi/archive/mcp/auth.rb
def parse_error_response(response)
data = JSON.parse(response.body.to_s)
data["error"] || data["message"] || "Unknown error"
rescue JSON::ParserError
response.body.to_s
endparse_error_response method · ruby · L207-L212 (6 LOC)lib/magi/archive/mcp/auth.rb
def parse_error_response(response)
data = JSON.parse(response.body.to_s)
data["error"] || data["message"] || "Unknown error"
rescue JSON::ParserError
response.body.to_s
endparse_error_response method · ruby · L207-L212 (6 LOC)lib/magi/archive/mcp/auth.rb
def parse_error_response(response)
data = JSON.parse(response.body.to_s)
data["error"] || data["message"] || "Unknown error"
rescue JSON::ParserError
response.body.to_s
endAbout: code-quality intelligence by Repobility · https://repobility.com
parse_error_response method · ruby · L207-L212 (6 LOC)lib/magi/archive/mcp/auth.rb
def parse_error_response(response)
data = JSON.parse(response.body.to_s)
data["error"] || data["message"] || "Unknown error"
rescue JSON::ParserError
response.body.to_s
endjwk_to_public_key method · ruby · L215-L229 (15 LOC)lib/magi/archive/mcp/auth.rb
def jwk_to_public_key(jwk)
# Extract modulus (n) and exponent (e) from JWK
n = decode_base64url(jwk["n"])
e = decode_base64url(jwk["e"])
# Create RSA public key
key = OpenSSL::PKey::RSA.new
key.set_key(
OpenSSL::BN.new(n, 2),
OpenSSL::BN.new(e, 2),
nil
)
key
endjwk_to_public_key method · ruby · L215-L229 (15 LOC)lib/magi/archive/mcp/auth.rb
def jwk_to_public_key(jwk)
# Extract modulus (n) and exponent (e) from JWK
n = decode_base64url(jwk["n"])
e = decode_base64url(jwk["e"])
# Create RSA public key
key = OpenSSL::PKey::RSA.new
key.set_key(
OpenSSL::BN.new(n, 2),
OpenSSL::BN.new(e, 2),
nil
)
key
end