_authentication.py 文件源码

python
阅读 19 收藏 0 点赞 0 评论 0

项目:txkube 作者: LeastAuthority 项目源码 文件源码
def authenticate_with_serviceaccount(reactor, **kw):
    """
    Create an ``IAgent`` which can issue authenticated requests to a
    particular Kubernetes server using a service account token.

    :param reactor: The reactor with which to configure the resulting agent.

    :param bytes path: The location of the service account directory.  The
        default should work fine for normal use within a container.

    :return IAgent: An agent which will authenticate itself to a particular
        Kubernetes server and which will verify that server or refuse to
        interact with it.
    """
    config = KubeConfig.from_service_account(**kw)
    policy = https_policy_from_config(config)
    token = config.user["token"]
    agent = HeaderInjectingAgent(
        _to_inject=Headers({u"authorization": [u"Bearer {}".format(token)]}),
        _agent=Agent(reactor, contextFactory=policy),
    )
    return agent
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号