Class: AtprotoAuth::ServerMetadata::OriginUrl
- Inherits:
-
Object
- Object
- AtprotoAuth::ServerMetadata::OriginUrl
- Defined in:
- lib/atproto_auth/server_metadata/origin_url.rb
Overview
The ‘OriginUrl` class provides validation logic for URLs that must conform to the AT Protocol OAuth “simple origin URL” requirements. These requirements are common between Resource and Authorization Servers and ensure that the URL is valid and secure for use in the protocol. This class validates that the URL:
-
Uses the HTTPS scheme.
-
Points to the root path (either an empty path or “/”).
-
Does not include a query string or fragment.
-
Does not include user or password credentials.
-
May include a non-default port but disallows the default HTTPS port (443).
This model centralizes the URL validation logic to promote reusability and consistency between different server classes.
Instance Attribute Summary collapse
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
-
#initialize(url) ⇒ OriginUrl
constructor
A new instance of OriginUrl.
-
#valid? ⇒ Boolean
Determines if a URL conforms to AT Protocol OAuth “simple origin URL” requirements.
Constructor Details
#initialize(url) ⇒ OriginUrl
Returns a new instance of OriginUrl.
20 21 22 23 |
# File 'lib/atproto_auth/server_metadata/origin_url.rb', line 20 def initialize(url) @url = url @uri = URI(url) end |
Instance Attribute Details
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
18 19 20 |
# File 'lib/atproto_auth/server_metadata/origin_url.rb', line 18 def uri @uri end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
18 19 20 |
# File 'lib/atproto_auth/server_metadata/origin_url.rb', line 18 def url @url end |
Instance Method Details
#valid? ⇒ Boolean
Determines if a URL conforms to AT Protocol OAuth “simple origin URL” requirements
27 28 29 30 31 32 33 34 |
# File 'lib/atproto_auth/server_metadata/origin_url.rb', line 27 def valid? https_scheme? && root_path? && !uri.query && !uri.fragment && !uri.userinfo && (!explicit_port? || uri.port != 443) end |