Do an initial commit after export from smol-k8s-lab
Signed-off-by: JesseBot <jessebot@linux.com>
This commit is contained in:
commit
8cb781f2bf
13 changed files with 3352 additions and 0 deletions
25
.forgejo/workflows/python-publish.yml
Normal file
25
.forgejo/workflows/python-publish.yml
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
---
|
||||
name: Python package build and publish
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- pyproject.toml
|
||||
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
build-and-publish:
|
||||
uses: small-hack/reusable-workflows/.forgejo/workflows/python-publish.yaml@main
|
||||
with:
|
||||
forgejo_url: https://git.smallhack.org
|
||||
owner: small-hack
|
||||
repo: bitwarden-wrapper
|
||||
force: false
|
||||
release: true
|
||||
codeberg: true
|
||||
secrets:
|
||||
forgejo_api_token: ${{ secrets.FORGE_TOKEN }}
|
||||
codeberg_token: ${{ secrets.CODEBERG_TOKEN }}
|
||||
pypi_token: ${{ secrets.PYPI_TOKEN }}
|
||||
20
.gitignore
vendored
Normal file
20
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
# ignore python cache
|
||||
**/__pycache__
|
||||
|
||||
# ignore apple finder stuff
|
||||
**/.DS_Store
|
||||
|
||||
# when we do brew installs with a bundle file, we get this
|
||||
**/Brewfile.lock.json
|
||||
|
||||
# python packaging
|
||||
bitwarden-wrapper.egg-info/**
|
||||
dist/**
|
||||
build/**
|
||||
.ruff_cache/**
|
||||
|
||||
# ignore any local env testing
|
||||
.env
|
||||
|
||||
# mkdocs stuff
|
||||
site/**
|
||||
5
AI_POLICY.md
Normal file
5
AI_POLICY.md
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
No AI is allowed in this repo.
|
||||
|
||||
You cannot use any AI or LLM to interact with this repo in way.
|
||||
|
||||
If you have questions about the codebase, open an issue at https://codeberg.org/open-engineering/bitwarden-wrapper or shout out to me on the Fediverse at @jessebot@social.smallhack.org but please never use AI. I'd rather a DM than know that you used AI on our repo.
|
||||
660
LICENSE
Normal file
660
LICENSE
Normal file
|
|
@ -0,0 +1,660 @@
|
|||
# GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
|
||||
Version 3, 19 November 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc.
|
||||
<https://fsf.org/>
|
||||
|
||||
Everyone is permitted to copy and distribute verbatim copies of this
|
||||
license document, but changing it is not allowed.
|
||||
|
||||
## Preamble
|
||||
|
||||
The GNU Affero General Public License is a free, copyleft license for
|
||||
software and other kinds of works, specifically designed to ensure
|
||||
cooperation with the community in the case of network server software.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
our General Public Licenses are intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains
|
||||
free software for all its users.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
Developers that use our General Public Licenses protect your rights
|
||||
with two steps: (1) assert copyright on the software, and (2) offer
|
||||
you this License which gives you legal permission to copy, distribute
|
||||
and/or modify the software.
|
||||
|
||||
A secondary benefit of defending all users' freedom is that
|
||||
improvements made in alternate versions of the program, if they
|
||||
receive widespread use, become available for other developers to
|
||||
incorporate. Many developers of free software are heartened and
|
||||
encouraged by the resulting cooperation. However, in the case of
|
||||
software used on network servers, this result may fail to come about.
|
||||
The GNU General Public License permits making a modified version and
|
||||
letting the public access it on a server without ever releasing its
|
||||
source code to the public.
|
||||
|
||||
The GNU Affero General Public License is designed specifically to
|
||||
ensure that, in such cases, the modified source code becomes available
|
||||
to the community. It requires the operator of a network server to
|
||||
provide the source code of the modified version running there to the
|
||||
users of that server. Therefore, public use of a modified version, on
|
||||
a publicly accessible server, gives the public access to the source
|
||||
code of the modified version.
|
||||
|
||||
An older license, called the Affero General Public License and
|
||||
published by Affero, was designed to accomplish similar goals. This is
|
||||
a different license, not a version of the Affero GPL, but Affero has
|
||||
released a new version of the Affero GPL which permits relicensing
|
||||
under this license.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
## TERMS AND CONDITIONS
|
||||
|
||||
### 0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU Affero General Public
|
||||
License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds
|
||||
of works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of
|
||||
an exact copy. The resulting work is called a "modified version" of
|
||||
the earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user
|
||||
through a computer network, with no transfer of a copy, is not
|
||||
conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices" to
|
||||
the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
### 1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work for
|
||||
making modifications to it. "Object code" means any non-source form of
|
||||
a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users can
|
||||
regenerate automatically from other parts of the Corresponding Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that same
|
||||
work.
|
||||
|
||||
### 2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not convey,
|
||||
without conditions so long as your license otherwise remains in force.
|
||||
You may convey covered works to others for the sole purpose of having
|
||||
them make modifications exclusively for you, or provide you with
|
||||
facilities for running those works, provided that you comply with the
|
||||
terms of this License in conveying all material for which you do not
|
||||
control copyright. Those thus making or running the covered works for
|
||||
you must do so exclusively on your behalf, under your direction and
|
||||
control, on terms that prohibit them from making any copies of your
|
||||
copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under the
|
||||
conditions stated below. Sublicensing is not allowed; section 10 makes
|
||||
it unnecessary.
|
||||
|
||||
### 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such
|
||||
circumvention is effected by exercising rights under this License with
|
||||
respect to the covered work, and you disclaim any intention to limit
|
||||
operation or modification of the work as a means of enforcing, against
|
||||
the work's users, your or third parties' legal rights to forbid
|
||||
circumvention of technological measures.
|
||||
|
||||
### 4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
### 5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these
|
||||
conditions:
|
||||
|
||||
- a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
- b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under
|
||||
section 7. This requirement modifies the requirement in section 4
|
||||
to "keep intact all notices".
|
||||
- c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
- d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
### 6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms of
|
||||
sections 4 and 5, provided that you also convey the machine-readable
|
||||
Corresponding Source under the terms of this License, in one of these
|
||||
ways:
|
||||
|
||||
- a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
- b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the Corresponding
|
||||
Source from a network server at no charge.
|
||||
- c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
- d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
- e) Convey the object code using peer-to-peer transmission,
|
||||
provided you inform other peers where the object code and
|
||||
Corresponding Source of the work are being offered to the general
|
||||
public at no charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal,
|
||||
family, or household purposes, or (2) anything designed or sold for
|
||||
incorporation into a dwelling. In determining whether a product is a
|
||||
consumer product, doubtful cases shall be resolved in favor of
|
||||
coverage. For a particular product received by a particular user,
|
||||
"normally used" refers to a typical or common use of that class of
|
||||
product, regardless of the status of the particular user or of the way
|
||||
in which the particular user actually uses, or expects or is expected
|
||||
to use, the product. A product is a consumer product regardless of
|
||||
whether the product has substantial commercial, industrial or
|
||||
non-consumer uses, unless such uses represent the only significant
|
||||
mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to
|
||||
install and execute modified versions of a covered work in that User
|
||||
Product from a modified version of its Corresponding Source. The
|
||||
information must suffice to ensure that the continued functioning of
|
||||
the modified object code is in no case prevented or interfered with
|
||||
solely because modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or
|
||||
updates for a work that has been modified or installed by the
|
||||
recipient, or for the User Product in which it has been modified or
|
||||
installed. Access to a network may be denied when the modification
|
||||
itself materially and adversely affects the operation of the network
|
||||
or violates the rules and protocols for communication across the
|
||||
network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
### 7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders
|
||||
of that material) supplement the terms of this License with terms:
|
||||
|
||||
- a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
- b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
- c) Prohibiting misrepresentation of the origin of that material,
|
||||
or requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
- d) Limiting the use for publicity purposes of names of licensors
|
||||
or authors of the material; or
|
||||
- e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
- f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions
|
||||
of it) with contractual assumptions of liability to the recipient,
|
||||
for any liability that these contractual assumptions directly
|
||||
impose on those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions; the
|
||||
above requirements apply either way.
|
||||
|
||||
### 8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your license
|
||||
from a particular copyright holder is reinstated (a) provisionally,
|
||||
unless and until the copyright holder explicitly and finally
|
||||
terminates your license, and (b) permanently, if the copyright holder
|
||||
fails to notify you of the violation by some reasonable means prior to
|
||||
60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
### 9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or run
|
||||
a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
### 10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
### 11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims owned
|
||||
or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within the
|
||||
scope of its coverage, prohibits the exercise of, or is conditioned on
|
||||
the non-exercise of one or more of the rights that are specifically
|
||||
granted under this License. You may not convey a covered work if you
|
||||
are a party to an arrangement with a third party that is in the
|
||||
business of distributing software, under which you make payment to the
|
||||
third party based on the extent of your activity of conveying the
|
||||
work, and under which the third party grants, to any of the parties
|
||||
who would receive the covered work from you, a discriminatory patent
|
||||
license (a) in connection with copies of the covered work conveyed by
|
||||
you (or copies made from those copies), or (b) primarily for and in
|
||||
connection with specific products or compilations that contain the
|
||||
covered work, unless you entered into that arrangement, or that patent
|
||||
license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
### 12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under
|
||||
this License and any other pertinent obligations, then as a
|
||||
consequence you may not convey it at all. For example, if you agree to
|
||||
terms that obligate you to collect a royalty for further conveying
|
||||
from those to whom you convey the Program, the only way you could
|
||||
satisfy both those terms and this License would be to refrain entirely
|
||||
from conveying the Program.
|
||||
|
||||
### 13. Remote Network Interaction; Use with the GNU General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, if you modify the
|
||||
Program, your modified version must prominently offer all users
|
||||
interacting with it remotely through a computer network (if your
|
||||
version supports such interaction) an opportunity to receive the
|
||||
Corresponding Source of your version by providing access to the
|
||||
Corresponding Source from a network server at no charge, through some
|
||||
standard or customary means of facilitating copying of software. This
|
||||
Corresponding Source shall include the Corresponding Source for any
|
||||
work covered by version 3 of the GNU General Public License that is
|
||||
incorporated pursuant to the following paragraph.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the work with which it is combined will remain governed by version
|
||||
3 of the GNU General Public License.
|
||||
|
||||
### 14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions
|
||||
of the GNU Affero General Public License from time to time. Such new
|
||||
versions will be similar in spirit to the present version, but may
|
||||
differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies that a certain numbered version of the GNU Affero General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU Affero General Public License, you may choose any version ever
|
||||
published by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future versions
|
||||
of the GNU Affero General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
### 15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT
|
||||
WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND
|
||||
PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE
|
||||
DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR
|
||||
CORRECTION.
|
||||
|
||||
### 16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR
|
||||
CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES
|
||||
ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT
|
||||
NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR
|
||||
LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM
|
||||
TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER
|
||||
PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
### 17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
## How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these
|
||||
terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest to
|
||||
attach them to the start of each source file to most effectively state
|
||||
the exclusion of warranty; and each file should have at least the
|
||||
"copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper
|
||||
mail.
|
||||
|
||||
If your software can interact with users remotely through a computer
|
||||
network, you should also make sure that it provides a way for users to
|
||||
get its source. For example, if your program is a web application, its
|
||||
interface could display a "Source" link that leads users to an archive
|
||||
of the code. There are many ways you could offer source, and different
|
||||
solutions will be better for different programs; see section 13 for
|
||||
the specific requirements.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. For more information on this, and how to apply and follow
|
||||
the GNU AGPL, see <https://www.gnu.org/licenses/>.
|
||||
40
README.md
Normal file
40
README.md
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
# bitwarden-wrapper
|
||||
|
||||
<a href="https://pypi.org/project/bitwarden-wrapper/">
|
||||
<img alt="PyPI - Version" src="https://img.shields.io/pypi/v/bitwarden-wrapper?logo=pypi">
|
||||
</a>
|
||||
|
||||
An extremely simple Bitwarden CLI wrapper. Originally developed for [smol-k8s-lab](https://smol-k8s-lab.open.engineering), but extracted so it can be used elsewhere.
|
||||
|
||||
## Usage
|
||||
|
||||
Here's the basic usage:
|
||||
|
||||
```python
|
||||
# initialize the object
|
||||
bw = BwCLI(my_passsword, my_client_id, my_client_secret)
|
||||
|
||||
# unlock the vault
|
||||
bw.unlock()
|
||||
|
||||
# generate a random password
|
||||
random_password = bw.generate()
|
||||
# create a login item in the vault
|
||||
bw.create_login(name="test mctest",
|
||||
item_url="coolhosting4dogs.tech",
|
||||
user="admin",
|
||||
password=random_password)
|
||||
|
||||
# lock the vault
|
||||
bw.lock()
|
||||
```
|
||||
|
||||
If you pass in `tui=True` to the `BwCLI` object, we'll also display a TUI for when a duplicate item exists to allow the user to select what they'd like to do.
|
||||
|
||||
You can also specify `duplicate_strategy="edit"` to edit existing items. The values for `duplicate_strategy` can be: "edit", "ask", "duplicate", "no_action", but it always defaults to "ask".
|
||||
|
||||
## Warnings
|
||||
|
||||
1. If you set your logging library to log level DEBUG, we may print sensitive info when creating and deleting vault items. This is intensional *for debugging purposes only*.
|
||||
|
||||
2. The TUI may throw issues when run inside an event loop. In which case, wecan always fall back to using rich instead.
|
||||
422
bitwarden_wrapper/__init__.py
Executable file
422
bitwarden_wrapper/__init__.py
Executable file
|
|
@ -0,0 +1,422 @@
|
|||
# extremely simple bitwarden cli wrapper
|
||||
# Author: @jessebot jessebot@linux.com
|
||||
"""
|
||||
Example:
|
||||
bw = BwCLI(my_passsword, my_client_id, my_client_secret)
|
||||
bw.unlock()
|
||||
random_password = bw.generate()
|
||||
bw.create_login(name="test mctest",
|
||||
item_url="coolhosting4dogs.tech",
|
||||
user="admin",
|
||||
password=random_password)
|
||||
bw.lock()
|
||||
"""
|
||||
import base64
|
||||
import json
|
||||
import logging as log
|
||||
from rich.prompt import Prompt, Confirm
|
||||
from rich_subproc import subproc
|
||||
from shutil import which
|
||||
from sys import exit
|
||||
from os import environ as env
|
||||
|
||||
# internal libraries
|
||||
from .tui.bitwarden_existing_item_app import AskUserForDuplicateStrategy
|
||||
|
||||
|
||||
class BwCLI():
|
||||
"""
|
||||
Python Wrapper for the Bitwarden cli
|
||||
"""
|
||||
def __init__(self,
|
||||
password: str,
|
||||
client_id: str,
|
||||
client_secret: str,
|
||||
duplicate_strategy: str = "ask",
|
||||
tui: bool = False):
|
||||
"""
|
||||
for storing the session token, credentials, and duplicate_strategy
|
||||
|
||||
duplicate_strategy: str, must be one of: edit, ask, duplicate, no_action
|
||||
"""
|
||||
self.bw_path = str(which("bw"))
|
||||
log.debug(f"self.bw_path is {self.bw_path}")
|
||||
|
||||
if not self.bw_path:
|
||||
log.error("whoops, looks like bw isn't installed. "
|
||||
"Try [green]brew install bw")
|
||||
exit()
|
||||
|
||||
# if we clean up the session when we're done or not
|
||||
self.delete_session = True
|
||||
|
||||
# this is used for bweso and logins
|
||||
self.host = env.get("BW_HOST", "https://bitwarden.com")
|
||||
log.debug(f"Using {self.host} as $BW_HOST")
|
||||
|
||||
|
||||
# make sure there's not a session token in the env vars already
|
||||
self.env = {"BW_SESSION": env.get("BW_SESSION", ""),
|
||||
"PATH": env.get("PATH"),
|
||||
"HOME": env.get("HOME"),
|
||||
"NODE_OPTIONS": "--no-deprecation"}
|
||||
|
||||
# credentials
|
||||
self.password = password
|
||||
self.client_id = client_id
|
||||
self.client_secret = client_secret
|
||||
self.duplicate_strategy = duplicate_strategy
|
||||
|
||||
self.tui = tui
|
||||
|
||||
def sync(self) -> None:
|
||||
"""
|
||||
syncs your bitwaren vault on initialize of this class
|
||||
"""
|
||||
res = subproc([f"{self.bw_path} sync"], env=self.env)
|
||||
log.info(res)
|
||||
|
||||
def __get_credential__(self, credential: str) -> str:
|
||||
"""
|
||||
prompts a user for a specific credential
|
||||
"""
|
||||
cred_prompt = f"[cyan]🤫 Enter your Bitwarden vault {credential}"
|
||||
return Prompt.ask(cred_prompt, password=True)
|
||||
|
||||
def status(self) -> str:
|
||||
"""
|
||||
generate a new password. Takes special_characters bool.
|
||||
"""
|
||||
log.info('Checking if you are logged in...')
|
||||
return json.loads(subproc(["bw status"], env=self.env))['status']
|
||||
|
||||
def unlock(self) -> None:
|
||||
"""
|
||||
unlocks the local bitwarden vault, and returns session token
|
||||
"""
|
||||
if self.env['BW_SESSION']:
|
||||
log.info('Using session token from $BW_SESSION env variable')
|
||||
self.delete_session = False
|
||||
|
||||
status = self.status()
|
||||
if status == "locked" or status == "unauthenticated":
|
||||
env = {"BW_PASSWORD": self.password,
|
||||
"BW_CLIENTID": self.client_id,
|
||||
"BW_CLIENTSECRET": self.client_secret,
|
||||
"BW_HOST": self.host,
|
||||
"PATH": self.env['PATH'],
|
||||
"HOME": self.env['HOME'],
|
||||
"NODE_OPTIONS": "--no-deprecation"}
|
||||
|
||||
# login if we need to
|
||||
if status == "unauthenticated":
|
||||
log.info('Logging into the Bitwarden vault...')
|
||||
# set command to login if we're unauthenticated
|
||||
cmd = f"{self.bw_path} login --passwordenv BW_PASSWORD --apikey --raw"
|
||||
subproc([cmd], quiet=True, env=env)
|
||||
|
||||
# we still need to unlock, even if we logged in already
|
||||
if status == "locked" or status == "unauthenticated":
|
||||
log.info('Unlocking the Bitwarden vault...')
|
||||
# set command to unlock if status is locked
|
||||
cmd = f"{self.bw_path} unlock --passwordenv BW_PASSWORD --raw"
|
||||
|
||||
# run either bw login or bw unlock depending on bw status
|
||||
self.env['BW_SESSION'] = subproc([cmd], quiet=True, env=env)
|
||||
log.debug(f"bw unlock session is {self.env['BW_SESSION']}")
|
||||
log.info('Unlocked the Bitwarden vault.')
|
||||
else:
|
||||
log.info(f"[green]bw status[/] returned '{status}', so we won't "
|
||||
"unlock the Bitwarden vault before starting.")
|
||||
|
||||
|
||||
def create_custom_field(custom_field_name: str, value: str) -> dict:
|
||||
"""
|
||||
creates a custom field dict for a bitwarden login item
|
||||
"""
|
||||
custom_field = {"name": custom_field_name,
|
||||
"value": value,
|
||||
"type": 1,
|
||||
"linkedId": None}
|
||||
|
||||
return custom_field
|
||||
|
||||
def lock(self) -> None:
|
||||
"""
|
||||
lock bitwarden vault, only if the user didn't have a session env var,
|
||||
so that we don't clean up a session the user didn't intend for
|
||||
"""
|
||||
if self.delete_session:
|
||||
log.info('Locking the Bitwarden vault...')
|
||||
subproc([f"{self.bw_path} lock"], env=self.env)
|
||||
log.info('Bitwarden vault locked.')
|
||||
else:
|
||||
log.debug("We didn't lock the Bitwarden vault when we were done, "
|
||||
"because we didn't set the BW_SESSION env var, so we"
|
||||
" don't want to be rude.")
|
||||
|
||||
def generate(self, special_characters: bool = False) -> str:
|
||||
"""
|
||||
generate a new password. Takes special_characters bool.
|
||||
"""
|
||||
log.debug('Generating a new password...')
|
||||
|
||||
command = "bw generate --length 32 --uppercase --lowercase --number"
|
||||
if special_characters:
|
||||
command += " --special"
|
||||
|
||||
password = subproc([command], quiet=True)
|
||||
log.debug('New password generated.')
|
||||
return password
|
||||
|
||||
def get_item(self, item_name: str, sync_first: bool = True) -> list:
|
||||
"""
|
||||
Get Item and return False if it does not exist. If item exists:
|
||||
return data, unless there's more than one, then return multiple IDs
|
||||
|
||||
Required Args:
|
||||
- item_name: str of name of item
|
||||
"""
|
||||
# always sync vault before checking anything, unless otherwise stated
|
||||
if sync_first:
|
||||
self.sync()
|
||||
|
||||
# go get the actual item
|
||||
response = json.loads(
|
||||
subproc([f'{self.bw_path} get item {item_name} --response'],
|
||||
error_ok=True,
|
||||
quiet=True,
|
||||
env=self.env)
|
||||
)
|
||||
|
||||
message = response.get("message", "")
|
||||
|
||||
# if there is no item, just return False
|
||||
if message == "Not found.":
|
||||
log.debug(response)
|
||||
return False, None
|
||||
|
||||
elif 'More than one result was found' in message:
|
||||
item_list = response['data']
|
||||
log.warn(f"found more than 1 entry for {item_name}: {item_list}")
|
||||
# make a list of each full item
|
||||
list_for_dialog = []
|
||||
|
||||
# ask the user what to do
|
||||
if self.tui:
|
||||
for id in item_list:
|
||||
list_for_dialog.append(self.get_item(id)[0])
|
||||
|
||||
user_response = AskUserForDuplicateStrategy(list_for_dialog,
|
||||
item_name).run()
|
||||
action = user_response[0]
|
||||
always_do_action = user_response[1]
|
||||
item = user_response[2]
|
||||
|
||||
else:
|
||||
action = Prompt.ask(
|
||||
f"Found more than 1 entry for {item_name}. "
|
||||
"What would you like to do?",
|
||||
choices=["duplicate", "edit", "no_action"])
|
||||
if action == "edit":
|
||||
print("Here are the items:")
|
||||
for id in item_list:
|
||||
item_data = self.get_item(id)[0]
|
||||
print(f"ID: {item_data['id']}, Name: {item_data['name']}")
|
||||
list_for_dialog.append(item_data['id'])
|
||||
|
||||
item = Prompt.ask("Which item ID would you like to edit?",
|
||||
choices=(list_for_dialog))
|
||||
elif action == "duplicate" or action == "no_action":
|
||||
always_do_action = Confirm.ask(
|
||||
f"Would you like to '{action}' every time?")
|
||||
|
||||
# if they always want to do this, then set self.duplicate_strategy
|
||||
if always_do_action:
|
||||
# NOTE: we still always ask if there's more than 1 entry returned
|
||||
self.duplicate_strategy = action
|
||||
|
||||
return item, action
|
||||
else:
|
||||
data = response.get('data', "")
|
||||
log.debug(data)
|
||||
if not data:
|
||||
log.debug(response)
|
||||
return data, self.duplicate_strategy
|
||||
|
||||
def list_items(self, url: str = "", sync_first: bool = True) -> dict:
|
||||
"""
|
||||
get multiplte times associated with a given url.
|
||||
|
||||
Optionally specify:
|
||||
sync_first: bool - sync the vault before checking for items
|
||||
|
||||
Returns a dict of name: id
|
||||
"""
|
||||
# always sync vault before checking anything, unless otherwise stated
|
||||
if sync_first:
|
||||
self.sync()
|
||||
|
||||
# go get the actual item
|
||||
response = json.loads(
|
||||
subproc([f'{self.bw_path} list items --search {url}'],
|
||||
error_ok=True,
|
||||
quiet=True,
|
||||
env=self.env
|
||||
)
|
||||
)
|
||||
|
||||
# if there is no item, just return False
|
||||
if not response:
|
||||
log.debug("We didn't get anything back from bitwarden... 🤔")
|
||||
return None
|
||||
else:
|
||||
# make a convenient dictionary to use downstream
|
||||
item_dict = {}
|
||||
for item in response:
|
||||
name = item['name']
|
||||
item_dict[name] = item['id']
|
||||
return item_dict
|
||||
|
||||
def create_login(self,
|
||||
name: str = "",
|
||||
item_url: str = "",
|
||||
user: str = "",
|
||||
password: str = "",
|
||||
fields: list = [],
|
||||
org: str = None,
|
||||
collection: str = None,
|
||||
strategy: str = None,
|
||||
sync: bool = None) -> str:
|
||||
"""
|
||||
Create login item to store a set of credentials for one site.
|
||||
Required Args:
|
||||
- name: str of the name of the item to create in the vault
|
||||
Optional Args:
|
||||
- user: str of username to use for login item
|
||||
- password: str of password you want to use for login item
|
||||
- item_url: str of URL you want to use the credentials for
|
||||
- org: str of organization to use for collection
|
||||
- collection: str collection inside organization to user
|
||||
- fields: list of {key: value} dicts for custom fields
|
||||
- strategy: str that defaults to self.duplicate_strategy
|
||||
|
||||
Returns string of the item id created or updated
|
||||
"""
|
||||
# don't edit anything by default
|
||||
edit = False
|
||||
|
||||
# fix naming for bitwarden items to inlude the url AND name
|
||||
if name:
|
||||
item_name = name
|
||||
if item_url:
|
||||
item_name += f"-{item_url}"
|
||||
else:
|
||||
item_name = item_url
|
||||
|
||||
# make sure sync is set to False by default
|
||||
if not sync:
|
||||
sync = False
|
||||
|
||||
# go check for existing items
|
||||
item_res = self.get_item(item_name, sync)
|
||||
item = item_res[0]
|
||||
|
||||
if not strategy:
|
||||
strategy = item_res[1]
|
||||
|
||||
if item:
|
||||
if strategy == "ask":
|
||||
if self.tui:
|
||||
user_response = AskUserForDuplicateStrategy(item,
|
||||
item_name).run()
|
||||
strategy = user_response[0]
|
||||
always_do_action = user_response[1]
|
||||
else:
|
||||
item_desc = f'"{item['name']}" (id: {item['id']})'
|
||||
strategy = Prompt.ask(
|
||||
f"A similar entry already exists for {item_name}. "
|
||||
f"It's called {item_desc}. What would you like to do?",
|
||||
choices=["duplicate", "edit", "no_action"])
|
||||
always_do_action = Confirm.ask(
|
||||
f"Would you like to '{strategy}' every time?")
|
||||
|
||||
# if they always want to do this, then set self.duplicate_strategy
|
||||
if always_do_action:
|
||||
# NOTE: we still always ask if there's more than 1 entry returned
|
||||
self.duplicate_strategy = strategy
|
||||
|
||||
if strategy == 'edit':
|
||||
log.info("duplicate_strategy set to edit, so we will edit the "
|
||||
f"existing item: {name}")
|
||||
edit = True
|
||||
|
||||
elif strategy == 'duplicate':
|
||||
msg = (f"😵 Item named {name} already exists in your Bitwarden"
|
||||
" vault and duplicate_strategy is set to 'duplicate'."
|
||||
" We will create the item anyway, but the Bitwarden ESO "
|
||||
"Provider may have trouble finding it :(")
|
||||
log.warn(msg)
|
||||
|
||||
elif strategy == "no_action":
|
||||
log.info(
|
||||
"We've encounted an existing entry for the item we were going "
|
||||
" to create. duplicate_strategy is set to 'no_action', so we "
|
||||
"will not replace or edit it nor will we create a new item."
|
||||
f"item: {item}"
|
||||
)
|
||||
return
|
||||
|
||||
# create new item
|
||||
if not edit:
|
||||
if item:
|
||||
log.info(f'Not editing Bitwarden item "{item_name}", because we '
|
||||
'were instructed to create a duplicate.')
|
||||
else:
|
||||
log.info(f'Creating Bitwarden login item "{item_name}"')
|
||||
|
||||
login_obj = json.dumps({
|
||||
"organizationId": org,
|
||||
"collectionIds": collection,
|
||||
"folderId": None,
|
||||
"type": 1,
|
||||
"name": item_name,
|
||||
"notes": None,
|
||||
"favorite": False,
|
||||
"fields": fields,
|
||||
"login": {"uris": [{"match": 0,
|
||||
"uri": item_url}],
|
||||
"username": user,
|
||||
"password": password,
|
||||
"totp": None},
|
||||
"secureNote": None,
|
||||
"card": None,
|
||||
"identity": None,
|
||||
"reprompt": 0})
|
||||
|
||||
encodedBytes = base64.b64encode(login_obj.encode("utf-8"))
|
||||
encodedStr = str(encodedBytes, "utf-8")
|
||||
|
||||
cmd = f"{self.bw_path} create item {encodedStr}"
|
||||
|
||||
# edit existing item
|
||||
else:
|
||||
log.info(f'Updating existing Bitwarden login item "{item_name}"...')
|
||||
item['login']['password'] = password
|
||||
item['login']['username'] = user
|
||||
item['fields'] = fields
|
||||
|
||||
encodedBytes = base64.b64encode(json.dumps(item).encode("utf-8"))
|
||||
encodedStr = str(encodedBytes, "utf-8")
|
||||
|
||||
cmd = f"{self.bw_path} edit item {item['id']} {encodedStr}"
|
||||
|
||||
|
||||
# edit OR create the item
|
||||
bitwarden_return_item = subproc([cmd + " --response"], quiet=True, env=self.env)
|
||||
log.debug(bitwarden_return_item)
|
||||
|
||||
if edit:
|
||||
return item['id']
|
||||
else:
|
||||
return json.loads(bitwarden_return_item)['data']['id']
|
||||
81
bitwarden_wrapper/tui/bitwarden.css
Normal file
81
bitwarden_wrapper/tui/bitwarden.css
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
$bluish_white: rgb(189,216,255);
|
||||
$lavender: rgb(174,168,248);
|
||||
$spacechalk_red: rgb(255,141,135);
|
||||
$neon_magenta: rgb(242,137,249);
|
||||
$light_pink: rgb(255,175,249);
|
||||
$orange: rgb(253,205,54);
|
||||
$soft_yellow: rgb(249,249,134);
|
||||
$soft_green: rgb(193,255,135);
|
||||
$spacechalk_lime: rgb(168,253,87);
|
||||
$sky_blue: rgb(92,201,253);
|
||||
$cornflower: rgb(95,135,255);
|
||||
$light_cornflower: rgb(122,162,247);
|
||||
$blue_gray: rgb(86,95,137);
|
||||
$dark_gray: rgb(58,58,58);
|
||||
$navy: rgb(35,35,54);
|
||||
|
||||
/* base container for the whole screen */
|
||||
#bitwarden-modal-container {
|
||||
width: 90%;
|
||||
height: 60%;
|
||||
align: center middle;
|
||||
background: $navy 50%;
|
||||
}
|
||||
|
||||
/* box with border and inputs and button */
|
||||
#credentials-box {
|
||||
align: center middle;
|
||||
content-align: center middle;
|
||||
padding: 1;
|
||||
border: round $cornflower;
|
||||
border-title-color: $soft_green;
|
||||
grid-gutter: 1;
|
||||
grid-rows: 0.25fr 1fr 0.25fr;
|
||||
}
|
||||
|
||||
/* help blurb */
|
||||
#bitwarden-help-text {
|
||||
color: $blue_gray;
|
||||
width: 100%;
|
||||
margin-left: 1;
|
||||
}
|
||||
|
||||
#all-bitwarden-inputs {
|
||||
align: center middle;
|
||||
content-align: center middle;
|
||||
grid-gutter: 1;
|
||||
padding-left: 1;
|
||||
}
|
||||
|
||||
/* bitwarden label and input row */
|
||||
.bitwarden-input-row {
|
||||
grid-size: 2;
|
||||
grid-columns: 0.42fr 1fr;
|
||||
height: auto;
|
||||
align: center middle;
|
||||
content-align: center middle;
|
||||
}
|
||||
|
||||
/* bitwarden input label */
|
||||
.bitwarden-label {
|
||||
content-align: left middle;
|
||||
color: $light_cornflower 80%;
|
||||
width: 100%;
|
||||
height: 3;
|
||||
}
|
||||
|
||||
/* bitwarden input */
|
||||
.bitwarden-inputs {
|
||||
height: 100%;
|
||||
content-align: left middle;
|
||||
}
|
||||
|
||||
/* submit button */
|
||||
#bitwarden-button-box {
|
||||
grid-size: 2;
|
||||
align: center middle;
|
||||
margin-bottom: 1;
|
||||
}
|
||||
|
||||
#bitwarden-submit {
|
||||
}
|
||||
78
bitwarden_wrapper/tui/bitwarden_app.py
Normal file
78
bitwarden_wrapper/tui/bitwarden_app.py
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
from smol_k8s_lab.tui.bitwarden.bitwarden_credentials_modal_screen import (
|
||||
BitwardenCredentialsScreen)
|
||||
from textual.app import App, ComposeResult
|
||||
from textual.widgets import Label
|
||||
|
||||
|
||||
class BitwardenCredentialsApp(App[None]):
|
||||
"""
|
||||
small app to launch a modal screen for a bitwarden credentials prompt
|
||||
"""
|
||||
CSS = """
|
||||
$bluish_white: rgb(189,216,255);
|
||||
$lavender: rgb(174,168,248);
|
||||
$neon_magenta: rgb(242,137,249);
|
||||
$orange: rgb(253,205,54);
|
||||
$spacechalk_lime: rgb(168,253,87);
|
||||
$light_cornflower: rgb(122,162,247);
|
||||
$blue_gray: rgb(86,95,137);
|
||||
$dark_gray: rgb(58,58,58);
|
||||
$navy: rgb(35,35,54);
|
||||
|
||||
Screen {
|
||||
align: center middle;
|
||||
}
|
||||
|
||||
Tooltip {
|
||||
background: $navy 50%;
|
||||
color: $bluish_white 75%;
|
||||
border: dashed gray 80%;
|
||||
padding-bottom: 0;
|
||||
padding-left: 1;
|
||||
padding-right: 1;
|
||||
}
|
||||
|
||||
Button {
|
||||
color: $light_cornflower;
|
||||
background: $lavender 10%;
|
||||
border-top: tall $blue_gray 60%;
|
||||
border-bottom: tall $dark_gray 50%;
|
||||
}
|
||||
|
||||
Input {
|
||||
background: $bluish_white 8%;
|
||||
color: white 75%;
|
||||
border: tall black 18%;
|
||||
}
|
||||
|
||||
Input.-invalid {
|
||||
border: tall $neon_magenta 90%;
|
||||
}
|
||||
|
||||
Input.-valid:focus {
|
||||
border: tall $spacechalk_lime 70%;
|
||||
}
|
||||
"""
|
||||
|
||||
def compose(self) -> ComposeResult:
|
||||
"""
|
||||
check if we need to grab the password or not
|
||||
"""
|
||||
yield Label("")
|
||||
self.get_credentials()
|
||||
|
||||
def get_credentials(self) -> None:
|
||||
"""
|
||||
launch a modal screen wtih inputs for bitwarden credentials
|
||||
"""
|
||||
def check_modal_output(credentials: dict):
|
||||
if credentials:
|
||||
self.app.exit(credentials)
|
||||
else:
|
||||
self.app.exit(None)
|
||||
|
||||
self.app.push_screen(BitwardenCredentialsScreen(), check_modal_output)
|
||||
|
||||
if __name__ == "__main__":
|
||||
app = BitwardenCredentialsApp()
|
||||
app.run()
|
||||
119
bitwarden_wrapper/tui/bitwarden_credentials_modal_screen.py
Normal file
119
bitwarden_wrapper/tui/bitwarden_credentials_modal_screen.py
Normal file
|
|
@ -0,0 +1,119 @@
|
|||
from rich.text import Text
|
||||
from textual import on
|
||||
from textual.app import ComposeResult
|
||||
from textual.binding import Binding
|
||||
from textual.containers import Grid
|
||||
from textual.screen import ModalScreen
|
||||
from textual.validation import Length
|
||||
from textual.widgets import Label, Input, Button
|
||||
|
||||
|
||||
HELP_TXT = ("Requires [u][link=https://bitwarden.com/help/personal-api-key/]"
|
||||
"personal API credentials[/][/]. To avoid this prompt, export the "
|
||||
"following env vars before running smol-k8s-lab: "
|
||||
"BW_PASSWORD, BW_CLIENTID, BW_CLIENTSECRET")
|
||||
|
||||
|
||||
class BitwardenCredentialsScreen(ModalScreen):
|
||||
"""
|
||||
modal screen to ask for bitwarden credentials
|
||||
"""
|
||||
CSS_PATH = "./bitwarden.css"
|
||||
BINDINGS = [Binding(key="b,escape,q",
|
||||
key_display="b",
|
||||
action="press_cancel",
|
||||
description=" Back")]
|
||||
|
||||
def compose(self) -> ComposeResult:
|
||||
|
||||
# base container for the whole screen
|
||||
with Grid(id="bitwarden-modal-container"):
|
||||
|
||||
# container for the actual help, inputs, and confirm button
|
||||
with Grid(id="credentials-box"):
|
||||
|
||||
# base help text to start us off
|
||||
yield Label(Text.from_markup(HELP_TXT), id="bitwarden-help-text")
|
||||
|
||||
with Grid(id="all-bitwarden-inputs"):
|
||||
for variable in ['password', 'client_id', 'client_secret']:
|
||||
yield self.generate_credential_row(variable)
|
||||
|
||||
with Grid(id="bitwarden-button-box"):
|
||||
# submit button, to trigger returning the credentials/exiting
|
||||
confirm_button = Button("submit", id="bitwarden-submit")
|
||||
confirm_button.disabled = True
|
||||
confirm_button.tooltip = ("submit your credentials, disabled"
|
||||
" until all fields are filled out.")
|
||||
yield confirm_button
|
||||
|
||||
# cancel button, to go back to the script or previous tui screen
|
||||
back_button = Button("cancel", id="bitwarden-cancel")
|
||||
back_button.tooltip = ("Exit Bitwarden credentials input screen "
|
||||
"without saving")
|
||||
yield back_button
|
||||
|
||||
def on_mount(self,) -> None:
|
||||
credentials_box = self.get_widget_by_id("credentials-box")
|
||||
credentials_box.border_title = "🛡️ Enter Bitwarden Vault Credentials"
|
||||
|
||||
# we set this at the beginning, so we can still return empty if they cancel
|
||||
self.credentials = {}
|
||||
|
||||
def action_press_cancel(self) -> None:
|
||||
"""
|
||||
presses the cancel button
|
||||
"""
|
||||
self.get_widget_by_id("bitwarden-cancel").action_press()
|
||||
|
||||
def on_button_pressed(self, event: Button.Pressed) -> None:
|
||||
"""
|
||||
return bitwarden password, client id, and client secret as a dict
|
||||
"""
|
||||
if event.button.id == "bitwarden-cancel":
|
||||
self.dismiss(None)
|
||||
else:
|
||||
self.dismiss(self.credentials)
|
||||
|
||||
@on(Input.Changed)
|
||||
def on_input_changed(self, event: Input.Changed) -> None:
|
||||
"""
|
||||
on any input field change, check all input fields and enable or disable
|
||||
the confirm button
|
||||
"""
|
||||
all_valid = True
|
||||
|
||||
all_inputs = self.query(".bitwarden-inputs")
|
||||
|
||||
# check all the input validations
|
||||
for input in all_inputs:
|
||||
is_not_valid = input.validate(input.value).failures
|
||||
# returns None if input is valid
|
||||
if is_not_valid:
|
||||
all_valid = False
|
||||
# if valid, make sure it's in our final return dict
|
||||
else:
|
||||
self.credentials[input.name] = input.value
|
||||
|
||||
confirm_button = self.get_widget_by_id("bitwarden-submit")
|
||||
|
||||
# disable button if any inputs are invalid
|
||||
if all_valid:
|
||||
confirm_button.disabled = False
|
||||
else:
|
||||
confirm_button.disabled = True
|
||||
|
||||
def generate_credential_row(self, label: str) -> None:
|
||||
"""
|
||||
return a row of a Label and Input in a Grid container
|
||||
"""
|
||||
pretty_label = label.replace("_", " ").replace("id", "ID") + ":"
|
||||
input_label = Label(pretty_label, classes="bitwarden-label")
|
||||
|
||||
input = Input(placeholder=label,
|
||||
password=True,
|
||||
validators=Length(minimum=2),
|
||||
classes="bitwarden-inputs",
|
||||
name=label)
|
||||
|
||||
return Grid(input_label, input, classes="bitwarden-input-row")
|
||||
109
bitwarden_wrapper/tui/bitwarden_existing_item.tcss
Normal file
109
bitwarden_wrapper/tui/bitwarden_existing_item.tcss
Normal file
|
|
@ -0,0 +1,109 @@
|
|||
$bluish_white: rgb(189,216,255);
|
||||
$lavender: rgb(174,168,248);
|
||||
$spacechalk_red: rgb(255,141,135);
|
||||
$neon_magenta: rgb(242,137,249);
|
||||
$light_pink: rgb(255,175,249);
|
||||
$orange: rgb(253,205,54);
|
||||
$soft_yellow: rgb(249,249,134);
|
||||
$soft_green: rgb(193,255,135);
|
||||
$spacechalk_lime: rgb(168,253,87);
|
||||
$sky_blue: rgb(92,201,253);
|
||||
$cornflower: rgb(95,135,255);
|
||||
$light_cornflower: rgb(122,162,247);
|
||||
$blue_gray: rgb(86,95,137);
|
||||
$dark_gray: rgb(58,58,58);
|
||||
$navy: rgb(35,35,54);
|
||||
|
||||
/* Matches the entire screen */
|
||||
Screen {
|
||||
align: center middle;
|
||||
}
|
||||
|
||||
Tooltip {
|
||||
background: $navy 50%;
|
||||
color: $bluish_white 75%;
|
||||
border: dashed gray 80%;
|
||||
padding-bottom: 0;
|
||||
padding-left: 1;
|
||||
padding-right: 1;
|
||||
}
|
||||
|
||||
Button {
|
||||
color: $light_cornflower;
|
||||
background: $lavender 10%;
|
||||
border-top: tall $blue_gray 60%;
|
||||
border-bottom: tall $dark_gray 50%;
|
||||
}
|
||||
|
||||
Label {
|
||||
color: $lavender;
|
||||
width: 100%;
|
||||
content-align: center middle;
|
||||
margin-top: 2;
|
||||
height: 3;
|
||||
}
|
||||
|
||||
/* select an item to view/edit radioset */
|
||||
RadioSet {
|
||||
height: auto;
|
||||
padding-top: 1;
|
||||
padding-bottom: 1;
|
||||
align: center middle;
|
||||
content-align: center middle;
|
||||
width: 100%;
|
||||
color: $bluish_white;
|
||||
margin-bottom: 1;
|
||||
border: solid $light_cornflower;
|
||||
border-title-color: $sky_blue;
|
||||
background: $navy;
|
||||
}
|
||||
|
||||
/* whole screen grid */
|
||||
#main-screen-grid {
|
||||
border: solid $cornflower;
|
||||
border-title-color: $sky_blue;
|
||||
width: 80%;
|
||||
height: 85%;
|
||||
padding: 1;
|
||||
grid-rows: 0.8fr 0.6fr 0.15fr;
|
||||
align: center middle;
|
||||
background: $navy 50%;
|
||||
}
|
||||
|
||||
/* includes both the selection list, if exists, and the actual vault item */
|
||||
#all-duplicates-view {
|
||||
align: center middle;
|
||||
padding-top: 1;
|
||||
}
|
||||
|
||||
/* the vault item preview */
|
||||
#pretty-scroll {
|
||||
border: solid $blue_gray;
|
||||
border-title-color: $sky_blue;
|
||||
scrollbar-background: $dark_gray;
|
||||
scrollbar-background-active: $dark_gray;
|
||||
scrollbar-background-hover: $dark_gray;
|
||||
scrollbar-color-active: $sky_blue;
|
||||
scrollbar-color-hover: $cornflower;
|
||||
scrollbar-color: $light_cornflower;
|
||||
}
|
||||
|
||||
#question-box {
|
||||
grid-gutter: 1;
|
||||
grid-rows: 0.25fr 0.25fr 0.5fr;
|
||||
}
|
||||
|
||||
/* just the three option buttons */
|
||||
#button-grid {
|
||||
height: 5;
|
||||
grid-size: 3;
|
||||
align: center middle;
|
||||
content-align: center middle;
|
||||
}
|
||||
|
||||
#always-checkbox {
|
||||
width: 100%;
|
||||
content-align: center middle;
|
||||
background: $navy 1%;
|
||||
color: $bluish_white;
|
||||
}
|
||||
169
bitwarden_wrapper/tui/bitwarden_existing_item_app.py
Normal file
169
bitwarden_wrapper/tui/bitwarden_existing_item_app.py
Normal file
|
|
@ -0,0 +1,169 @@
|
|||
from textual.app import App, ComposeResult
|
||||
from textual.containers import Grid, VerticalScroll, Container
|
||||
from textual.widgets import Label, Pretty, Checkbox, Button, RadioSet, RadioButton
|
||||
|
||||
|
||||
class AskUserForDuplicateStrategy(App[None]):
|
||||
"""
|
||||
ask user how to handle creating an item when duplicate[s] found
|
||||
"""
|
||||
|
||||
CSS_PATH = ["./bitwarden_existing_item.tcss"]
|
||||
|
||||
def __init__(self, duplicate_item: dict | list, item_searched: str) -> None:
|
||||
self.duplicate_item = duplicate_item
|
||||
self.item_searched = item_searched
|
||||
self.always_do = False
|
||||
super().__init__()
|
||||
|
||||
def compose(self) -> ComposeResult:
|
||||
"""
|
||||
check if we need to grab the password or not
|
||||
"""
|
||||
with Grid(id="main-screen-grid"):
|
||||
with Container(id="all-duplicates-view"):
|
||||
if isinstance(self.duplicate_item, list):
|
||||
with RadioSet():
|
||||
for item in self.duplicate_item:
|
||||
button = RadioButton(item['id'])
|
||||
# set the radio button to be a heart :3
|
||||
button.BUTTON_INNER = "♥ "
|
||||
yield button
|
||||
with VerticalScroll(id="pretty-scroll"):
|
||||
yield Pretty("Select an item above to preview")
|
||||
|
||||
|
||||
with Grid(id="question-box"):
|
||||
yield Label("How would you like to proceed?")
|
||||
check_box = Checkbox("Always perform this action",
|
||||
id="always-checkbox")
|
||||
yield check_box
|
||||
|
||||
with Grid(id="button-grid"):
|
||||
edit_button = Button("✏️ Edit", id="edit-button")
|
||||
edit_button.tooltip = "Edit the existing Vault item with new info"
|
||||
yield edit_button
|
||||
|
||||
duplicate_button = Button("👥 Duplicate", id="duplicate-button")
|
||||
duplicate_button.tooltip = "Create an additional Vault item"
|
||||
yield duplicate_button
|
||||
|
||||
no_action_button = Button("⛔️ No Action", id="no-action-button")
|
||||
no_action_button.tooltip = "Use the existing Vault item"
|
||||
yield no_action_button
|
||||
|
||||
def on_mount(self) -> None:
|
||||
"""
|
||||
border styling and enabling of the edit button
|
||||
"""
|
||||
pretty_scroll = self.get_widget_by_id("pretty-scroll")
|
||||
pretty_scroll.border_title = "Bitarden Vault Item [#C1FF87]Preview[/]"
|
||||
if isinstance(self.duplicate_item, list):
|
||||
box_title = ('[#ffaff9][i]duplicate[/i] items[/] found for '
|
||||
f'[#C2FF87]{self.item_searched}[/] in your vault')
|
||||
|
||||
# disable the edit button till a user has selected an item
|
||||
edit_button = self.get_widget_by_id("edit-button")
|
||||
edit_button.disabled = True
|
||||
edit_button.tooltip = ("Select an item above to have smol-k8s-lab "
|
||||
"edit the existing item in your Vault.")
|
||||
|
||||
self.query_one(RadioSet).border_title = (
|
||||
"[#ffaff9]♥[/] [i]select[/] an item to view/edit")
|
||||
else:
|
||||
self.query_one(Pretty).update(self.duplicate_item)
|
||||
box_title = (
|
||||
"An [#ffaff9][i]existing[/i] item[/] for "
|
||||
f"[#C1FF87]{self.item_searched}[/] found in your vault"
|
||||
)
|
||||
|
||||
self.get_widget_by_id("main-screen-grid").border_title = box_title
|
||||
|
||||
def on_check_box_ticked(self, event: Checkbox.Changed) -> None:
|
||||
"""
|
||||
if the checkbox is selected, we update the self.always_do variable
|
||||
"""
|
||||
self.always_do = event.checkbox.value
|
||||
|
||||
def on_radio_set_changed(self, event: RadioSet.Changed) -> None:
|
||||
"""
|
||||
if any radio set button is selected, update the Pretty widget and
|
||||
make sure the edit button is enabled again
|
||||
"""
|
||||
pressed_index = event.radio_set.pressed_index
|
||||
self.query_one(Pretty).update(self.duplicate_item[pressed_index])
|
||||
self.get_widget_by_id("edit-button").disabled = False
|
||||
|
||||
def on_button_pressed(self, event: Button.Pressed) -> None:
|
||||
"""
|
||||
if any button is pressed, take action and exit
|
||||
"""
|
||||
if isinstance(self.duplicate_item, list):
|
||||
item = self.duplicate_item[self.query_one(RadioSet).pressed_index]
|
||||
else:
|
||||
item = self.duplicate_item
|
||||
|
||||
if event.button.id == "no-action-button":
|
||||
self.app.exit(["no_action", self.always_do, item])
|
||||
|
||||
if event.button.id == "edit-button":
|
||||
self.app.exit(["edit", self.always_do, item])
|
||||
|
||||
if event.button.id == "duplicate-button":
|
||||
self.app.exit(["duplicate", self.always_do, item])
|
||||
|
||||
# for testing only
|
||||
if __name__ == "__main__":
|
||||
item = {"creationDate": "2022-03-19T12:22:02.920Z",
|
||||
"id": "2222224b-u94j-rv85-8787-y5555555555o",
|
||||
"organizationId": None,
|
||||
"folderId": "33333333-c5l8-328a-ge49-ve0000000000",
|
||||
"name": "www.bol.com",
|
||||
"notes": None,
|
||||
"favorite": False,
|
||||
"login": {
|
||||
"uris": [
|
||||
{"match": None,
|
||||
"uri": "https://www.test.com/"}
|
||||
],
|
||||
"username": "test@test.test",
|
||||
"password": "passwordthatissupposedtobesecurebutisnot",
|
||||
"passwordRevisionDate": None}
|
||||
}
|
||||
item_list = [
|
||||
{"creationDate": "2022-02-19T12:22:02.920Z",
|
||||
"id": "2222224b-u94j-rv85-8787-y5555555555o",
|
||||
"organizationId": None,
|
||||
"folderId": "33333333-c5l8-328a-ge49-ve0000000000",
|
||||
"name": "www.bol.com",
|
||||
"notes": None,
|
||||
"favorite": False,
|
||||
"login": {
|
||||
"uris": [
|
||||
{"match": None,
|
||||
"uri": "https://www.test.com/"}
|
||||
],
|
||||
"username": "test@test.test",
|
||||
"password": "passwordthatissupposedtobesecure",
|
||||
"passwordRevisionDate": None}
|
||||
},
|
||||
{"creationDate": "2023-02-19T12:22:02.920Z",
|
||||
"id": "2247q311-b06a-ww85-9532-a00000bb548f",
|
||||
"organizationId": None,
|
||||
"folderId": "33333333-c5l8-328a-ge49-ve0000000000",
|
||||
"name": "www.bol.com",
|
||||
"notes": None,
|
||||
"favorite": False,
|
||||
"login": {
|
||||
"uris": [
|
||||
{"match": None,
|
||||
"uri": "https://www.test.com/"}
|
||||
],
|
||||
"username": "test@test.test",
|
||||
"password": "supposedtobesecurebutisnot",
|
||||
"passwordRevisionDate": None}
|
||||
}
|
||||
]
|
||||
app = AskUserForDuplicateStrategy(item,
|
||||
"argocd-admin-credentials-argo.test.com")
|
||||
app.run()
|
||||
1579
poetry.lock
generated
Normal file
1579
poetry.lock
generated
Normal file
File diff suppressed because it is too large
Load diff
45
pyproject.toml
Normal file
45
pyproject.toml
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
[project]
|
||||
name = "bitwarden-wrapper"
|
||||
version = "0.1.0"
|
||||
description = "Simple bitwarden cli wrapper that can get and create credentials."
|
||||
Authors = ["Jesse Hitch <jessebot@linux.com>"]
|
||||
readme = "README.md"
|
||||
packages = [{include = "bitwarden_wrapper"}]
|
||||
license = "AGPL-3.0-or-later"
|
||||
homepage = "https://bitwarden-wrapper.open.engineering"
|
||||
repository = "http://codeberg.org/open-engineering/bitwarden-wrapper"
|
||||
documentation = "https://bitwarden-wrapper.open.engineering"
|
||||
keywords = ["bitwarden", "passwordmanager"]
|
||||
classifiers = ["Development Status :: 4 - Beta",
|
||||
"Programming Language :: Python :: 3.13",
|
||||
"Programming Language :: Python :: 3.14",
|
||||
"Operating System :: MacOS :: MacOS X",
|
||||
"Operating System :: POSIX :: Linux",
|
||||
"License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)"]
|
||||
|
||||
[tool.poetry.urls]
|
||||
"Bug Tracker" = "http://codeberg.org/open-engineering/bitwarden-wrapper/issues"
|
||||
|
||||
[tool.poetry.dependencies]
|
||||
python = ">=3.13,<3.15"
|
||||
rich = "^14.1"
|
||||
rich-subproc = "^0.1.0"
|
||||
textual = "^8.0"
|
||||
|
||||
[tool.poetry.group.docs]
|
||||
optional = true
|
||||
|
||||
[tool.poetry.group.docs.dependencies]
|
||||
zensical = "^0.0.53"
|
||||
|
||||
[tool.poetry.group.dev]
|
||||
optional = true
|
||||
|
||||
[tool.poetry.group.dev.dependencies]
|
||||
deptry = "^0.25"
|
||||
textual-dev = "^1.7"
|
||||
pytest-textual-snapshot = "^1.0"
|
||||
|
||||
[build-system]
|
||||
requires = ["poetry-core"]
|
||||
build-backend = "poetry.core.masonry.api"
|
||||
Loading…
Reference in a new issue