Class: AtprotoAuth::ClientMetadata

Inherits:
Object
  • Object
show all
Defined in:
lib/atproto_auth/client_metadata.rb

Overview

Handles validation and management of AT Protocol OAuth client metadata according to the specification. This includes required fields like client_id and redirect URIs, optional metadata like client name and logo, and authentication configuration for confidential clients. Validates that all fields conform to the protocol’s requirements, including:

  • Application type (web/native) validation and redirect URI rules

  • Required scopes and grant types

  • JWKS configuration for confidential clients

  • DPoP binding requirements

  • URI scheme and format validation

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(metadata) ⇒ ClientMetadata

Initializes a new ClientMetadata instance from metadata hash.

Parameters:

  • metadata (Hash)

    Client metadata.

Raises:



35
36
37
# File 'lib/atproto_auth/client_metadata.rb', line 35

def initialize()
  validate_and_set_metadata!()
end

Instance Attribute Details

#application_typeObject (readonly)

Required fields



26
27
28
# File 'lib/atproto_auth/client_metadata.rb', line 26

def application_type
  @application_type
end

#client_idObject (readonly)

Required fields



26
27
28
# File 'lib/atproto_auth/client_metadata.rb', line 26

def client_id
  @client_id
end

#client_nameObject (readonly)

Optional fields



28
29
30
# File 'lib/atproto_auth/client_metadata.rb', line 28

def client_name
  @client_name
end

#client_uriObject (readonly)

Optional fields



28
29
30
# File 'lib/atproto_auth/client_metadata.rb', line 28

def client_uri
  @client_uri
end

#grant_typesObject (readonly)

Required fields



26
27
28
# File 'lib/atproto_auth/client_metadata.rb', line 26

def grant_types
  @grant_types
end

#jwksObject (readonly)

Authentication and key-related fields



30
31
32
# File 'lib/atproto_auth/client_metadata.rb', line 30

def jwks
  @jwks
end

#jwks_uriObject (readonly)

Authentication and key-related fields



30
31
32
# File 'lib/atproto_auth/client_metadata.rb', line 30

def jwks_uri
  @jwks_uri
end

#logo_uriObject (readonly)

Optional fields



28
29
30
# File 'lib/atproto_auth/client_metadata.rb', line 28

def logo_uri
  @logo_uri
end

#policy_uriObject (readonly)

Optional fields



28
29
30
# File 'lib/atproto_auth/client_metadata.rb', line 28

def policy_uri
  @policy_uri
end

#redirect_urisObject (readonly)

Required fields



26
27
28
# File 'lib/atproto_auth/client_metadata.rb', line 26

def redirect_uris
  @redirect_uris
end

#response_typesObject (readonly)

Required fields



26
27
28
# File 'lib/atproto_auth/client_metadata.rb', line 26

def response_types
  @response_types
end

#scopeObject (readonly)

Required fields



26
27
28
# File 'lib/atproto_auth/client_metadata.rb', line 26

def scope
  @scope
end

#token_endpoint_auth_methodObject (readonly)

Authentication and key-related fields



30
31
32
# File 'lib/atproto_auth/client_metadata.rb', line 30

def token_endpoint_auth_method
  @token_endpoint_auth_method
end

#tos_uriObject (readonly)

Optional fields



28
29
30
# File 'lib/atproto_auth/client_metadata.rb', line 28

def tos_uri
  @tos_uri
end

Class Method Details

.from_url(url) ⇒ ClientMetadata

Fetches client metadata from a URL and creates a new instance.

Parameters:

  • url (String)

    URL to fetch metadata from.

Returns:

Raises:



43
44
45
46
47
48
49
# File 'lib/atproto_auth/client_metadata.rb', line 43

def self.from_url(url)
  validate_url!(url)
  response = (url)
   = (response[:body])
  validate_client_id!(["client_id"], url)
  new()
end

Instance Method Details

#confidential?Boolean

Determines if the client is confidential (has authentication keys).

Returns:

  • (Boolean)

    true if client is confidential.



53
54
55
# File 'lib/atproto_auth/client_metadata.rb', line 53

def confidential?
  token_endpoint_auth_method == "private_key_jwt"
end