Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
244 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ uwsgi: | |
volumes: | ||
- .:/code | ||
- ./static:/var/www/static | ||
- ./images:/var/www/images | ||
links: | ||
- redis | ||
- db | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
# Setup | ||
By the time you get here, you have added all required secrets and settings to your [settings](../shub/settings) folder, and you've built and started the image. Next, you should navigate to [http://127.0.0.1](http://127.0.0.1) (localhost) to make sure the registry is up and running. | ||
|
||
## Image Interaction | ||
Before we work with accounts and other application setup, you need to know how to interact with the application, meaning Docker images. Here are the basic commands you should get comfortable with as an administrator of your registry. Note that these are really great for debugging too: | ||
|
||
``` | ||
docker ps # gets you the image ids | ||
docker-compose logs worker # show me the logs of the worker instance | ||
docker-compose logs nginx # logs for the main application | ||
docker-compose logs -f nginx # keep the logs open until I Control+C | ||
``` | ||
|
||
and to shell in to an image, you can do the following: | ||
|
||
``` | ||
NAME=$(docker ps -aqf "name=sregistry_uwsgi_1") | ||
docker exec -it ${NAME} bash | ||
``` | ||
|
||
## Accounts | ||
To create your admin account, the first thing you need to do (in the web interface) is click Login on the top right. You should see the social account options that you configured in the [deployment](deployment.md) step. You can now log in with your social account of choice. This will create a user account for yourself that you can use to manage the application, and when you are logged in you should see your username in the top right. It usually corresponds with the one from your social account. | ||
|
||
|
||
## The Application Manager | ||
At this point, you've started the application, and created a user with your social auth. Your username is in the top right, and it's usually the same as your social account. Keep this in mind because you will need it when you shell into the image to make yourself a superuser. Let's first shell inside: | ||
|
||
``` | ||
NAME=$(docker ps -aqf "name=sregistry_uwsgi_1") | ||
docker exec -it ${NAME} bash | ||
``` | ||
|
||
you will find yourself in a directory called `/code`, which is where the main application lives. For administration you will be using the file [manage.py](../manage.py) to interact with the registry. If you want to see all the different options, type `python manage.py` and it will show you. | ||
|
||
Let's first make yourself a superuser and an admin, meaning that you are an administrator **and** have godlevel control of the registry. Just by way of being inside the Docker image you already have that. You will be able to set other people as admins. In summary: | ||
|
||
- `superuser`: you are an admin that can do anything, you have all permissions. | ||
- `admin`: you can push images, but not have significant impact on the registry application. | ||
|
||
Of course anyone that shells into your Docker image could just explode everything - it's up to you to secure and manage the server itself! Let's say my username is `vsoch`. Here is the command I would run to make myself a superuser and admin. Note that we are inside the Docker image `sregistry_uwsgi_1`: | ||
|
||
```bash | ||
$ python manage.py add_superuser --username vsoch | ||
DEBUG Username: vsoch | ||
DEBUG vsoch is now a superuser. | ||
|
||
$ python manage.py add_superuser --username vsoch | ||
DEBUG Username: vsoch | ||
DEBUG vsoch can now manage and build. | ||
``` | ||
|
||
# And from outside the Docker image | ||
NAME=$(docker ps -aqf "name=sregistry_uwsgi_1") | ||
docker exec $NAME python /code/manage.py add_superuser --username vsoch | ||
docker exec $NAME python /code/manage.py add_admin --username vsoch | ||
|
||
``` | ||
You can also choose to remove a superuser or admin at any time. This means he or she will no longer be able to build and access the token and secret to do so. | ||
``` | ||
# Inside the image | ||
$ python manage.py remove_superuser --username vsoch | ||
$ python manage.py remove_admin --username vsoch | ||
|
||
# Outside | ||
NAME=$(docker ps -aqf "name=sregistry_uwsgi_1") | ||
docker exec $NAME python /code/manage.py remove_superuser --username vsoch | ||
docker exec $NAME python /code/manage.py remove_admin --username vsoch | ||
``` | ||
Great! Now that you have your accounts, you probably want to learn about how to build and push images! You will need to read about the [client](client.md) to do this. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
''' | ||
Copyright (c) 2017, Vanessa Sochat, All rights reserved. | ||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are met: | ||
* Redistributions of source code must retain the above copyright notice, this | ||
list of conditions and the following disclaimer. | ||
* Redistributions in binary form must reproduce the above copyright notice, | ||
this list of conditions and the following disclaimer in the documentation | ||
and/or other materials provided with the distribution. | ||
* Neither the name of the copyright holder nor the names of its | ||
contributors may be used to endorse or promote products derived from | ||
this software without specific prior written permission. | ||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | ||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
''' | ||
|
||
from django.core.management.base import ( | ||
BaseCommand, | ||
CommandError | ||
) | ||
|
||
from shub.apps.users.models import User | ||
from shub.logger import bot | ||
import re | ||
|
||
class Command(BaseCommand): | ||
'''add admin will add admin and manager privs singularity | ||
registry. The super user is an admin that can build, delete, | ||
and manage images | ||
''' | ||
def add_arguments(self, parser): | ||
# Positional arguments | ||
parser.add_argument('--username', dest='username', default=None, type=str) | ||
|
||
help = "Generates an admin for the registry." | ||
def handle(self,*args, **options): | ||
if options['username'] is None: | ||
raise CommandError("Please provide a username with --username") | ||
|
||
bot.debug("Username: %s" %options['username']) | ||
|
||
try: | ||
user = User.objects.get(username=options['username']) | ||
except User.DoesNotExist: | ||
raise CommandError("This username does not exist.") | ||
|
||
if user.admin is True: #and user.manager is True: | ||
raise CommandError("This user can already manage and build.") | ||
|
||
user.admin = True | ||
#user.manager = True | ||
user.save() | ||
bot.debug("%s can now manage and build." %(user.username)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
''' | ||
Copyright (c) 2017, Vanessa Sochat, All rights reserved. | ||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are met: | ||
* Redistributions of source code must retain the above copyright notice, this | ||
list of conditions and the following disclaimer. | ||
* Redistributions in binary form must reproduce the above copyright notice, | ||
this list of conditions and the following disclaimer in the documentation | ||
and/or other materials provided with the distribution. | ||
* Neither the name of the copyright holder nor the names of its | ||
contributors may be used to endorse or promote products derived from | ||
this software without specific prior written permission. | ||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | ||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
''' | ||
|
||
from django.core.management.base import ( | ||
BaseCommand, | ||
CommandError | ||
) | ||
|
||
from shub.apps.users.models import User | ||
from shub.logger import bot | ||
import re | ||
|
||
class Command(BaseCommand): | ||
'''remove admin will remove admin privs for a singularity | ||
registry. The super user is an admin that can build, delete, | ||
and manage images | ||
''' | ||
def add_arguments(self, parser): | ||
# Positional arguments | ||
parser.add_argument('--username', dest='username', default=None, type=str) | ||
|
||
help = "Removes admin priviledges for the registry." | ||
def handle(self,*args, **options): | ||
if options['username'] is None: | ||
raise CommandError("Please provide a username with --username") | ||
|
||
bot.debug("Username: %s" %options['username']) | ||
|
||
try: | ||
user = User.objects.get(username=options['username']) | ||
except User.DoesNotExist: | ||
raise CommandError("This username does not exist.") | ||
|
||
if user.admin is False: #and user.manager is False: | ||
raise CommandError("This user already can't manage and build.") | ||
|
||
user.admin = False | ||
#user.manager = False | ||
bot.debug("%s can no longer manage and build." %(user.username)) | ||
user.save() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters