Class: Mortymer::SecuritySchemes::OAuth2

Inherits:
Object
  • Object
show all
Defined in:
lib/mortymer/security_schemes.rb

Overview

Define the OAuth2 security scheme

Class Method Summary collapse

Class Method Details

.scheme(scopes = [].freeze) ⇒ Object



56
57
58
# File 'lib/mortymer/security_schemes.rb', line 56

def self.scheme(scopes = [].freeze)
  { OAuth2: scopes }
end

.to_scheme(flows: {}) ⇒ Object



60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/mortymer/security_schemes.rb', line 60

def self.to_scheme(flows: {})
  {
    OAuth2: {
      type: :oauth2,
      flows: flows || {
        implicit: {
          authorizationUrl: "/oauth/authorize",
          scopes: {
            "read:api" => "Read access",
            "write:api" => "Write access"
          }
        },
        password: {
          tokenUrl: "/oauth/token",
          scopes: {
            "read:api" => "Read access",
            "write:api" => "Write access"
          }
        }
      }
    }
  }
end