Class: Toolchest::Oauth::MetadataController

Inherits:
ActionController::API
  • Object
show all
Defined in:
app/controllers/toolchest/oauth/metadata_controller.rb

Instance Method Summary collapse

Instance Method Details

#authorization_serverObject

GET /.well-known/oauth-authorization-server(/*rest)



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'app/controllers/toolchest/oauth/metadata_controller.rb', line 5

def authorization_server
  mount_path, cfg = resolve_mount
  return if performed?

  render json: {
    issuer: "#{request.base_url}#{mount_path}",
    authorization_endpoint: "#{request.base_url}#{mount_path}/oauth/authorize",
    token_endpoint: "#{request.base_url}#{mount_path}/oauth/token",
    registration_endpoint: "#{request.base_url}#{mount_path}/oauth/register",
    response_types_supported: ["code"],
    grant_types_supported: ["authorization_code", "refresh_token"],
    token_endpoint_auth_methods_supported: ["none"],
    scopes_supported: cfg.scopes.keys,
    code_challenge_methods_supported: ["S256"]
  }
end

#protected_resourceObject

GET /.well-known/oauth-protected-resource(/*rest)



23
24
25
26
27
28
29
30
31
32
33
# File 'app/controllers/toolchest/oauth/metadata_controller.rb', line 23

def protected_resource
  mount_path, cfg = resolve_mount
  return if performed?

  render json: {
    resource: "#{request.base_url}#{mount_path}",
    authorization_servers: ["#{request.base_url}#{mount_path}"],
    scopes_supported: cfg.scopes.keys,
    bearer_methods_supported: ["header"]
  }
end