Skip to content
GitLab
Menu
Why GitLab
Pricing
Contact Sales
Explore
Why GitLab
Pricing
Contact Sales
Explore
Sign in
Get free trial
Primary navigation
Search or go to…
Project
buildgrid
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Privacy statement
Keyboard shortcuts
?
What's new
6
Snippets
Groups
Projects
Show more breadcrumbs
BuildGrid
buildgrid
Commits
ddb69ad6
Commit
ddb69ad6
authored
6 years ago
by
Martin Blanchard
Browse files
Options
Downloads
Patches
Plain Diff
server/instance.py: Register authentication gRPC interceptor
parent
8827a263
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
buildgrid/server/instance.py
+22
-2
22 additions, 2 deletions
buildgrid/server/instance.py
with
22 additions
and
2 deletions
buildgrid/server/instance.py
+
22
−
2
View file @
ddb69ad6
...
...
@@ -26,6 +26,7 @@ import grpc
from
buildgrid._enums
import
BotStatus
,
MetricRecordDomain
,
MetricRecordType
from
buildgrid._protos.buildgrid.v2
import
monitoring_pb2
from
buildgrid.server.actioncache.service
import
ActionCacheService
from
buildgrid.server._authentication
import
AuthMetadataMethod
,
AuthMetadataAlgorithm
,
AuthMetadataServerInterceptor
from
buildgrid.server.bots.service
import
BotsService
from
buildgrid.server.cas.service
import
ByteStreamService
,
ContentAddressableStorageService
from
buildgrid.server.execution.service
import
ExecutionService
...
...
@@ -44,11 +45,21 @@ class BuildGridServer:
requisite services.
"""
def
__init__
(
self
,
max_workers
=
None
,
monitor
=
False
):
def
__init__
(
self
,
max_workers
=
None
,
monitor
=
False
,
auth_method
=
AuthMetadataMethod
.
NONE
,
auth_secret
=
None
,
auth_algorithm
=
AuthMetadataAlgorithm
.
NONE
):
"""
Initializes a new :class:`BuildGridServer` instance.
Args:
max_workers (int, optional): A pool of max worker threads.
monitor (bool, optional): Whether or not to globally activate server
monitoring. Defaults to ``False``.
auth_method (AuthMetadataMethod, optional): Authentication method to
be used for request authorization. Defaults to ``NONE``.
auth_secret (str, optional): The secret or key to be used for
authorizing request using `auth_method`. Defaults to ``None``.
auth_algorithm (AuthMetadataAlgorithm, optional): The crytographic
algorithm to be uses in combination with `auth_secret` for
authorizing request using `auth_method`. Defaults to ``NONE``.
"""
self
.
__logger
=
logging
.
getLogger
(
__name__
)
...
...
@@ -56,8 +67,17 @@ class BuildGridServer:
# Use max_workers default from Python 3.5+
max_workers
=
(
os
.
cpu_count
()
or
1
)
*
5
self
.
__grpc_auth_interceptor
=
None
if
auth_method
!=
AuthMetadataMethod
.
NONE
:
self
.
__grpc_auth_interceptor
=
AuthMetadataServerInterceptor
(
method
=
auth_method
,
secret
=
auth_secret
,
algorithm
=
auth_algorithm
)
self
.
__grpc_executor
=
futures
.
ThreadPoolExecutor
(
max_workers
)
self
.
__grpc_server
=
grpc
.
server
(
self
.
__grpc_executor
)
if
self
.
__grpc_auth_interceptor
is
not
None
:
self
.
__grpc_server
=
grpc
.
server
(
self
.
__grpc_executor
,
interceptors
=
(
self
.
__grpc_auth_interceptor
,))
else
:
self
.
__grpc_server
=
grpc
.
server
(
self
.
__grpc_executor
)
self
.
__main_loop
=
asyncio
.
get_event_loop
()
self
.
__monitoring_bus
=
None
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment