authlete 0.3.6 → 0.3.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/authlete.rb +14 -14
- data/lib/authlete/api.rb +115 -35
- data/lib/authlete/authentication-server.rb +4 -4
- data/lib/authlete/model/client-list.rb +127 -181
- data/lib/authlete/model/client.rb +444 -492
- data/lib/authlete/model/hashable.rb +65 -0
- data/lib/authlete/model/request/authentication-callback-request.rb +91 -0
- data/lib/authlete/model/request/authorization-fail-request.rb +107 -0
- data/lib/authlete/model/request/authorization-issue-request.rb +136 -0
- data/lib/authlete/model/request/authorization-request.rb +104 -0
- data/lib/authlete/model/request/developer-authentication-callback-request.rb +85 -0
- data/lib/authlete/model/request/introspection-request.rb +40 -0
- data/lib/authlete/model/request/token-fail-request.rb +104 -0
- data/lib/authlete/model/request/token-issue-request.rb +104 -0
- data/lib/authlete/model/request/token-request.rb +124 -0
- data/lib/authlete/model/response/authentication-callback-response.rb +54 -0
- data/lib/authlete/model/response/authorization-fail-response.rb +47 -0
- data/lib/authlete/model/response/authorization-issue-response.rb +47 -0
- data/lib/authlete/model/response/authorization-response.rb +146 -0
- data/lib/authlete/model/response/developer-authentication-callback-response.rb +56 -0
- data/lib/authlete/model/response/introspection-response.rb +129 -0
- data/lib/authlete/model/response/result.rb +45 -0
- data/lib/authlete/model/response/service-creatable-response.rb +51 -0
- data/lib/authlete/model/response/token-fail-response.rb +48 -0
- data/lib/authlete/model/response/token-issue-response.rb +48 -0
- data/lib/authlete/model/response/token-response.rb +69 -0
- data/lib/authlete/model/scope.rb +17 -42
- data/lib/authlete/model/service-list.rb +19 -74
- data/lib/authlete/model/service-owner.rb +16 -40
- data/lib/authlete/model/service.rb +20 -76
- data/lib/authlete/model/sns-credentials.rb +16 -41
- data/lib/authlete/model/tagged-value.rb +105 -135
- data/lib/authlete/utility.rb +29 -5
- data/lib/authlete/version.rb +1 -1
- metadata +24 -10
- data/lib/authlete/request/authentication-callback-request.rb +0 -90
- data/lib/authlete/request/developer-authentication-callback-request.rb +0 -84
- data/lib/authlete/response/authentication-callback-response.rb +0 -58
- data/lib/authlete/response/base-response.rb +0 -41
- data/lib/authlete/response/developer-authentication-callback-response.rb +0 -60
- data/lib/authlete/response/introspection-response.rb +0 -130
- data/lib/authlete/response/service-creatable-response.rb +0 -52
@@ -1,130 +0,0 @@
|
|
1
|
-
# :nodoc:
|
2
|
-
#
|
3
|
-
# Copyright (C) 2014-2015 Authlete, Inc.
|
4
|
-
#
|
5
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
-
# you may not use this file except in compliance with the License.
|
7
|
-
# You may obtain a copy of the License at
|
8
|
-
#
|
9
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
-
#
|
11
|
-
# Unless required by applicable law or agreed to in writing, software
|
12
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
-
# See the License for the specific language governing permissions and
|
15
|
-
# limitations under the License.
|
16
|
-
|
17
|
-
|
18
|
-
module Authlete
|
19
|
-
module Response
|
20
|
-
# == Authlete::Response::IntrospectionResponse class
|
21
|
-
#
|
22
|
-
# A class that represents a response from Authlete's
|
23
|
-
# /api/auth/introspection API.
|
24
|
-
#
|
25
|
-
class IntrospectionResponse < Authlete::Response::BaseResponse
|
26
|
-
include Authlete::Utility
|
27
|
-
|
28
|
-
# The next action which the caller of the API should take next.
|
29
|
-
attr_accessor :action
|
30
|
-
|
31
|
-
# The ID of the client application which is associated with
|
32
|
-
# the access token.
|
33
|
-
attr_accessor :client_id
|
34
|
-
|
35
|
-
# The subject which is associated with the access token.
|
36
|
-
# This is <tt>nil</tt> if the access token was created
|
37
|
-
# through {Client Credentials Flow}[https://tools.ietf.org/html/rfc6749#section-4.4].
|
38
|
-
attr_accessor :subject
|
39
|
-
|
40
|
-
# The scopes which is associated with the access token.
|
41
|
-
attr_accessor :scopes
|
42
|
-
|
43
|
-
# True when the access token exists.
|
44
|
-
attr_accessor :existent
|
45
|
-
|
46
|
-
# True when the access token is usable (= exists and has not expired).
|
47
|
-
attr_accessor :usable
|
48
|
-
|
49
|
-
# True when the access token covers all the scopes (if specified).
|
50
|
-
attr_accessor :sufficient
|
51
|
-
|
52
|
-
# True when the access token can be refreshed using its corresponding
|
53
|
-
# refresh token.
|
54
|
-
attr_accessor :refreshable
|
55
|
-
|
56
|
-
# The content of the error response that the service implementation
|
57
|
-
# should return to the client application.
|
58
|
-
attr_accessor :response_content
|
59
|
-
|
60
|
-
# The constructor which takes a hash that represents a JSON response
|
61
|
-
# from /api/auth/introspection API.
|
62
|
-
def initialize(hash = {})
|
63
|
-
super(hash)
|
64
|
-
|
65
|
-
@action = extract_value(hash, :action)
|
66
|
-
@client_id = extract_value(hash, :clientId)
|
67
|
-
@subject = extract_value(hash, :subject)
|
68
|
-
@scopes = extract_value(hash, :scopes)
|
69
|
-
@existent = extract_boolean_value(hash, :existent)
|
70
|
-
@usable = extract_boolean_value(hash, :usable)
|
71
|
-
@sufficient = extract_boolean_value(hash, :sufficient)
|
72
|
-
@refreshable = extract_boolean_value(hash, :refreshable)
|
73
|
-
@response_content = extract_value(hash, :responseContent)
|
74
|
-
end
|
75
|
-
|
76
|
-
alias_method :existent?, :existent
|
77
|
-
alias_method :exists, :existent
|
78
|
-
alias_method :exists?, :existent
|
79
|
-
alias_method :exist, :existent
|
80
|
-
alias_method :exist?, :existent
|
81
|
-
alias_method :usable?, :usable
|
82
|
-
alias_method :sufficient?, :sufficient
|
83
|
-
alias_method :refreshable?, :refreshable
|
84
|
-
|
85
|
-
# Generate an array which is usable as a Rack response from this instance.
|
86
|
-
# When <tt>action</tt> method returns other value than 'OK', the array
|
87
|
-
# returned from this method satisfies RFC 6750.
|
88
|
-
def to_rack_response
|
89
|
-
# 'action' denotes the next action.
|
90
|
-
case @action
|
91
|
-
when 'INTERNAL_SERVER_ERROR'
|
92
|
-
# 500 Internal Server Error
|
93
|
-
# The API request from this implementation was wrong
|
94
|
-
# or an error occurred in Authlete.
|
95
|
-
return to_rack_response_www_authenticate(500, @response_content)
|
96
|
-
|
97
|
-
when 'BAD_REQUEST'
|
98
|
-
# 400 Bad Request
|
99
|
-
# The request from the client application does not
|
100
|
-
# contain an access token.
|
101
|
-
return to_rack_response_www_authenticate(400, @response_content)
|
102
|
-
|
103
|
-
when 'UNAUTHORIZED'
|
104
|
-
# 401 Unauthorized
|
105
|
-
# The presented access token does not exist or has expired.
|
106
|
-
return to_rack_response_www_authenticate(401, @response_content)
|
107
|
-
|
108
|
-
when 'FORBIDDEN'
|
109
|
-
# 403 Forbidden
|
110
|
-
# The access token does not cover the required scopes
|
111
|
-
# or the subject associated with the access token is
|
112
|
-
# different.
|
113
|
-
return to_rack_response_www_authenticate(403, @response_content)
|
114
|
-
|
115
|
-
when 'OK'
|
116
|
-
# The access token is valid (= exists and has not expired).
|
117
|
-
# Basically, the caller won't use the array returned from here.
|
118
|
-
# Instead, it will return the protected resource to the client
|
119
|
-
# application which has presented the valid access token.
|
120
|
-
return [ 200, nil, nil ]
|
121
|
-
|
122
|
-
else
|
123
|
-
# This should not happen.
|
124
|
-
return to_rack_response_www_authenticate(500,
|
125
|
-
'Bearer error="server_error",error_description="Unknown action"')
|
126
|
-
end
|
127
|
-
end
|
128
|
-
end
|
129
|
-
end
|
130
|
-
end
|
@@ -1,52 +0,0 @@
|
|
1
|
-
# :nodoc:
|
2
|
-
#
|
3
|
-
# Copyright (C) 2015 Authlete, Inc.
|
4
|
-
#
|
5
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
-
# you may not use this file except in compliance with the License.
|
7
|
-
# You may obtain a copy of the License at
|
8
|
-
#
|
9
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
-
#
|
11
|
-
# Unless required by applicable law or agreed to in writing, software
|
12
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
-
# See the License for the specific language governing permissions and
|
15
|
-
# limitations under the License.
|
16
|
-
|
17
|
-
|
18
|
-
module Authlete
|
19
|
-
module Response
|
20
|
-
# == Authlete::Response::ServiceCreatableResponse class
|
21
|
-
class ServiceCreatableResponse
|
22
|
-
include Authlete::Utility
|
23
|
-
|
24
|
-
# A boolean flag to indicate whether the service owner can
|
25
|
-
# create a new service or not.
|
26
|
-
attr_accessor :creatable
|
27
|
-
|
28
|
-
# The number of services that the service owner currently has.
|
29
|
-
attr_accessor :count
|
30
|
-
|
31
|
-
# The maximum number of services allowed in the plan of the
|
32
|
-
# service owner.
|
33
|
-
attr_accessor :limit
|
34
|
-
|
35
|
-
# The plan of the service owner.
|
36
|
-
attr_accessor :plan
|
37
|
-
|
38
|
-
# The constructor which takes a hash that represents a JSON
|
39
|
-
# response from /api/service/creatable API.
|
40
|
-
def initialize(hash = {})
|
41
|
-
super(hash)
|
42
|
-
|
43
|
-
@creatable = extract_boolean_value(hash, :creatable)
|
44
|
-
@count = extract_value(hash, :count);
|
45
|
-
@limit = extract_value(hash, :limit);
|
46
|
-
@plan = extract_value(hash, :plan);
|
47
|
-
end
|
48
|
-
|
49
|
-
alias_method :creatable?, :creatable
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|