Hướng dẫn python keyring mac - móc khóa python mac
Show
Nội dung chính ShowShow
Nội dung chính ShowShowShow
Nội dung chính ShowShowShow
Nội dung chính ShowShow Nội dung chính ShowShowShow
KDE4 & KDE5 KWALLET (Yêu cầu DBU) Cài đặt - LinuxWindows Ch dụng khóa thông tin Khả năng tương thích - MacOSCác triển khai Keyring khác có sẵn thông qua phụ trợ của bên thứ ba. Sử dụng KeyringTrên Linux, phụ trợ KWALLET dựa vào DBUS-Python, không phải lúc nào cũng cài đặt chính xác khi sử dụng PIP (cần biên dịch). Để có kết quả tốt nhất, hãy cài đặt DBUS-Python làm gói hệ thống.keyring.set_password and keyring.get_password: >>> import keyring >>> keyring.set_password("system", "username", "password") >>> keyring.get_password("system", "username") 'password' Tiện ích dòng lệnhMacOS Keychain hỗ trợ MacOS 11 (Big Sur) và sau đó yêu cầu Python 3.8.7 trở lên với nhị phân của Universal Universal2. Xem #525 để biết chi tiết.keyring.set_password and keyring.get_password:keyring command which is installed with the package. After installing keyring in most environments, the command should be available for setting, getting, and deleting passwords. For more usage information, invoke with no arguments or with --help as so: $ keyring --help $ keyring set system username Password for 'username' in 'system': $ keyring get system username password Cấu hình đường dẫn tệp Việc sử dụng cơ bản của Keyring khá đơn giản: Chỉ cần gọi Keyring.Set_Password và Keyring.Get_Password:keyring.set_password and keyring.get_password:keyring.set_password and keyring.get_password:keyring command which is installed with the package. After installing keyring in most environments, the command should be available for setting, getting, and deleting passwords. For more usage information, invoke with no arguments or with --help as so:Cấu hình
$ python -m keyring --help $ python -m keyring set system username Password for 'username' in 'system': $ python -m keyring get system username passwordset_keyring() function. Cấu hình đường dẫn tệpCấu hình nội dung tệp python -c "import keyring.util.platform_; print(keyring.util.platform_.config_root())" Phụ trợ của bên thứ ba Cấu hìnhkeyring command which is installed with the package. After installing keyring in most environments, the command should be available for setting, getting, and deleting passwords. For more usage information, invoke with no arguments or with --help as so:set_keyring() function.Cấu hình nội dung tệp
python -c "import keyring.util.platform_; print(keyring.util.platform_.data_root())"default-keyring option to the full path of the class for that backend, such as keyring.backends.OS_X.Keyring. Phụ trợ của bên thứ badefault-keyring option to the full path of the class for that backend, such as keyring.backends.OS_X.Keyring.keyring-path is indicated, keyring will add that path to the Python module search path before loading the backend. Viết phụ trợ Keyring của riêng bạnkeyring-path is indicated, keyring will add that path to the Python module search path before loading the backend.SimpleKeyring from the simplekeyring module in the ./demo directory (not implemented): [backend] default-keyring=simplekeyring.SimpleKeyring keyring-path=demo Phụ trợ của bên thứ baViết phụ trợ Keyring của riêng bạn
Viết phụ trợ Keyring của riêng bạnNgoại lệkeyring.backend.KeyringBackend. Every backend should derive from that base class and define a priority attribute and three functions: get_password(), set_password(), and delete_password(). The get_credential() function may be defined if desired. Vô hiệu hóa Keyringbackend module for more detail on the interface of this class.backend module for more detail on the interface of this class. Thay đổi hành vi khóakeyrings namespace, in a manner modeled by the keyrings.alt package. See the setup.cfg file in that project for hints on how to create the requisite entry points. Backends that prove essential may be considered for inclusion in the core library, although the ease of installing these third-party packages should mean that extensions may be readily available.keyrings namespace, in a manner modeled by the keyrings.alt package. See the setup.cfg file in that project for hints on how to create the requisite entry points. Backends that prove essential may be considered for inclusion in the core library, although the ease of installing these third-party packages should mean that extensions may be readily available. Để tạo tiện ích mở rộng cho Keyring, vui lòng gửi yêu cầu kéo để mở rộng được đề cập dưới dạng tiện ích mở rộng có sẵn. Cấu hình thời gian chạyNgoài ra, Keyring cho phép cấu hình lập trình của phần phụ trợ gọi API set_keyring (). Các phụ trợ được chỉ định sau đó sẽ được sử dụng để lưu trữ và truy xuất mật khẩu.set_keyring(). The indicated backend will subsequently be used to store and retrieve passwords.set_keyring(). The indicated backend will subsequently be used to store and retrieve passwords.set_keyring(). The indicated backend will subsequently be used to store and retrieve passwords.set_keyring(). The indicated backend will subsequently be used to store and retrieve passwords. Để gọi set_keyring:set_keyring:set_keyring:set_keyring:set_keyring: # define a new keyring class which extends the KeyringBackend import keyring.backend class TestKeyring(keyring.backend.KeyringBackend): """A test keyring which always outputs the same password """ priority = 1 def set_password(self, servicename, username, password): pass def get_password(self, servicename, username): return "password from TestKeyring" def delete_password(self, servicename, username): pass # set the keyring for keyring lib keyring.set_keyring(TestKeyring()) # invoke the keyring lib try: keyring.set_password("demo-service", "tarek", "passexample") print("password stored successfully") except keyring.errors.PasswordSetError: print("failed to store password") print("password", keyring.get_password("demo-service", "tarek")) Vô hiệu hóa KeyringTrong nhiều trường hợp, việc gỡ cài đặt Keyring sẽ không bao giờ cần thiết. Đặc biệt là trên Windows và MacOS, hành vi của Keyring thường bị thoái hóa, có nghĩa là nó sẽ trả lại các giá trị trống cho người gọi, cho phép người gọi quay trở lại với một số hành vi khác. Trong một số trường hợp, hành vi mặc định của Keyring là không mong muốn và sẽ tốt hơn là vô hiệu hóa hoàn toàn hành vi khóa. Có một số cơ chế để vô hiệu hóa Keyring:
Thay đổi hành vi khóaKeyring cung cấp một cơ chế để thay đổi hành vi Keyring, thông qua các biến môi trường. Mỗi phụ trợ thực hiện một KeyringBackend.Set_ProperIES_FROM_ENV, khi được gọi sẽ tìm thấy tất cả các biến môi trường bắt đầu bằng keyring_property_ {name} và sẽ đặt một thuộc tính cho mỗi {name.lower ()} trên Keyring. Phương pháp này được gọi trong khi khởi tạo cho khóa mặc định/được định cấu hình.KeyringBackend.set_properties_from_env, which when invoked will find all environment variables beginning with KEYRING_PROPERTY_{NAME} and will set a property for each {NAME.lower()} on the keyring. This method is invoked during initialization for the default/configured keyring.KeyringBackend.set_properties_from_env, which when invoked will find all environment variables beginning with KEYRING_PROPERTY_{NAME} and will set a property for each {NAME.lower()} on the keyring. This method is invoked during initialization for the default/configured keyring.KeyringBackend.set_properties_from_env, which when invoked will find all environment variables beginning with KEYRING_PROPERTY_{NAME} and will set a property for each {NAME.lower()} on the keyring. This method is invoked during initialization for the default/configured keyring.KeyringBackend.set_properties_from_env, which when invoked will find all environment variables beginning with KEYRING_PROPERTY_{NAME} and will set a property for each {NAME.lower()} on the keyring. This method is invoked during initialization for the default/configured keyring. Cơ chế này có thể được sử dụng để đặt một số giá trị hữu ích cho các khóa khác nhau, bao gồm:
Sử dụng Keyring trên Ubuntu 16.04Sau đây là bảng điểm hoàn chỉnh để cài đặt Keyring trong môi trường ảo trên Ubuntu 16.04. Không có tệp cấu hình nào được sử dụng: $ sudo apt install python3-venv libdbus-glib-1-dev $ cd /tmp $ pyvenv py3 $ source py3/bin/activate $ pip install -U pip $ pip install secretstorage dbus-python $ pip install keyring $ python >>> import keyring >>> keyring.get_keyring() Sử dụng Keyring trên các hệ thống Linux không đầuCó thể sử dụng phụ trợ SecretService trên các hệ thống Linux mà không có máy chủ X11 (chỉ cần D-bus). Trong trường hợp này:
Sử dụng Keyring trên các hệ thống Linux không đầu trong thùng chứa DockerCó thể sử dụng Keyring với phần phụ trợ bí mật trong các thùng chứa Docker. Tất cả những gì bạn cần làm là cài đặt các phụ thuộc cần thiết và thêm cờ của bạn để tránh mọi hoạt động không được phép lỗi khi cố gắng mở khóa hệ thống Keyring. Sau đây là bảng điểm hoàn chỉnh để cài đặt Keyring trên container Ubuntu 18:04: docker run -it -d --privileged ubuntu:18.04 $ apt-get update $ apt install -y gnome-keyring python3-venv python3-dev $ python3 -m venv venv $ source venv/bin/activate # source a virtual environment to avoid polluting your system $ pip3 install --upgrade pip $ pip3 install keyring $ dbus-run-session -- sh # this will drop you into a new D-bus shell $ echo 'somecredstorepass' | gnome-keyring-daemon --unlock # unlock the system's keyring $ python >>> import keyring >>> keyring.get_keyring() Hội nhậpAPILIB KEYRING có một vài chức năng:
Trong mọi trường hợp, các tham số (dịch vụ, tên người dùng, mật khẩu) phải là văn bản Unicode.service, username, password) should be Unicode text.service, username, password) should be Unicode text.service, username, password) should be Unicode text. Ngoại lệLIB KEYRING làm tăng các trường hợp ngoại lệ sau:
Tham gia vàoPython Keyring Lib là một dự án cộng đồng mở và háo hức chào đón những người đóng góp.
Cho doanh nghiệpCó sẵn như một phần của đăng ký Tidelift. Dự án này và người bảo trì hàng ngàn gói khác đang làm việc với Tidelift để cung cấp một đăng ký doanh nghiệp bao gồm tất cả các nguồn mở bạn sử dụng. Tìm hiểu thêm. Liên hệ bảo mậtĐể báo cáo lỗ hổng bảo mật, vui lòng sử dụng liên hệ bảo mật Tidelift. Tidelift sẽ phối hợp sửa chữa và tiết lộ. Cân nhắc về Bảo mậtMỗi phụ trợ tích hợp có thể có những cân nhắc bảo mật để hiểu trước khi sử dụng thư viện này. Các tác giả của các công cụ hoặc thư viện sử dụng Keyring được khuyến khích xem xét những mối quan tâm này.keyring are encouraged to consider these concerns.keyring are encouraged to consider these concerns.keyring are encouraged to consider these concerns. Như với bất kỳ danh sách các mối quan tâm bảo mật đã biết, danh sách này không đầy đủ. Các vấn đề bổ sung có thể được thêm vào khi cần thiết.
KDE4 & KDE5 KWALLETWindows Ch dụng khóa thông tin Phát hành
Những điều khác cần xem xét khi phát hành:Kiểm tra xem Changelog là hiện tại cho bản phát hành dự định. Chạy thử nghiệm Các thử nghiệm liên tục chạy trong các hành động của GitHub.Để chạy các bài kiểm tra cục bộ, cài đặt và gọi TOX. |