示例#1
0
    def authenticate_credentials(self, userid, password):
        if userid != "bk_iam":
            raise AuthenticationFailed("username is not bk_iam")

        iam = IAM(settings.APP_ID, settings.APP_TOKEN, settings.BK_IAM_HOST, settings.BK_PAAS_INNER_HOST)
        ok, msg, token = iam.get_token(settings.APP_ID)
        if not ok:
            raise AuthenticationFailed(f"get system token fail: {msg}")
        if password != token:
            raise AuthenticationFailed("password in basic_auth not equals to system token")

        return (FancyDict(username=userid, password=password), None)
示例#2
0
    def authenticate_credentials(self,
                                 userid: str,
                                 password: str,
                                 request=None):
        if userid != "bk_iam":
            raise AuthenticationFailed("username is not bk_iam")

        iam = IAM(
            settings.APP_CODE,
            settings.SECRET_KEY,
            settings.BK_IAM_HOST,
            settings.BK_PAAS_INNER_HOST,
            settings.BK_IAM_APIGATEWAY_URL,
        )
        ok, msg, token = iam.get_token(settings.BK_IAM_SYSTEM_ID)
        if not ok:
            raise AuthenticationFailed(f"get system token fail: {msg}")
        if password != token:
            raise AuthenticationFailed(
                "password in basic_auth not equals to system token")

        return (FancyDict(username=userid, password=password), None)