-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft OpenApi Specification #1
Comments
Here we go: openapi: 3.0.1
info:
title: Docker-mailserver Administration API
version: 0.0.1
servers:
- url: 'https://contoso.com/'
paths:
/api/admin/v1/users/{emailAddress}/changePassword:
post:
summary: Changes a given user's password
tags:
- V1 User operations
- V1 Admin API
security:
- ApiKeyAuth: []
parameters:
- in: path
name: emailAddress
required: true
schema:
type: string
requestBody:
description: The new password for the target user
content:
application/json:
schema:
type: string
responses:
'204':
description: The password was successfully modified
'404':
$ref: '#/components/responses/UserNotFoundError'
'401':
$ref: '#/components/responses/UnauthorizedError'
components:
schemas:
ErrorBase:
type: object
required:
- errorCode
- message
properties:
errorCode:
type: string
description: Code name of the error
message:
type: string
description: Additional details about the error
securitySchemes:
ApiKeyAuth:
type: apiKey
in: header
name: X-API-KEY
responses:
UserNotFoundError:
description: User does not exist
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorBase'
UnauthorizedError:
description: API key is missing or invalid
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorBase' You can copy & paste this in https://editor.swagger.io/ to see how it would look like Key points:
Feel free to discuss any point from the spec in that issue. |
Sounds and looks good. Nothing stuck out as problematic to me. Small question: I'm a novice, so I'm curious if it's typical to have /user/{username} and a separate /users which would list all users for APIs? The plural /users/{email}/changePassword is grammatically odd to me. |
While I've seen the debate between plural and singular, I've never seen an API where you have both. Doing this, you somewhat break the clear hierarchy so I don't think it's common at all. I don't claim to know everything though, obviously! Maybe reading that as "From /users, change the password of {email}" might help grammatically :) When it comes to all plural vs all singular, I prefer to have plural because "/user" for listing looks weird to me. Resources that might be of interest: https://jsonapi.org/recommendations/#urls-resource-collections JsonAPI is a nicely specified way to design an API, so I like to take inspiration from there! |
I'm not sure the API-Key Auth is enough for users changing their password by them self. I think it is neccessary for this use case to authenticate by old password? |
@DerOetzi I have looked into that possibility, and that's even what I wanted to do in the first place. However, when trying to do a dummy implementation some weeks ago, I noticed it wasn't so simple: we wouldn't be able to use the shell functions from docker-mailserver, we'd need to read the While it is doable, it seems that users mostly wanted to have a layer above the API with a simple key, meaning -I assumed-, they'd manage authentication on their UI instead. With that in mind, I therefore prefixed this api with |
But how is a single user getting his personal API-Key? Let us asume their a two users [email protected] and [email protected]. How is secured that [email protected] can only change it's own password and not of [email protected]? |
There is no personal API key for Again, that doesn't prevent having |
Does this also address forgotten passwords? I mean sending a one-time hash link to a user-defined address (which will be checked for existence and if not existent, no reply - not even about non-existence! - will be issued) with a form to change password. Or something along that line. This helps enormously in practice as passwords are number one reason to contact the admin/support. |
Right now this doesn't. |
I got here from docker-mailserver/docker-mailserver#2092 This is certainly interesting - and I'd like to suggest that the API expand to at minimum all of the commands you can perform via |
I don't know all of them, but for there should be no issue with having them all available with the API |
I believe the password change capability would be Here is a full list of the commands supported by setup
|
Isn't doing these changes via |
Yes and no. The dockermailserver container runs as root. So that as a whole is the main security issue.
Of course - that is exactly the same restrictions you'd need to create a limited API as you describe.
It is unlikely due to the software stack dockermailserver is built on to avoid the container running as root. Possible, but probably more trouble than it is worth. |
Yes, but isn't the difference that |
You are correct that either you have configured docker such that users can run docker (which in itself is a security risk) or you have to be root to issue the docker command. I do think you've interpreted the Today - with dockermailserver if you modify the config files - the container notices and refreshes. You don't have to use |
Related: #3
Goal: Discuss and Create the v1 API spec to use with in the app
The text was updated successfully, but these errors were encountered: