Class: RailsAiBridge::Config::Auth

Inherits:
Object
  • Object
show all
Defined in:
lib/rails_ai_bridge/config/auth.rb

Overview

Holds authentication and authorization settings for the MCP HTTP endpoint.

Strategy priority (highest → lowest):

  1. #mcp_jwt_decoder — caller-supplied JWT decoding lambda
  2. #mcp_token_resolver — caller-supplied token resolution lambda
  3. #http_mcp_token / +ENV["RAILS_AI_BRIDGE_MCP_TOKEN"]+ — static bearer token
  4. None configured — open access

See Also:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeAuth

Returns a new instance of Auth.



27
28
29
30
31
32
# File 'lib/rails_ai_bridge/config/auth.rb', line 27

def initialize
  @http_mcp_token = nil
  @allow_auto_mount_in_production = false
  @mcp_token_resolver           = nil
  @mcp_jwt_decoder              = nil
end

Instance Attribute Details

#allow_auto_mount_in_productionBoolean

Returns allow auto-mounting the MCP endpoint in production.

Returns:

  • (Boolean)

    allow auto-mounting the MCP endpoint in production



19
20
21
# File 'lib/rails_ai_bridge/config/auth.rb', line 19

def allow_auto_mount_in_production
  @allow_auto_mount_in_production
end

#http_mcp_tokenString?

Returns static bearer token for HTTP MCP auth.

Returns:

  • (String, nil)

    static bearer token for HTTP MCP auth



16
17
18
# File 'lib/rails_ai_bridge/config/auth.rb', line 16

def http_mcp_token
  @http_mcp_token
end

#mcp_jwt_decoderProc?

Returns lambda decoding a raw JWT to a payload hash.

Returns:

  • (Proc, nil)

    lambda decoding a raw JWT to a payload hash



25
26
27
# File 'lib/rails_ai_bridge/config/auth.rb', line 25

def mcp_jwt_decoder
  @mcp_jwt_decoder
end

#mcp_token_resolverProc?

Returns lambda resolving a raw bearer token to an auth context.

Returns:

  • (Proc, nil)

    lambda resolving a raw bearer token to an auth context



22
23
24
# File 'lib/rails_ai_bridge/config/auth.rb', line 22

def mcp_token_resolver
  @mcp_token_resolver
end