Class: Scim::Kit::V2::AuthenticationScheme

Inherits:
Object
  • Object
show all
Includes:
Templatable
Defined in:
lib/scim/kit/v2/authentication_scheme.rb

Overview

Represents the available Authentication Schemes.

Constant Summary collapse

DEFAULTS =
{
  httpbasic: {
    description: 'Authentication scheme using the HTTP Basic Standard',
    documentation_uri: 'http://example.com/help/httpBasic.html',
    name: 'HTTP Basic',
    spec_uri: 'http://www.rfc-editor.org/info/rfc2617'
  },
  oauthbearertoken: {
    description:
    'Authentication scheme using the OAuth Bearer Token Standard',
    documentation_uri: 'http://example.com/help/oauth.html',
    name: 'OAuth Bearer Token',
    spec_uri: 'http://www.rfc-editor.org/info/rfc6750'
  }
}.freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Templatable

#as_json, #render, #template_name, #to_h, #to_json

Constructor Details

#initialize {|_self| ... } ⇒ AuthenticationScheme

Returns a new instance of AuthenticationScheme.

Yields:

  • (_self)

Yield Parameters:



31
32
33
# File 'lib/scim/kit/v2/authentication_scheme.rb', line 31

def initialize
  yield self if block_given?
end

Instance Attribute Details

#descriptionObject



25
26
27
# File 'lib/scim/kit/v2/authentication_scheme.rb', line 25

def description
  @description
end

#documentation_uriObject



26
27
28
# File 'lib/scim/kit/v2/authentication_scheme.rb', line 26

def documentation_uri
  @documentation_uri
end

#nameObject



24
25
26
# File 'lib/scim/kit/v2/authentication_scheme.rb', line 24

def name
  @name
end

#primaryObject



29
30
31
# File 'lib/scim/kit/v2/authentication_scheme.rb', line 29

def primary
  @primary
end

#spec_uriObject



27
28
29
# File 'lib/scim/kit/v2/authentication_scheme.rb', line 27

def spec_uri
  @spec_uri
end

#typeObject



28
29
30
# File 'lib/scim/kit/v2/authentication_scheme.rb', line 28

def type
  @type
end

Class Method Details

.build_for(type, primary: nil) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
# File 'lib/scim/kit/v2/authentication_scheme.rb', line 36

def build_for(type, primary: nil)
  defaults = DEFAULTS[type.to_sym] || {}
  new do |x|
    x.type = type
    x.primary = primary
    x.description = defaults[:description]
    x.documentation_uri = defaults[:documentation_uri]
    x.name = defaults[:name]
    x.spec_uri = defaults[:spec_uri]
  end
end

.from(hash) ⇒ Object



48
49
50
51
52
53
54
55
# File 'lib/scim/kit/v2/authentication_scheme.rb', line 48

def from(hash)
  x = build_for(hash[:type], primary: hash[:primary])
  x.description = hash[:description]
  x.documentation_uri = hash[:documentationUri]
  x.name = hash[:name]
  x.spec_uri = hash[:specUri]
  x
end