-
Notifications
You must be signed in to change notification settings - Fork 108
Expand file tree
/
Copy patherrors.rb
More file actions
72 lines (57 loc) · 2.07 KB
/
errors.rb
File metadata and controls
72 lines (57 loc) · 2.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# frozen_string_literal: true
module MCP
module Auth
module Errors
class InvalidScopeError < StandardError; end
class InvalidGrantsError < StandardError; end
class InvalidRedirectUriError < StandardError; end
class MissingClientIdError < StandardError; end
class RegistrationError < StandardError
INVALID_REDIRECT_URI = "invalid_redirect_uri"
INVALID_CLIENT_METADATA = "invalid_client_metadata"
INVALID_SOFTWARE_STATEMENT = "invalid_software_statement"
UNAPPROVED_SOFTARE_STATEMENT = "unapproved_software_statement"
attr_reader :error_code
def initialize(error_code:, message: nil)
super(message)
@error_code = error_code
end
end
class ClientAuthenticationError < StandardError; end
class AuthorizationError < StandardError
INVALID_REQUEST = "invalid_request"
UNAUTHORIZED_CLIENT = "unauthorized_client"
ACCESS_DENIED = "access_denied"
UNSUPPORTED_RESPONSE_TYPE = "unsupported_response_type"
INVALID_SCOPE = "invalid_scope"
SERVER_ERROR = "server_error"
TEMPORARILY_UNAVAILABLE = "temporarily_unavailable"
attr_reader :error_code
def initialize(error_code:, message: nil)
super(message)
@error_code = error_code
end
class << self
def invalid_request(message)
AuthorizationError.new(error_code: INVALID_REQUEST, message:)
end
def invalid_grant(message)
AuthorizationError.new(error_code: INVALID_GRANT, message:)
end
end
end
class TokenError < StandardError
INVALID_REQUEST = "invalid_request"
INVALID_CLIENT = "invalid_client"
INVALID_GRANT = "invalid_grant"
UNAUTHORIZED_CLIENT = "unauthorized_client"
UNSUPPORTED_GRANT_TYPE = "unsupported_grant_type"
INVALID_SCOPE = "invalid_scope"
def initialize(error_code:, message: nil)
super(message)
@error_code = error_code
end
end
end
end
end