Flip cat images upside down - Programming Test
This repository has been archived on 2020-12-30. You can view files and clone it, but cannot push or open issues/pull-requests.
Go to file
Arran 48888f1b1d Improve Readme formatting 2020-09-07 11:53:25 +02:00
Authentication Add JWT Authentication 2020-08-31 01:05:23 +02:00
Controllers Add JWT Authentication 2020-08-31 01:05:23 +02:00
Models Add JWT Authentication 2020-08-31 01:05:23 +02:00
Properties Add ImageController and basic project skeleton 2020-08-30 19:51:08 +02:00
.gitignore Initial Commit - Add GitIgnore 2020-08-28 20:33:06 +02:00
Dockerfile Add Docker support 2020-08-31 00:11:40 +02:00
LICENSE Add LICENSE 2020-08-30 19:51:08 +02:00
Program.cs Remove unnecessary 'using' statements 2020-08-30 19:51:08 +02:00
README.md Improve Readme formatting 2020-09-07 11:53:25 +02:00
Stac.csproj Add JWT Authentication 2020-08-31 01:05:23 +02:00
Startup.cs Define explicit password requirements 2020-08-31 01:05:23 +02:00
appsettings.Development.json Add JWT Authentication 2020-08-31 01:05:23 +02:00
appsettings.json Add JWT Authentication 2020-08-31 01:05:23 +02:00


Stac (Cats) 🐈

AspNetCore RESTful API to return upside-down cat pictures.


  • Authenticated access to upside-down cat pictures with tag support! eg. (angry, sad, beans)
  • Interactive Swagger Documentation
  • Simultaneous Cookie and JWT Authentication


.NET Core CLI Docker
dotnet restore docker build . -t stac
dotnet run docker run -p 8080:80 --rm stac

Environment Variables / Configuration

Configuration can be retreived from either appsettings.json or Environment Variables.

  • JWT_SIGNING_KEY: Signing key to generate and verify JSON web tokens. string
  • JWT_ISSUER: Issuer of the token string
  • JWT_AUDIENCE: Intended recipient of the token. string
  • JWT_VALIDITY: Validity of the token, in minutes. int

Quick Start

I recommend using the interactive Swagger documentation located at the root node: /.

If the CLI is your style, try: HTTPpie & HTTPie-JWT.

Register a new User

POST /user username=<username> password=<password>

Sign In

POST /authentication/signin username=<username> password=<password>

Enjoy upside-down cat pictures

GET /image/cat

GET /image/cat?tag=beans


GET /authentication/jwt

GET /image/cat Bearer=<token>

Development Notes

Project Structure

├── Controllers
│   ├── Authentication
│   │   └── AuthenticationController.cs
│   ├── User
│   │   └── UserController.cs
│   └── ImageController.cs
├── Models
│   └── UserInformation.cs
├── Program.cs
└── Startup.cs

For me, defining a directory structure is an important decision when beginning a new project. An intuitive structure aids the development process by making components painless to find and modify.

In this project the directory names are based on the RESTful API design, for example /authentication => Controllers/Authentication - This design helps determine what class is responsible for particular HTTP routes.

Project Philosophy

I have attempted to write as little code as possible, placing an importance on layout and readability which makes the project easily accessible to future developers.

Where possible, I have researched and integrated relevant packages. Utilizing these pre-existing solutions saves time, reduces code complexity and delegates maintenance to the respective package authors.

One concrete example is the image manipulation library - Instead of creating a function to flip the cat image, I opted for ImageSharp.


Well defined guidelines regarding commits and their messages add a new informational dimension to a project, one that helps paint a picture of how and why code has changed.

I emphasize:

  • Including concise, well defined changes.
  • Using an imperative mood in commit messages.
  • Capitalizing the beginning of the subject line.

Code Snippets


Open a cat image using a JWT.

$ T=<token>
$ http --auth-type=jwt --auth="${T}" localhost:8080/image/cat --output cat && xdg-open cat

Get UserInformation using a JWT.

$ T=<token>
$ http --auth-type=jwt --auth="${T}" localhost:8080/user