Class: Yori::Schema::V3::OAuthFlows

Inherits:
Yori::SchemaBase show all
Defined in:
lib/yori/schema/v3/oauth_flows.rb

Overview

OAuthFlows: Allows configuration of the supported OAuth Flows.

Instance Attribute Summary

Attributes inherited from Yori::SchemaBase

#id

Instance Method Summary collapse

Methods inherited from Yori::SchemaBase

eval_class!, eval_hash!, eval_input!, #ref, #validator

Instance Method Details

#authorizationCodeObject

Configuration for the OAuth Authorization Code flow. Previously called accessCode in OpenAPI 2.0.



23
# File 'lib/yori/schema/v3/oauth_flows.rb', line 23

field_block :authorizationCode, Yori::Schema::V3::OAuthFlow

#clientCredentialsObject

Configuration for the OAuth Client Credentials flow. Previously called application in OpenAPI 2.0.



19
# File 'lib/yori/schema/v3/oauth_flows.rb', line 19

field_block :clientCredentials, Yori::Schema::V3::OAuthFlow

#implicitObject

Configuration for the OAuth Implicit flow



12
# File 'lib/yori/schema/v3/oauth_flows.rb', line 12

field_block :implicit, Yori::Schema::V3::OAuthFlow

#passwordObject

Configuration for the OAuth Resource Owner Password flow



15
# File 'lib/yori/schema/v3/oauth_flows.rb', line 15

field_block :password, Yori::Schema::V3::OAuthFlow

#required_flow_fields(flow) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/yori/schema/v3/oauth_flows.rb', line 36

def required_flow_fields(flow)
  case flow
  when 'implicit'
    %w[authorizationUrl]
  when 'clientCredentials'
    %w[tokenUrl]
  when 'authorizationCode'
    %w[authorizationUrl tokenUrl]
  else
    []
  end
end

#validate!Object



25
26
27
28
29
# File 'lib/yori/schema/v3/oauth_flows.rb', line 25

def validate!
  %w[implicit clientCredentials authorizationCode].each do |field|
    validate_flow!(field)
  end
end

#validate_flow!(flow) ⇒ Object



31
32
33
34
# File 'lib/yori/schema/v3/oauth_flows.rb', line 31

def validate_flow!(flow)
  oauth_flow = self[flow]
  oauth_flow&.validate_require_fields!(*required_flow_fields(flow))
end