-
Notifications
You must be signed in to change notification settings - Fork 340
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #652 from guardrails-ai/feat/cli-jwt-auth
new jwt strat
- Loading branch information
Showing
9 changed files
with
252 additions
and
210 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,26 @@ | ||
import http.client | ||
import json | ||
# import http.client | ||
# import json | ||
|
||
from guardrails.classes.credentials import Credentials | ||
# from guardrails.classes.credentials import Credentials | ||
|
||
|
||
def get_auth_token(creds: Credentials) -> str: | ||
if creds.client_id and creds.client_secret: | ||
audience = "https://validator-hub-service.guardrailsai.com" | ||
conn = http.client.HTTPSConnection("guardrailsai.us.auth0.com") | ||
payload = json.dumps( | ||
{ | ||
"client_id": creds.client_id, | ||
"client_secret": creds.client_secret, | ||
"audience": audience, | ||
"grant_type": "client_credentials", | ||
} | ||
) | ||
headers = {"content-type": "application/json"} | ||
conn.request("POST", "/oauth/token", payload, headers) | ||
# unused - for now | ||
# def get_auth_token(creds: Credentials) -> str: | ||
# if creds.client_id and creds.client_secret: | ||
# audience = "https://validator-hub-service.guardrailsai.com" | ||
# conn = http.client.HTTPSConnection("guardrailsai.us.auth0.com") | ||
# payload = json.dumps( | ||
# { | ||
# "client_id": creds.client_id, | ||
# "client_secret": creds.client_secret, | ||
# "audience": audience, | ||
# "grant_type": "client_credentials", | ||
# } | ||
# ) | ||
# headers = {"content-type": "application/json"} | ||
# conn.request("POST", "/oauth/token", payload, headers) | ||
|
||
res = conn.getresponse() | ||
data = json.loads(res.read().decode("utf-8")) | ||
return data.get("access_token", "") | ||
return "" | ||
# res = conn.getresponse() | ||
# data = json.loads(res.read().decode("utf-8")) | ||
# return data.get("access_token", "") | ||
# return "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.