Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -176,3 +176,5 @@ cython_debug/

# PyPI configuration file
.pypirc

.fake
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ pip install -e .

### Initialization

> **⚠️ IMPORTANT:**
> **[WARN] IMPORTANT:**
> * If you don't have an existing configuration, first run `corebrain --configure`
> * If you need to generate a new API key, use `corebrain --create`
> * Never share your API key in public repositories. Use environment variables instead.
Expand Down
10 changes: 5 additions & 5 deletions corebrain/cli/auth/api_keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,18 +125,18 @@ def fetch_api_keys(api_url: str, api_token: str, user_data: Dict[str, Any]) -> O

# Verify if the key is active
if selected_key.get('active') != True:
print_colored("⚠️ The selected API key is not active. Select another one.", "yellow")
print_colored("[WARN] The selected API key is not active. Select another one.", "yellow")
continue

# Get information of the selected key
key_name = selected_key.get('name', 'Unknown')
key_value = selected_key.get('key', None)

if not key_value:
print_colored("⚠️ The selected API key does not have a valid value.", "yellow")
print_colored("[WARN] The selected API key does not have a valid value.", "yellow")
continue

print_colored(f" You selected: {key_name}", "green")
print_colored(f"[OK] You selected: {key_name}", "green")
print_colored("Wait while we assign the API key to your SDK...", "yellow")

return key_value
Expand Down Expand Up @@ -216,7 +216,7 @@ def get_api_key_id_from_token(sso_token: str, api_token: str, api_url: str) -> O
key_id = key_data.get("id")
return key_id
else:
print_colored("⚠️ Could not find the API key ID", "yellow")
print_colored("[WARN] Could not find the API key ID", "yellow")
return None

except Exception as e:
Expand Down Expand Up @@ -269,7 +269,7 @@ def exchange_sso_token_for_api_token(api_url: str, sso_token: str, user_data: Di
print_colored("The response does not contain a valid API token", "red")
return None

print_colored(" API token successfully obtained", "green")
print_colored("[OK] API token successfully obtained", "green")
return api_token
except Exception as e:
print_colored(f"Error processing JSON response: {str(e)}", "red")
Expand Down
20 changes: 10 additions & 10 deletions corebrain/cli/auth/sso.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,14 +293,14 @@ def handler_factory(*args, **kwargs):

# Verify if authentication was completed
if auth_completed.is_set():
print_colored(" SSO authentication completed successfully!", "green")
print_colored("[OK] SSO authentication completed successfully!", "green")
return result["sso_token"], session_data['user']
else:
print_colored(f" Could not complete SSO authentication in {timeout_seconds} seconds.", "red")
print_colored(f"[ERROR] Could not complete SSO authentication in {timeout_seconds} seconds.", "red")
print_colored("You can try again or use a token manually.", "yellow")
return None, None, None
except Exception as e:
print_colored(f" Error during SSO authentication: {str(e)}", "red")
print_colored(f"[ERROR] Error during SSO authentication: {str(e)}", "red")
return None, None, None
finally:
# Stop the server
Expand Down Expand Up @@ -405,7 +405,7 @@ def handler_factory(*args, **kwargs):
if 'user' in session_data:
user_data = session_data['user']

print_colored(" SSO authentication completed successfully!", "green")
print_colored("[OK] SSO authentication completed successfully!", "green")

# Get and select an API key
api_url = os.environ.get("COREBRAIN_API_URL", DEFAULT_API_URL)
Expand All @@ -416,7 +416,7 @@ def handler_factory(*args, **kwargs):
api_token = exchange_sso_token_for_api_token(api_url, result["sso_token"], user_data)

if not api_token:
print_colored("⚠️ Could not obtain an API Token with the SSO Token", "yellow")
print_colored("[WARN] Could not obtain an API Token with the SSO Token", "yellow")
return None, None, None

# Now that we have the API Token, we get the available API Keys
Expand All @@ -426,21 +426,21 @@ def handler_factory(*args, **kwargs):
# We return the selected api_key
return api_key_selected, user_data, api_token
else:
print_colored("⚠️ Could not obtain an API Key. Create a new one using the command", "yellow")
print_colored("[WARN] Could not obtain an API Key. Create a new one using the command", "yellow")
return None, user_data, api_token
else:
print_colored(" No valid token was obtained during authentication.", "red")
print_colored("[ERROR] No valid token was obtained during authentication.", "red")
return None, None, None

# We don't have a token or user data
print_colored(" Authentication did not produce a valid token.", "red")
print_colored("[ERROR] Authentication did not produce a valid token.", "red")
return None, None, None
else:
print_colored(f" Could not complete SSO authentication in {timeout_seconds} seconds.", "red")
print_colored(f"[ERROR] Could not complete SSO authentication in {timeout_seconds} seconds.", "red")
print_colored("You can try again or use a token manually.", "yellow")
return None, None, None
except Exception as e:
print_colored(f" Error during SSO authentication: {str(e)}", "red")
print_colored(f"[ERROR] Error during SSO authentication: {str(e)}", "red")
return None, None, None
finally:
# Stop the server
Expand Down
Loading