1

I am new to Openshift container platform. I am trying to deploy my ML model written in python, which serves the Json request based on authentication of name/password already mentioned in the py code.

    @app.before_request
def validate_request():
    try :
        if(request.authorization.username != auth_user or request.authorization.password != auth_password):
            return "Authentication failed: invalid or missing user/password."
    except:
        return "Authentication failed: invalid or missing user/password"

Now what I am doing is, I am creating a secrert dm in Openshift name-space and adding it in the deployment as below enter image description here

How can I use the username and password mentioned in this secret in my python code, I have tried with the openshift docbut it doesnt complete my requirement of using the value in the code.

4

1 回答 1

1
auth_user = os.environ.get('principle')
auth_password = os.environ.get('credential')
于 2019-08-28T03:19:05.670 回答