Class: GitLfsS3::Application
- Inherits:
-
Sinatra::Application
- Object
- Sinatra::Application
- GitLfsS3::Application
show all
- Includes:
- AwsHelpers
- Defined in:
- lib/git-lfs-s3/application.rb
Class Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from AwsHelpers
#aws_access_key_id, #aws_region, #aws_secret_access_key, #bucket, #bucket_name, #object_data, #s3
Class Attribute Details
.auth_callback ⇒ Object
Returns the value of attribute auth_callback.
6
7
8
|
# File 'lib/git-lfs-s3/application.rb', line 6
def auth_callback
@auth_callback
end
|
Class Method Details
.authentication_enabled? ⇒ Boolean
12
13
14
|
# File 'lib/git-lfs-s3/application.rb', line 12
def authentication_enabled?
!auth_callback.nil?
end
|
.on_authenticate(&block) ⇒ Object
8
9
10
|
# File 'lib/git-lfs-s3/application.rb', line 8
def on_authenticate(&block)
@auth_callback = block
end
|
16
17
18
|
# File 'lib/git-lfs-s3/application.rb', line 16
def perform_authentication(username, password)
auth_callback.call(username, password)
end
|
Instance Method Details
#authorized? ⇒ Boolean
32
33
34
35
36
37
|
# File 'lib/git-lfs-s3/application.rb', line 32
def authorized?
@auth ||= Rack::Auth::Basic::Request.new(request.env)
@auth.provided? && @auth.basic? && @auth.credentials && self.class.auth_callback.call(
@auth.credentials[0], @auth.credentials[1]
)
end
|
#protected! ⇒ Object
39
40
41
42
43
44
|
# File 'lib/git-lfs-s3/application.rb', line 39
def protected!
unless authorized?
response['WWW-Authenticate'] = %(Basic realm="Restricted Area")
throw(:halt, [401, "Invalid username or password"])
end
end
|