@ -1,3 +1,36 @@
|
||||
|
||||
# API documentation
|
||||
trinity-1686a
commented 6 years ago
Review
Just "use apps" is maybe a bit unclear, maybe you should use the full path, and also tell how to use it (Do a post with such data, and such other is optional and....)
Just "use apps" is maybe a bit unclear, maybe you should use the full path, and also tell how to use it (Do a post with such data, and such other is optional and....)
```suggestion
token. To do so, use the `/api/v1/apps` API (accessible without a token) to create
```
Review
The request should be documented with Swagger (but it is broken for the moment 😢) The request should be documented with Swagger (but it is broken for the moment :cry:)
|
||||
|
||||
trinity-1686a
commented 6 years ago
Review
Just "use apps" is maybe a bit unclear, maybe you should use the full path, and also tell how to use it (Do a post with such data, and such other is optional and....)
Just "use apps" is maybe a bit unclear, maybe you should use the full path, and also tell how to use it (Do a post with such data, and such other is optional and....)
```suggestion
token. To do so, use the `/api/v1/apps` API (accessible without a token) to create
```
Review
The request should be documented with Swagger (but it is broken for the moment 😢) The request should be documented with Swagger (but it is broken for the moment :cry:)
|
||||
## Getting an API token
|
||||
trinity-1686a
commented 6 years ago
Review
Just "use apps" is maybe a bit unclear, maybe you should use the full path, and also tell how to use it (Do a post with such data, and such other is optional and....)
Just "use apps" is maybe a bit unclear, maybe you should use the full path, and also tell how to use it (Do a post with such data, and such other is optional and....)
```suggestion
token. To do so, use the `/api/v1/apps` API (accessible without a token) to create
```
Review
The request should be documented with Swagger (but it is broken for the moment 😢) The request should be documented with Swagger (but it is broken for the moment :cry:)
|
||||
|
||||
trinity-1686a
commented 6 years ago
Review
Just "use apps" is maybe a bit unclear, maybe you should use the full path, and also tell how to use it (Do a post with such data, and such other is optional and....)
Just "use apps" is maybe a bit unclear, maybe you should use the full path, and also tell how to use it (Do a post with such data, and such other is optional and....)
```suggestion
token. To do so, use the `/api/v1/apps` API (accessible without a token) to create
```
Review
The request should be documented with Swagger (but it is broken for the moment 😢) The request should be documented with Swagger (but it is broken for the moment :cry:)
|
||||
To get access to the API, you should register your app and obtain a
|
||||
trinity-1686a
commented 6 years ago
Review
Just "use apps" is maybe a bit unclear, maybe you should use the full path, and also tell how to use it (Do a post with such data, and such other is optional and....)
Just "use apps" is maybe a bit unclear, maybe you should use the full path, and also tell how to use it (Do a post with such data, and such other is optional and....)
```suggestion
token. To do so, use the `/api/v1/apps` API (accessible without a token) to create
```
Review
The request should be documented with Swagger (but it is broken for the moment 😢) The request should be documented with Swagger (but it is broken for the moment :cry:)
|
||||
token. To do so, use the `/api/v1/apps` API (accessible without a token) to create
|
||||
trinity-1686a
commented 6 years ago
Review
Just "use apps" is maybe a bit unclear, maybe you should use the full path, and also tell how to use it (Do a post with such data, and such other is optional and....)
Just "use apps" is maybe a bit unclear, maybe you should use the full path, and also tell how to use it (Do a post with such data, and such other is optional and....)
```suggestion
token. To do so, use the `/api/v1/apps` API (accessible without a token) to create
```
Review
The request should be documented with Swagger (but it is broken for the moment 😢) The request should be documented with Swagger (but it is broken for the moment :cry:)
|
||||
a new app. Store the result somewhere for future use.
|
||||
trinity-1686a
commented 6 years ago
Review
Just "use apps" is maybe a bit unclear, maybe you should use the full path, and also tell how to use it (Do a post with such data, and such other is optional and....)
Just "use apps" is maybe a bit unclear, maybe you should use the full path, and also tell how to use it (Do a post with such data, and such other is optional and....)
```suggestion
token. To do so, use the `/api/v1/apps` API (accessible without a token) to create
```
Review
The request should be documented with Swagger (but it is broken for the moment 😢) The request should be documented with Swagger (but it is broken for the moment :cry:)
|
||||
|
||||
trinity-1686a
commented 6 years ago
Review
Just "use apps" is maybe a bit unclear, maybe you should use the full path, and also tell how to use it (Do a post with such data, and such other is optional and....)
Just "use apps" is maybe a bit unclear, maybe you should use the full path, and also tell how to use it (Do a post with such data, and such other is optional and....)
```suggestion
token. To do so, use the `/api/v1/apps` API (accessible without a token) to create
```
Review
The request should be documented with Swagger (but it is broken for the moment 😢) The request should be documented with Swagger (but it is broken for the moment :cry:)
|
||||
Then send a request to `/api/v1/oauth2`, with the following GET parameters:
|
||||
trinity-1686a
commented 6 years ago
Review
Just "use apps" is maybe a bit unclear, maybe you should use the full path, and also tell how to use it (Do a post with such data, and such other is optional and....)
Just "use apps" is maybe a bit unclear, maybe you should use the full path, and also tell how to use it (Do a post with such data, and such other is optional and....)
```suggestion
token. To do so, use the `/api/v1/apps` API (accessible without a token) to create
```
Review
The request should be documented with Swagger (but it is broken for the moment 😢) The request should be documented with Swagger (but it is broken for the moment :cry:)
|
||||
|
||||
trinity-1686a
commented 6 years ago
Review
Just "use apps" is maybe a bit unclear, maybe you should use the full path, and also tell how to use it (Do a post with such data, and such other is optional and....)
Just "use apps" is maybe a bit unclear, maybe you should use the full path, and also tell how to use it (Do a post with such data, and such other is optional and....)
```suggestion
token. To do so, use the `/api/v1/apps` API (accessible without a token) to create
```
Review
The request should be documented with Swagger (but it is broken for the moment 😢) The request should be documented with Swagger (but it is broken for the moment :cry:)
|
||||
- `client_id`, your client ID.
|
||||
trinity-1686a
commented 6 years ago
Review
Just "use apps" is maybe a bit unclear, maybe you should use the full path, and also tell how to use it (Do a post with such data, and such other is optional and....)
Just "use apps" is maybe a bit unclear, maybe you should use the full path, and also tell how to use it (Do a post with such data, and such other is optional and....)
```suggestion
token. To do so, use the `/api/v1/apps` API (accessible without a token) to create
```
Review
The request should be documented with Swagger (but it is broken for the moment 😢) The request should be documented with Swagger (but it is broken for the moment :cry:)
|
||||
- `client_secret`, your client secret.
|
||||
trinity-1686a
commented 6 years ago
Review
Just "use apps" is maybe a bit unclear, maybe you should use the full path, and also tell how to use it (Do a post with such data, and such other is optional and....)
Just "use apps" is maybe a bit unclear, maybe you should use the full path, and also tell how to use it (Do a post with such data, and such other is optional and....)
```suggestion
token. To do so, use the `/api/v1/apps` API (accessible without a token) to create
```
Review
The request should be documented with Swagger (but it is broken for the moment 😢) The request should be documented with Swagger (but it is broken for the moment :cry:)
|
||||
- `scopes`, the scopes you want to access. They are separated by `+`, and can either
|
||||
trinity-1686a
commented 6 years ago
Review
Just "use apps" is maybe a bit unclear, maybe you should use the full path, and also tell how to use it (Do a post with such data, and such other is optional and....)
Just "use apps" is maybe a bit unclear, maybe you should use the full path, and also tell how to use it (Do a post with such data, and such other is optional and....)
```suggestion
token. To do so, use the `/api/v1/apps` API (accessible without a token) to create
```
Review
The request should be documented with Swagger (but it is broken for the moment 😢) The request should be documented with Swagger (but it is broken for the moment :cry:)
|
||||
be `read` (global read), `write` (global write), `read:SCOPE` (read only in `SCOPE`),
|
||||
trinity-1686a
commented 6 years ago
Review
Just "use apps" is maybe a bit unclear, maybe you should use the full path, and also tell how to use it (Do a post with such data, and such other is optional and....)
Just "use apps" is maybe a bit unclear, maybe you should use the full path, and also tell how to use it (Do a post with such data, and such other is optional and....)
```suggestion
token. To do so, use the `/api/v1/apps` API (accessible without a token) to create
```
Review
The request should be documented with Swagger (but it is broken for the moment 😢) The request should be documented with Swagger (but it is broken for the moment :cry:)
|
||||
or `write:SCOPE` (write only in `SCOPE`).
|
||||
trinity-1686a
commented 6 years ago
Review
Just "use apps" is maybe a bit unclear, maybe you should use the full path, and also tell how to use it (Do a post with such data, and such other is optional and....)
Just "use apps" is maybe a bit unclear, maybe you should use the full path, and also tell how to use it (Do a post with such data, and such other is optional and....)
```suggestion
token. To do so, use the `/api/v1/apps` API (accessible without a token) to create
```
Review
The request should be documented with Swagger (but it is broken for the moment 😢) The request should be documented with Swagger (but it is broken for the moment :cry:)
|
||||
- `username` the username (not the email, display name nor the fully qualified name) of the
|
||||
trinity-1686a
commented 6 years ago
Review
Just "use apps" is maybe a bit unclear, maybe you should use the full path, and also tell how to use it (Do a post with such data, and such other is optional and....)
Just "use apps" is maybe a bit unclear, maybe you should use the full path, and also tell how to use it (Do a post with such data, and such other is optional and....)
```suggestion
token. To do so, use the `/api/v1/apps` API (accessible without a token) to create
```
Review
The request should be documented with Swagger (but it is broken for the moment 😢) The request should be documented with Swagger (but it is broken for the moment :cry:)
|
||||
user using your app.
|
||||
trinity-1686a
commented 6 years ago
Review
Just "use apps" is maybe a bit unclear, maybe you should use the full path, and also tell how to use it (Do a post with such data, and such other is optional and....)
Just "use apps" is maybe a bit unclear, maybe you should use the full path, and also tell how to use it (Do a post with such data, and such other is optional and....)
```suggestion
token. To do so, use the `/api/v1/apps` API (accessible without a token) to create
```
Review
The request should be documented with Swagger (but it is broken for the moment 😢) The request should be documented with Swagger (but it is broken for the moment :cry:)
|
||||
- `password`, the password of the user.
|
||||
trinity-1686a
commented 6 years ago
Review
Just "use apps" is maybe a bit unclear, maybe you should use the full path, and also tell how to use it (Do a post with such data, and such other is optional and....)
Just "use apps" is maybe a bit unclear, maybe you should use the full path, and also tell how to use it (Do a post with such data, and such other is optional and....)
```suggestion
token. To do so, use the `/api/v1/apps` API (accessible without a token) to create
```
Review
The request should be documented with Swagger (but it is broken for the moment 😢) The request should be documented with Swagger (but it is broken for the moment :cry:)
|
||||
|
||||
trinity-1686a
commented 6 years ago
Review
Just "use apps" is maybe a bit unclear, maybe you should use the full path, and also tell how to use it (Do a post with such data, and such other is optional and....)
Just "use apps" is maybe a bit unclear, maybe you should use the full path, and also tell how to use it (Do a post with such data, and such other is optional and....)
```suggestion
token. To do so, use the `/api/v1/apps` API (accessible without a token) to create
```
Review
The request should be documented with Swagger (but it is broken for the moment 😢) The request should be documented with Swagger (but it is broken for the moment :cry:)
|
||||
Plume will respond with something similar to:
|
||||
trinity-1686a
commented 6 years ago
Review
Just "use apps" is maybe a bit unclear, maybe you should use the full path, and also tell how to use it (Do a post with such data, and such other is optional and....)
Just "use apps" is maybe a bit unclear, maybe you should use the full path, and also tell how to use it (Do a post with such data, and such other is optional and....)
```suggestion
token. To do so, use the `/api/v1/apps` API (accessible without a token) to create
```
Review
The request should be documented with Swagger (but it is broken for the moment 😢) The request should be documented with Swagger (but it is broken for the moment :cry:)
|
||||
|
||||
trinity-1686a
commented 6 years ago
Review
Just "use apps" is maybe a bit unclear, maybe you should use the full path, and also tell how to use it (Do a post with such data, and such other is optional and....)
Just "use apps" is maybe a bit unclear, maybe you should use the full path, and also tell how to use it (Do a post with such data, and such other is optional and....)
```suggestion
token. To do so, use the `/api/v1/apps` API (accessible without a token) to create
```
Review
The request should be documented with Swagger (but it is broken for the moment 😢) The request should be documented with Swagger (but it is broken for the moment :cry:)
|
||||
```json
|
||||
trinity-1686a
commented 6 years ago
Review
Just "use apps" is maybe a bit unclear, maybe you should use the full path, and also tell how to use it (Do a post with such data, and such other is optional and....)
Just "use apps" is maybe a bit unclear, maybe you should use the full path, and also tell how to use it (Do a post with such data, and such other is optional and....)
```suggestion
token. To do so, use the `/api/v1/apps` API (accessible without a token) to create
```
Review
The request should be documented with Swagger (but it is broken for the moment 😢) The request should be documented with Swagger (but it is broken for the moment :cry:)
|
||||
{
|
||||
trinity-1686a
commented 6 years ago
Review
Just "use apps" is maybe a bit unclear, maybe you should use the full path, and also tell how to use it (Do a post with such data, and such other is optional and....)
Just "use apps" is maybe a bit unclear, maybe you should use the full path, and also tell how to use it (Do a post with such data, and such other is optional and....)
```suggestion
token. To do so, use the `/api/v1/apps` API (accessible without a token) to create
```
Review
The request should be documented with Swagger (but it is broken for the moment 😢) The request should be documented with Swagger (but it is broken for the moment :cry:)
|
||||
"token": "<YOUR TOKEN HERE>"
|
||||
trinity-1686a
commented 6 years ago
Review
Just "use apps" is maybe a bit unclear, maybe you should use the full path, and also tell how to use it (Do a post with such data, and such other is optional and....)
Just "use apps" is maybe a bit unclear, maybe you should use the full path, and also tell how to use it (Do a post with such data, and such other is optional and....)
```suggestion
token. To do so, use the `/api/v1/apps` API (accessible without a token) to create
```
Review
The request should be documented with Swagger (but it is broken for the moment 😢) The request should be documented with Swagger (but it is broken for the moment :cry:)
|
||||
}
|
||||
trinity-1686a
commented 6 years ago
Review
Just "use apps" is maybe a bit unclear, maybe you should use the full path, and also tell how to use it (Do a post with such data, and such other is optional and....)
Just "use apps" is maybe a bit unclear, maybe you should use the full path, and also tell how to use it (Do a post with such data, and such other is optional and....)
```suggestion
token. To do so, use the `/api/v1/apps` API (accessible without a token) to create
```
Review
The request should be documented with Swagger (but it is broken for the moment 😢) The request should be documented with Swagger (but it is broken for the moment :cry:)
|
||||
```
|
||||
trinity-1686a
commented 6 years ago
Review
Just "use apps" is maybe a bit unclear, maybe you should use the full path, and also tell how to use it (Do a post with such data, and such other is optional and....)
Just "use apps" is maybe a bit unclear, maybe you should use the full path, and also tell how to use it (Do a post with such data, and such other is optional and....)
```suggestion
token. To do so, use the `/api/v1/apps` API (accessible without a token) to create
```
Review
The request should be documented with Swagger (but it is broken for the moment 😢) The request should be documented with Swagger (but it is broken for the moment :cry:)
|
||||
|
||||
trinity-1686a
commented 6 years ago
Review
Just "use apps" is maybe a bit unclear, maybe you should use the full path, and also tell how to use it (Do a post with such data, and such other is optional and....)
Just "use apps" is maybe a bit unclear, maybe you should use the full path, and also tell how to use it (Do a post with such data, and such other is optional and....)
```suggestion
token. To do so, use the `/api/v1/apps` API (accessible without a token) to create
```
Review
The request should be documented with Swagger (but it is broken for the moment 😢) The request should be documented with Swagger (but it is broken for the moment :cry:)
|
||||
To authenticate your requests you should put this token in the `Authorization` header:
|
||||
trinity-1686a
commented 6 years ago
Review
Just "use apps" is maybe a bit unclear, maybe you should use the full path, and also tell how to use it (Do a post with such data, and such other is optional and....)
Just "use apps" is maybe a bit unclear, maybe you should use the full path, and also tell how to use it (Do a post with such data, and such other is optional and....)
```suggestion
token. To do so, use the `/api/v1/apps` API (accessible without a token) to create
```
Review
The request should be documented with Swagger (but it is broken for the moment 😢) The request should be documented with Swagger (but it is broken for the moment :cry:)
|
||||
|
||||
trinity-1686a
commented 6 years ago
Review
Just "use apps" is maybe a bit unclear, maybe you should use the full path, and also tell how to use it (Do a post with such data, and such other is optional and....)
Just "use apps" is maybe a bit unclear, maybe you should use the full path, and also tell how to use it (Do a post with such data, and such other is optional and....)
```suggestion
token. To do so, use the `/api/v1/apps` API (accessible without a token) to create
```
Review
The request should be documented with Swagger (but it is broken for the moment 😢) The request should be documented with Swagger (but it is broken for the moment :cry:)
|
||||
```
|
||||
trinity-1686a
commented 6 years ago
Review
Just "use apps" is maybe a bit unclear, maybe you should use the full path, and also tell how to use it (Do a post with such data, and such other is optional and....)
Just "use apps" is maybe a bit unclear, maybe you should use the full path, and also tell how to use it (Do a post with such data, and such other is optional and....)
```suggestion
token. To do so, use the `/api/v1/apps` API (accessible without a token) to create
```
Review
The request should be documented with Swagger (but it is broken for the moment 😢) The request should be documented with Swagger (but it is broken for the moment :cry:)
|
||||
Authorization: Bearer <YOUR TOKEN HERE>
|
||||
trinity-1686a
commented 6 years ago
Review
Just "use apps" is maybe a bit unclear, maybe you should use the full path, and also tell how to use it (Do a post with such data, and such other is optional and....)
Just "use apps" is maybe a bit unclear, maybe you should use the full path, and also tell how to use it (Do a post with such data, and such other is optional and....)
```suggestion
token. To do so, use the `/api/v1/apps` API (accessible without a token) to create
```
Review
The request should be documented with Swagger (but it is broken for the moment 😢) The request should be documented with Swagger (but it is broken for the moment :cry:)
|
||||
```
|
||||
trinity-1686a
commented 6 years ago
Review
Just "use apps" is maybe a bit unclear, maybe you should use the full path, and also tell how to use it (Do a post with such data, and such other is optional and....)
Just "use apps" is maybe a bit unclear, maybe you should use the full path, and also tell how to use it (Do a post with such data, and such other is optional and....)
```suggestion
token. To do so, use the `/api/v1/apps` API (accessible without a token) to create
```
Review
The request should be documented with Swagger (but it is broken for the moment 😢) The request should be documented with Swagger (but it is broken for the moment :cry:)
|
||||
|
||||
trinity-1686a
commented 6 years ago
Review
Just "use apps" is maybe a bit unclear, maybe you should use the full path, and also tell how to use it (Do a post with such data, and such other is optional and....)
Just "use apps" is maybe a bit unclear, maybe you should use the full path, and also tell how to use it (Do a post with such data, and such other is optional and....)
```suggestion
token. To do so, use the `/api/v1/apps` API (accessible without a token) to create
```
Review
The request should be documented with Swagger (but it is broken for the moment 😢) The request should be documented with Swagger (but it is broken for the moment :cry:)
|
||||
<script src="//unpkg.com/swagger-ui-dist@3/swagger-ui-bundle.js"></script>
|
||||
|
||||
<div id="api"></div>
|
||||
|
||||
trinity-1686a
commented 6 years ago
Review
Just "use apps" is maybe a bit unclear, maybe you should use the full path, and also tell how to use it (Do a post with such data, and such other is optional and....)
Just "use apps" is maybe a bit unclear, maybe you should use the full path, and also tell how to use it (Do a post with such data, and such other is optional and....)
```suggestion
token. To do so, use the `/api/v1/apps` API (accessible without a token) to create
```
trinity-1686a
commented 6 years ago
Review
Just "use apps" is maybe a bit unclear, maybe you should use the full path, and also tell how to use it (Do a post with such data, and such other is optional and....)
Just "use apps" is maybe a bit unclear, maybe you should use the full path, and also tell how to use it (Do a post with such data, and such other is optional and....)
```suggestion
token. To do so, use the `/api/v1/apps` API (accessible without a token) to create
```
Review
The request should be documented with Swagger (but it is broken for the moment 😢) The request should be documented with Swagger (but it is broken for the moment :cry:)
Review
The request should be documented with Swagger (but it is broken for the moment 😢) The request should be documented with Swagger (but it is broken for the moment :cry:)
|
@ -0,0 +1,2 @@
|
||||
-- This file should undo anything in `up.sql`
|
||||
DROP TABLE apps;
|
@ -0,0 +1,10 @@
|
||||
-- Your SQL goes here
|
||||
CREATE TABLE apps (
|
||||
id SERIAL PRIMARY KEY,
|
||||
name TEXT NOT NULL DEFAULT '',
|
||||
client_id TEXT NOT NULL,
|
||||
client_secret TEXT NOT NULL,
|
||||
redirect_uri TEXT,
|
||||
website TEXT,
|
||||
creation_date TIMESTAMP NOT NULL DEFAULT now()
|
||||
);
|
@ -0,0 +1,2 @@
|
||||
-- This file should undo anything in `up.sql`
|
||||
DROP TABLE api_tokens;
|
@ -0,0 +1,9 @@
|
||||
-- Your SQL goes here
|
||||
CREATE TABLE api_tokens (
|
||||
id SERIAL PRIMARY KEY,
|
||||
creation_date TIMESTAMP NOT NULL DEFAULT now(),
|
||||
value TEXT NOT NULL,
|
||||
scopes TEXT NOT NULL,
|
||||
app_id INTEGER NOT NULL REFERENCES apps(id) ON DELETE CASCADE,
|
||||
user_id INTEGER NOT NULL REFERENCES users(id) ON DELETE CASCADE
|
||||
)
|
@ -0,0 +1,2 @@
|
||||
-- This file should undo anything in `up.sql`
|
||||
DROP TABLE apps;
|
@ -0,0 +1,10 @@
|
||||
-- Your SQL goes here
|
||||
CREATE TABLE apps (
|
||||
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
name TEXT NOT NULL DEFAULT '',
|
||||
client_id TEXT NOT NULL,
|
||||
client_secret TEXT NOT NULL,
|
||||
redirect_uri TEXT,
|
||||
website TEXT,
|
||||
creation_date DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
@ -0,0 +1,2 @@
|
||||
-- This file should undo anything in `up.sql`
|
||||
DROP TABLE api_tokens;
|
@ -0,0 +1,9 @@
|
||||
-- Your SQL goes here
|
||||
CREATE TABLE api_tokens (
|
||||
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
creation_date DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
value TEXT NOT NULL,
|
||||
scopes TEXT NOT NULL,
|
||||
app_id INTEGER NOT NULL REFERENCES apps(id) ON DELETE CASCADE,
|
||||
user_id INTEGER NOT NULL REFERENCES users(id) ON DELETE CASCADE
|
||||
)
|
@ -0,0 +1,13 @@
|
||||
trinity-1686a
commented 6 years ago
Review
name seems to be required by name seems to be required by https://github.com/Plume-org/Plume/blob/36297101f261f473fd03d86a22f46379d125e002/plume-models/src/apps.rs#L47
So I think it should not be an Option
trinity-1686a
commented 6 years ago
Review
name seems to be required by name seems to be required by https://github.com/Plume-org/Plume/blob/36297101f261f473fd03d86a22f46379d125e002/plume-models/src/apps.rs#L47
So I think it should not be an Option
|
||||
use canapi::Endpoint;
|
||||
trinity-1686a
commented 6 years ago
Review
name seems to be required by name seems to be required by https://github.com/Plume-org/Plume/blob/36297101f261f473fd03d86a22f46379d125e002/plume-models/src/apps.rs#L47
So I think it should not be an Option
|
||||
|
||||
trinity-1686a
commented 6 years ago
Review
name seems to be required by name seems to be required by https://github.com/Plume-org/Plume/blob/36297101f261f473fd03d86a22f46379d125e002/plume-models/src/apps.rs#L47
So I think it should not be an Option
|
||||
#[derive(Clone, Default, Serialize, Deserialize)]
|
||||
trinity-1686a
commented 6 years ago
Review
name seems to be required by name seems to be required by https://github.com/Plume-org/Plume/blob/36297101f261f473fd03d86a22f46379d125e002/plume-models/src/apps.rs#L47
So I think it should not be an Option
|
||||
pub struct AppEndpoint {
|
||||
trinity-1686a
commented 6 years ago
Review
This feel strange to be at the same time data received from Post (with id, client_id and client_secret ignored, as they must be generated by the server) and data returned by the api (with those same field used, and most likely different than what was originally posted if they where). It should either be 2 different struct or at least a struct with FromForm custom-implemented to ensure that This feel strange to be at the same time data received from Post (with id, client_id and client_secret ignored, as they must be generated by the server) and data returned by the api (with those same field used, and most likely different than what was originally posted if they where). It should either be 2 different struct or at least a struct with FromForm custom-implemented to ensure that
trinity-1686a
commented 6 years ago
Review
name seems to be required by name seems to be required by https://github.com/Plume-org/Plume/blob/36297101f261f473fd03d86a22f46379d125e002/plume-models/src/apps.rs#L47
So I think it should not be an Option
Review
We can't use But I think I may add a Or maybe canapi is just a bad idea and we should drop it... 🤔 We can't use `FromForm` in plume-api, or we would loose all the benefits of canapi.
But I think I may add a `Server`/`Client`/`Both` wrapper type to specify when a field is required and make it easier to check if something has been forgotten.
Or maybe canapi is just a bad idea and we should drop it... :thinking:
|
||||
pub id: Option<i32>,
|
||||
trinity-1686a
commented 6 years ago
Review
name seems to be required by name seems to be required by https://github.com/Plume-org/Plume/blob/36297101f261f473fd03d86a22f46379d125e002/plume-models/src/apps.rs#L47
So I think it should not be an Option
|
||||
pub name: String,
|
||||
trinity-1686a
commented 6 years ago
Review
name seems to be required by name seems to be required by https://github.com/Plume-org/Plume/blob/36297101f261f473fd03d86a22f46379d125e002/plume-models/src/apps.rs#L47
So I think it should not be an Option
|
||||
pub website: Option<String>,
|
||||
trinity-1686a
commented 6 years ago
Review
name seems to be required by name seems to be required by https://github.com/Plume-org/Plume/blob/36297101f261f473fd03d86a22f46379d125e002/plume-models/src/apps.rs#L47
So I think it should not be an Option
|
||||
pub redirect_uri: Option<String>,
|
||||
trinity-1686a
commented 6 years ago
Review
name seems to be required by name seems to be required by https://github.com/Plume-org/Plume/blob/36297101f261f473fd03d86a22f46379d125e002/plume-models/src/apps.rs#L47
So I think it should not be an Option
|
||||
pub client_id: Option<String>,
|
||||
trinity-1686a
commented 6 years ago
Review
name seems to be required by name seems to be required by https://github.com/Plume-org/Plume/blob/36297101f261f473fd03d86a22f46379d125e002/plume-models/src/apps.rs#L47
So I think it should not be an Option
|
||||
pub client_secret: Option<String>,
|
||||
trinity-1686a
commented 6 years ago
Review
name seems to be required by name seems to be required by https://github.com/Plume-org/Plume/blob/36297101f261f473fd03d86a22f46379d125e002/plume-models/src/apps.rs#L47
So I think it should not be an Option
|
||||
}
|
||||
trinity-1686a
commented 6 years ago
Review
name seems to be required by name seems to be required by https://github.com/Plume-org/Plume/blob/36297101f261f473fd03d86a22f46379d125e002/plume-models/src/apps.rs#L47
So I think it should not be an Option
|
||||
|
||||
trinity-1686a
commented 6 years ago
Review
name seems to be required by name seems to be required by https://github.com/Plume-org/Plume/blob/36297101f261f473fd03d86a22f46379d125e002/plume-models/src/apps.rs#L47
So I think it should not be an Option
|
||||
api!("/api/v1/apps" => AppEndpoint);
|
||||
trinity-1686a
commented 6 years ago
Review
name seems to be required by name seems to be required by https://github.com/Plume-org/Plume/blob/36297101f261f473fd03d86a22f46379d125e002/plume-models/src/apps.rs#L47
So I think it should not be an Option
|
@ -0,0 +1,88 @@
|
||||
use chrono::NaiveDateTime;
|
||||
use diesel::{self, ExpressionMethods, QueryDsl, RunQueryDsl};
|
||||
use rocket::{
|
||||
Outcome,
|
||||
http::Status,
|
||||
request::{self, FromRequest, Request}
|
||||
};
|
||||
|
||||
use db_conn::DbConn;
|
||||
use schema::api_tokens;
|
||||
|
||||
#[derive(Clone, Queryable)]
|
||||
pub struct ApiToken {
|
||||
pub id: i32,
|
||||
pub creation_date: NaiveDateTime,
|
||||
pub value: String,
|
||||
|
||||
/// Scopes, separated by +
|
||||
/// Global scopes are read and write
|
||||
/// and both can be limited to an endpoint by affixing them with :ENDPOINT
|
||||
///
|
||||
/// Examples :
|
||||
///
|
||||
/// read
|
||||
/// read+write
|
||||
/// read:posts
|
||||
/// read:posts+write:posts
|
||||
pub scopes: String,
|
||||
pub app_id: i32,
|
||||
pub user_id: i32,
|
||||
}
|
||||
|
||||
#[derive(Insertable)]
|
||||
#[table_name = "api_tokens"]
|
||||
pub struct NewApiToken {
|
||||
pub value: String,
|
||||
pub scopes: String,
|
||||
pub app_id: i32,
|
||||
pub user_id: i32,
|
||||
}
|
||||
|
||||
impl ApiToken {
|
||||
get!(api_tokens);
|
||||
insert!(api_tokens, NewApiToken);
|
||||
find_by!(api_tokens, find_by_value, value as String);
|
||||
|
||||
pub fn can(&self, what: &'static str, scope: &'static str) -> bool {
|
||||
let full_scope = what.to_owned() + ":" + scope;
|
||||
for s in self.scopes.split('+') {
|
||||
if s == what || s == full_scope {
|
||||
return true
|
||||
}
|
||||
}
|
||||
false
|
||||
}
|
||||
|
||||
pub fn can_read(&self, scope: &'static str) -> bool {
|
||||
self.can("read", scope)
|
||||
}
|
||||
trinity-1686a
commented 6 years ago
Review
This is confusing because This is confusing because `can` take a `what` set to "read" and a `scope` set to `what`. `what` should probably renamed `scope`, or something else should be renamed in `can`
|
||||
|
||||
pub fn can_write(&self, scope: &'static str) -> bool {
|
||||
self.can("write", scope)
|
||||
}
|
||||
trinity-1686a
commented 6 years ago
Review
Same goes here (about variable naming) Same goes here (about variable naming)
|
||||
}
|
||||
|
||||
impl<'a, 'r> FromRequest<'a, 'r> for ApiToken {
|
||||
type Error = ();
|
||||
|
||||
fn from_request(request: &'a Request<'r>) -> request::Outcome<ApiToken, ()> {
|
||||
let headers: Vec<_> = request.headers().get("Authorization").collect();
|
||||
if headers.len() != 1 {
|
||||
return Outcome::Failure((Status::BadRequest, ()));
|
||||
}
|
||||
|
||||
let mut parsed_header = headers[0].split(' ');
|
||||
let auth_type = parsed_header.next().expect("Expect a token type");
|
||||
let val = parsed_header.next().expect("Expect a token value");
|
||||
|
||||
if auth_type == "Bearer" {
|
||||
let conn = request.guard::<DbConn>().expect("Couldn't connect to DB");
|
||||
if let Some(token) = ApiToken::find_by_value(&*conn, val.to_string()) {
|
||||
return Outcome::Success(token);
|
||||
}
|
||||
}
|
||||
|
||||
return Outcome::Forward(());
|
||||
}
|
||||
}
|
@ -0,0 +1,77 @@
|
||||
use canapi::{Error, Provider};
|
||||
Review
should i be watching the canapi repo as well? should i be watching the canapi repo as well?
Review
As you want As you want
|
||||
use chrono::NaiveDateTime;
|
||||
use diesel::{self, RunQueryDsl, QueryDsl, ExpressionMethods};
|
||||
|
||||
use plume_api::apps::AppEndpoint;
|
||||
use plume_common::utils::random_hex;
|
||||
use Connection;
|
||||
use schema::apps;
|
||||
|
||||
#[derive(Clone, Queryable)]
|
||||
pub struct App {
|
||||
pub id: i32,
|
||||
pub name: String,
|
||||
pub client_id: String,
|
||||
pub client_secret: String,
|
||||
pub redirect_uri: Option<String>,
|
||||
pub website: Option<String>,
|
||||
pub creation_date: NaiveDateTime,
|
||||
}
|
||||
|
||||
#[derive(Insertable)]
|
||||
#[table_name= "apps"]
|
||||
pub struct NewApp {
|
||||
pub name: String,
|
||||
pub client_id: String,
|
||||
pub client_secret: String,
|
||||
pub redirect_uri: Option<String>,
|
||||
pub website: Option<String>,
|
||||
}
|
||||
|
||||
impl Provider<Connection> for App {
|
||||
type Data = AppEndpoint;
|
||||
|
||||
fn get(_conn: &Connection, _id: i32) -> Result<AppEndpoint, Error> {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
fn list(_conn: &Connection, _query: AppEndpoint) -> Vec<AppEndpoint> {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
fn create(conn: &Connection, data: AppEndpoint) -> Result<AppEndpoint, Error> {
|
||||
let client_id = random_hex();
|
||||
|
||||
let client_secret = random_hex();
|
||||
let app = App::insert(conn, NewApp {
|
||||
name: data.name,
|
||||
client_id: client_id,
|
||||
client_secret: client_secret,
|
||||
redirect_uri: data.redirect_uri,
|
||||
website: data.website,
|
||||
});
|
||||
|
||||
Ok(AppEndpoint {
|
||||
id: Some(app.id),
|
||||
name: app.name,
|
||||
client_id: Some(app.client_id),
|
||||
client_secret: Some(app.client_secret),
|
||||
redirect_uri: app.redirect_uri,
|
||||
website: app.website,
|
||||
})
|
||||
}
|
||||
|
||||
fn update(_conn: &Connection, _id: i32, _new_data: AppEndpoint) -> Result<AppEndpoint, Error> {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
fn delete(_conn: &Connection, _id: i32) {
|
||||
unimplemented!()
|
||||
}
|
||||
}
|
||||
|
||||
impl App {
|
||||
get!(apps);
|
||||
insert!(apps, NewApp);
|
||||
find_by!(apps, find_by_client_id, client_id as String);
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
use canapi::Provider;
|
||||
use rocket_contrib::Json;
|
||||
use serde_json;
|
||||
|
||||
use plume_api::apps::AppEndpoint;
|
||||
use plume_models::{
|
||||
Connection,
|
||||
db_conn::DbConn,
|
||||
apps::App,
|
||||
};
|
||||
|
||||
#[post("/apps", data = "<data>")]
|
||||
fn create(conn: DbConn, data: Json<AppEndpoint>) -> Json<serde_json::Value> {
|
||||
let post = <App as Provider<Connection>>::create(&*conn, (*data).clone()).ok();
|
||||
Json(json!(post))
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
Review
I don't know if there is a better way to define this type. If I don't use I don't know if there is a better way to define this type. If I don't use `A` and `S` in its definition, it refuses to build.
Review
I don't know if there is a better way to define this type. If I don't use I don't know if there is a better way to define this type. If I don't use `A` and `S` in its definition, it refuses to build.
Review
As you can see, these two Options will actually always be None, never Some(A) or Some(S). As you can see, these two Options will actually always be None, never Some(A) or Some(S).
Review
As you can see, these two Options will actually always be None, never Some(A) or Some(S). As you can see, these two Options will actually always be None, never Some(A) or Some(S).
trinity-1686a
commented 6 years ago
Review
You can use PhantomData https://doc.rust-lang.org/beta/std/marker/struct.PhantomData.html, it'll probably do the trick You can use PhantomData https://doc.rust-lang.org/beta/std/marker/struct.PhantomData.html, it'll probably do the trick
Simple example : https://gist.github.com/rust-play/9e51f5b8bb3a915a99d958f5ea982f1a
trinity-1686a
commented 6 years ago
Review
You can use PhantomData https://doc.rust-lang.org/beta/std/marker/struct.PhantomData.html, it'll probably do the trick You can use PhantomData https://doc.rust-lang.org/beta/std/marker/struct.PhantomData.html, it'll probably do the trick
Simple example : https://gist.github.com/rust-play/9e51f5b8bb3a915a99d958f5ea982f1a
|
||||
use rocket::{
|
||||
Review
I don't know if there is a better way to define this type. If I don't use I don't know if there is a better way to define this type. If I don't use `A` and `S` in its definition, it refuses to build.
Review
As you can see, these two Options will actually always be None, never Some(A) or Some(S). As you can see, these two Options will actually always be None, never Some(A) or Some(S).
trinity-1686a
commented 6 years ago
Review
You can use PhantomData https://doc.rust-lang.org/beta/std/marker/struct.PhantomData.html, it'll probably do the trick You can use PhantomData https://doc.rust-lang.org/beta/std/marker/struct.PhantomData.html, it'll probably do the trick
Simple example : https://gist.github.com/rust-play/9e51f5b8bb3a915a99d958f5ea982f1a
|
||||
Outcome,
|
||||
Review
I don't know if there is a better way to define this type. If I don't use I don't know if there is a better way to define this type. If I don't use `A` and `S` in its definition, it refuses to build.
Review
As you can see, these two Options will actually always be None, never Some(A) or Some(S). As you can see, these two Options will actually always be None, never Some(A) or Some(S).
trinity-1686a
commented 6 years ago
Review
You can use PhantomData https://doc.rust-lang.org/beta/std/marker/struct.PhantomData.html, it'll probably do the trick You can use PhantomData https://doc.rust-lang.org/beta/std/marker/struct.PhantomData.html, it'll probably do the trick
Simple example : https://gist.github.com/rust-play/9e51f5b8bb3a915a99d958f5ea982f1a
|
||||
http::Status,
|
||||
Review
I don't know if there is a better way to define this type. If I don't use I don't know if there is a better way to define this type. If I don't use `A` and `S` in its definition, it refuses to build.
Review
As you can see, these two Options will actually always be None, never Some(A) or Some(S). As you can see, these two Options will actually always be None, never Some(A) or Some(S).
trinity-1686a
commented 6 years ago
Review
You can use PhantomData https://doc.rust-lang.org/beta/std/marker/struct.PhantomData.html, it'll probably do the trick You can use PhantomData https://doc.rust-lang.org/beta/std/marker/struct.PhantomData.html, it'll probably do the trick
Simple example : https://gist.github.com/rust-play/9e51f5b8bb3a915a99d958f5ea982f1a
|
||||
request::{self, FromRequest, Request}
|
||||
Review
I don't know if there is a better way to define this type. If I don't use I don't know if there is a better way to define this type. If I don't use `A` and `S` in its definition, it refuses to build.
Review
As you can see, these two Options will actually always be None, never Some(A) or Some(S). As you can see, these two Options will actually always be None, never Some(A) or Some(S).
trinity-1686a
commented 6 years ago
Review
You can use PhantomData https://doc.rust-lang.org/beta/std/marker/struct.PhantomData.html, it'll probably do the trick You can use PhantomData https://doc.rust-lang.org/beta/std/marker/struct.PhantomData.html, it'll probably do the trick
Simple example : https://gist.github.com/rust-play/9e51f5b8bb3a915a99d958f5ea982f1a
|
||||
};
|
||||
Review
I don't know if there is a better way to define this type. If I don't use I don't know if there is a better way to define this type. If I don't use `A` and `S` in its definition, it refuses to build.
Review
As you can see, these two Options will actually always be None, never Some(A) or Some(S). As you can see, these two Options will actually always be None, never Some(A) or Some(S).
trinity-1686a
commented 6 years ago
Review
You can use PhantomData https://doc.rust-lang.org/beta/std/marker/struct.PhantomData.html, it'll probably do the trick You can use PhantomData https://doc.rust-lang.org/beta/std/marker/struct.PhantomData.html, it'll probably do the trick
Simple example : https://gist.github.com/rust-play/9e51f5b8bb3a915a99d958f5ea982f1a
|
||||
use std::marker::PhantomData;
|
||||
Review
I don't know if there is a better way to define this type. If I don't use I don't know if there is a better way to define this type. If I don't use `A` and `S` in its definition, it refuses to build.
Review
As you can see, these two Options will actually always be None, never Some(A) or Some(S). As you can see, these two Options will actually always be None, never Some(A) or Some(S).
trinity-1686a
commented 6 years ago
Review
You can use PhantomData https://doc.rust-lang.org/beta/std/marker/struct.PhantomData.html, it'll probably do the trick You can use PhantomData https://doc.rust-lang.org/beta/std/marker/struct.PhantomData.html, it'll probably do the trick
Simple example : https://gist.github.com/rust-play/9e51f5b8bb3a915a99d958f5ea982f1a
|
||||
use plume_models::{self, api_tokens::ApiToken};
|
||||
Review
I don't know if there is a better way to define this type. If I don't use I don't know if there is a better way to define this type. If I don't use `A` and `S` in its definition, it refuses to build.
Review
As you can see, these two Options will actually always be None, never Some(A) or Some(S). As you can see, these two Options will actually always be None, never Some(A) or Some(S).
trinity-1686a
commented 6 years ago
Review
You can use PhantomData https://doc.rust-lang.org/beta/std/marker/struct.PhantomData.html, it'll probably do the trick You can use PhantomData https://doc.rust-lang.org/beta/std/marker/struct.PhantomData.html, it'll probably do the trick
Simple example : https://gist.github.com/rust-play/9e51f5b8bb3a915a99d958f5ea982f1a
|
||||
|
||||
Review
I don't know if there is a better way to define this type. If I don't use I don't know if there is a better way to define this type. If I don't use `A` and `S` in its definition, it refuses to build.
Review
As you can see, these two Options will actually always be None, never Some(A) or Some(S). As you can see, these two Options will actually always be None, never Some(A) or Some(S).
trinity-1686a
commented 6 years ago
Review
You can use PhantomData https://doc.rust-lang.org/beta/std/marker/struct.PhantomData.html, it'll probably do the trick You can use PhantomData https://doc.rust-lang.org/beta/std/marker/struct.PhantomData.html, it'll probably do the trick
Simple example : https://gist.github.com/rust-play/9e51f5b8bb3a915a99d958f5ea982f1a
|
||||
// Actions
|
||||
Review
I don't know if there is a better way to define this type. If I don't use I don't know if there is a better way to define this type. If I don't use `A` and `S` in its definition, it refuses to build.
Review
As you can see, these two Options will actually always be None, never Some(A) or Some(S). As you can see, these two Options will actually always be None, never Some(A) or Some(S).
trinity-1686a
commented 6 years ago
Review
You can use PhantomData https://doc.rust-lang.org/beta/std/marker/struct.PhantomData.html, it'll probably do the trick You can use PhantomData https://doc.rust-lang.org/beta/std/marker/struct.PhantomData.html, it'll probably do the trick
Simple example : https://gist.github.com/rust-play/9e51f5b8bb3a915a99d958f5ea982f1a
|
||||
pub trait Action {
|
||||
Review
I don't know if there is a better way to define this type. If I don't use I don't know if there is a better way to define this type. If I don't use `A` and `S` in its definition, it refuses to build.
Review
As you can see, these two Options will actually always be None, never Some(A) or Some(S). As you can see, these two Options will actually always be None, never Some(A) or Some(S).
trinity-1686a
commented 6 years ago
Review
You can use PhantomData https://doc.rust-lang.org/beta/std/marker/struct.PhantomData.html, it'll probably do the trick You can use PhantomData https://doc.rust-lang.org/beta/std/marker/struct.PhantomData.html, it'll probably do the trick
Simple example : https://gist.github.com/rust-play/9e51f5b8bb3a915a99d958f5ea982f1a
|
||||
fn to_str() -> &'static str;
|
||||
Review
I don't know if there is a better way to define this type. If I don't use I don't know if there is a better way to define this type. If I don't use `A` and `S` in its definition, it refuses to build.
Review
As you can see, these two Options will actually always be None, never Some(A) or Some(S). As you can see, these two Options will actually always be None, never Some(A) or Some(S).
trinity-1686a
commented 6 years ago
Review
You can use PhantomData https://doc.rust-lang.org/beta/std/marker/struct.PhantomData.html, it'll probably do the trick You can use PhantomData https://doc.rust-lang.org/beta/std/marker/struct.PhantomData.html, it'll probably do the trick
Simple example : https://gist.github.com/rust-play/9e51f5b8bb3a915a99d958f5ea982f1a
|
||||
}
|
||||
Review
I don't know if there is a better way to define this type. If I don't use I don't know if there is a better way to define this type. If I don't use `A` and `S` in its definition, it refuses to build.
Review
As you can see, these two Options will actually always be None, never Some(A) or Some(S). As you can see, these two Options will actually always be None, never Some(A) or Some(S).
trinity-1686a
commented 6 years ago
Review
You can use PhantomData https://doc.rust-lang.org/beta/std/marker/struct.PhantomData.html, it'll probably do the trick You can use PhantomData https://doc.rust-lang.org/beta/std/marker/struct.PhantomData.html, it'll probably do the trick
Simple example : https://gist.github.com/rust-play/9e51f5b8bb3a915a99d958f5ea982f1a
|
||||
pub struct Read;
|
||||
Review
I don't know if there is a better way to define this type. If I don't use I don't know if there is a better way to define this type. If I don't use `A` and `S` in its definition, it refuses to build.
Review
As you can see, these two Options will actually always be None, never Some(A) or Some(S). As you can see, these two Options will actually always be None, never Some(A) or Some(S).
trinity-1686a
commented 6 years ago
Review
You can use PhantomData https://doc.rust-lang.org/beta/std/marker/struct.PhantomData.html, it'll probably do the trick You can use PhantomData https://doc.rust-lang.org/beta/std/marker/struct.PhantomData.html, it'll probably do the trick
Simple example : https://gist.github.com/rust-play/9e51f5b8bb3a915a99d958f5ea982f1a
|
||||
impl Action for Read {
|
||||
Review
I don't know if there is a better way to define this type. If I don't use I don't know if there is a better way to define this type. If I don't use `A` and `S` in its definition, it refuses to build.
Review
As you can see, these two Options will actually always be None, never Some(A) or Some(S). As you can see, these two Options will actually always be None, never Some(A) or Some(S).
trinity-1686a
commented 6 years ago
Review
You can use PhantomData https://doc.rust-lang.org/beta/std/marker/struct.PhantomData.html, it'll probably do the trick You can use PhantomData https://doc.rust-lang.org/beta/std/marker/struct.PhantomData.html, it'll probably do the trick
Simple example : https://gist.github.com/rust-play/9e51f5b8bb3a915a99d958f5ea982f1a
|
||||
fn to_str() -> &'static str {
|
||||
Review
I don't know if there is a better way to define this type. If I don't use I don't know if there is a better way to define this type. If I don't use `A` and `S` in its definition, it refuses to build.
Review
As you can see, these two Options will actually always be None, never Some(A) or Some(S). As you can see, these two Options will actually always be None, never Some(A) or Some(S).
trinity-1686a
commented 6 years ago
Review
You can use PhantomData https://doc.rust-lang.org/beta/std/marker/struct.PhantomData.html, it'll probably do the trick You can use PhantomData https://doc.rust-lang.org/beta/std/marker/struct.PhantomData.html, it'll probably do the trick
Simple example : https://gist.github.com/rust-play/9e51f5b8bb3a915a99d958f5ea982f1a
|
||||
"read"
|
||||
Review
I don't know if there is a better way to define this type. If I don't use I don't know if there is a better way to define this type. If I don't use `A` and `S` in its definition, it refuses to build.
Review
As you can see, these two Options will actually always be None, never Some(A) or Some(S). As you can see, these two Options will actually always be None, never Some(A) or Some(S).
trinity-1686a
commented 6 years ago
Review
You can use PhantomData https://doc.rust-lang.org/beta/std/marker/struct.PhantomData.html, it'll probably do the trick You can use PhantomData https://doc.rust-lang.org/beta/std/marker/struct.PhantomData.html, it'll probably do the trick
Simple example : https://gist.github.com/rust-play/9e51f5b8bb3a915a99d958f5ea982f1a
|
||||
}
|
||||
Review
I don't know if there is a better way to define this type. If I don't use I don't know if there is a better way to define this type. If I don't use `A` and `S` in its definition, it refuses to build.
Review
As you can see, these two Options will actually always be None, never Some(A) or Some(S). As you can see, these two Options will actually always be None, never Some(A) or Some(S).
trinity-1686a
commented 6 years ago
Review
You can use PhantomData https://doc.rust-lang.org/beta/std/marker/struct.PhantomData.html, it'll probably do the trick You can use PhantomData https://doc.rust-lang.org/beta/std/marker/struct.PhantomData.html, it'll probably do the trick
Simple example : https://gist.github.com/rust-play/9e51f5b8bb3a915a99d958f5ea982f1a
|
||||
}
|
||||
Review
I don't know if there is a better way to define this type. If I don't use I don't know if there is a better way to define this type. If I don't use `A` and `S` in its definition, it refuses to build.
Review
As you can see, these two Options will actually always be None, never Some(A) or Some(S). As you can see, these two Options will actually always be None, never Some(A) or Some(S).
trinity-1686a
commented 6 years ago
Review
You can use PhantomData https://doc.rust-lang.org/beta/std/marker/struct.PhantomData.html, it'll probably do the trick You can use PhantomData https://doc.rust-lang.org/beta/std/marker/struct.PhantomData.html, it'll probably do the trick
Simple example : https://gist.github.com/rust-play/9e51f5b8bb3a915a99d958f5ea982f1a
|
||||
pub struct Write;
|
||||
Review
I don't know if there is a better way to define this type. If I don't use I don't know if there is a better way to define this type. If I don't use `A` and `S` in its definition, it refuses to build.
Review
As you can see, these two Options will actually always be None, never Some(A) or Some(S). As you can see, these two Options will actually always be None, never Some(A) or Some(S).
trinity-1686a
commented 6 years ago
Review
You can use PhantomData https://doc.rust-lang.org/beta/std/marker/struct.PhantomData.html, it'll probably do the trick You can use PhantomData https://doc.rust-lang.org/beta/std/marker/struct.PhantomData.html, it'll probably do the trick
Simple example : https://gist.github.com/rust-play/9e51f5b8bb3a915a99d958f5ea982f1a
|
||||
impl Action for Write {
|
||||
Review
I don't know if there is a better way to define this type. If I don't use I don't know if there is a better way to define this type. If I don't use `A` and `S` in its definition, it refuses to build.
Review
As you can see, these two Options will actually always be None, never Some(A) or Some(S). As you can see, these two Options will actually always be None, never Some(A) or Some(S).
trinity-1686a
commented 6 years ago
Review
You can use PhantomData https://doc.rust-lang.org/beta/std/marker/struct.PhantomData.html, it'll probably do the trick You can use PhantomData https://doc.rust-lang.org/beta/std/marker/struct.PhantomData.html, it'll probably do the trick
Simple example : https://gist.github.com/rust-play/9e51f5b8bb3a915a99d958f5ea982f1a
|
||||
fn to_str() -> &'static str {
|
||||
Review
I don't know if there is a better way to define this type. If I don't use I don't know if there is a better way to define this type. If I don't use `A` and `S` in its definition, it refuses to build.
Review
As you can see, these two Options will actually always be None, never Some(A) or Some(S). As you can see, these two Options will actually always be None, never Some(A) or Some(S).
trinity-1686a
commented 6 years ago
Review
You can use PhantomData https://doc.rust-lang.org/beta/std/marker/struct.PhantomData.html, it'll probably do the trick You can use PhantomData https://doc.rust-lang.org/beta/std/marker/struct.PhantomData.html, it'll probably do the trick
Simple example : https://gist.github.com/rust-play/9e51f5b8bb3a915a99d958f5ea982f1a
|
||||
"write"
|
||||
Review
I don't know if there is a better way to define this type. If I don't use I don't know if there is a better way to define this type. If I don't use `A` and `S` in its definition, it refuses to build.
Review
As you can see, these two Options will actually always be None, never Some(A) or Some(S). As you can see, these two Options will actually always be None, never Some(A) or Some(S).
trinity-1686a
commented 6 years ago
Review
You can use PhantomData https://doc.rust-lang.org/beta/std/marker/struct.PhantomData.html, it'll probably do the trick You can use PhantomData https://doc.rust-lang.org/beta/std/marker/struct.PhantomData.html, it'll probably do the trick
Simple example : https://gist.github.com/rust-play/9e51f5b8bb3a915a99d958f5ea982f1a
|
||||
}
|
||||
Review
I don't know if there is a better way to define this type. If I don't use I don't know if there is a better way to define this type. If I don't use `A` and `S` in its definition, it refuses to build.
Review
As you can see, these two Options will actually always be None, never Some(A) or Some(S). As you can see, these two Options will actually always be None, never Some(A) or Some(S).
trinity-1686a
commented 6 years ago
Review
You can use PhantomData https://doc.rust-lang.org/beta/std/marker/struct.PhantomData.html, it'll probably do the trick You can use PhantomData https://doc.rust-lang.org/beta/std/marker/struct.PhantomData.html, it'll probably do the trick
Simple example : https://gist.github.com/rust-play/9e51f5b8bb3a915a99d958f5ea982f1a
|
||||
}
|
||||
Review
I don't know if there is a better way to define this type. If I don't use I don't know if there is a better way to define this type. If I don't use `A` and `S` in its definition, it refuses to build.
Review
As you can see, these two Options will actually always be None, never Some(A) or Some(S). As you can see, these two Options will actually always be None, never Some(A) or Some(S).
trinity-1686a
commented 6 years ago
Review
You can use PhantomData https://doc.rust-lang.org/beta/std/marker/struct.PhantomData.html, it'll probably do the trick You can use PhantomData https://doc.rust-lang.org/beta/std/marker/struct.PhantomData.html, it'll probably do the trick
Simple example : https://gist.github.com/rust-play/9e51f5b8bb3a915a99d958f5ea982f1a
|
||||
|
||||
Review
I don't know if there is a better way to define this type. If I don't use I don't know if there is a better way to define this type. If I don't use `A` and `S` in its definition, it refuses to build.
Review
As you can see, these two Options will actually always be None, never Some(A) or Some(S). As you can see, these two Options will actually always be None, never Some(A) or Some(S).
trinity-1686a
commented 6 years ago
Review
You can use PhantomData https://doc.rust-lang.org/beta/std/marker/struct.PhantomData.html, it'll probably do the trick You can use PhantomData https://doc.rust-lang.org/beta/std/marker/struct.PhantomData.html, it'll probably do the trick
Simple example : https://gist.github.com/rust-play/9e51f5b8bb3a915a99d958f5ea982f1a
|
||||
// Scopes
|
||||
Review
I don't know if there is a better way to define this type. If I don't use I don't know if there is a better way to define this type. If I don't use `A` and `S` in its definition, it refuses to build.
Review
As you can see, these two Options will actually always be None, never Some(A) or Some(S). As you can see, these two Options will actually always be None, never Some(A) or Some(S).
trinity-1686a
commented 6 years ago
Review
You can use PhantomData https://doc.rust-lang.org/beta/std/marker/struct.PhantomData.html, it'll probably do the trick You can use PhantomData https://doc.rust-lang.org/beta/std/marker/struct.PhantomData.html, it'll probably do the trick
Simple example : https://gist.github.com/rust-play/9e51f5b8bb3a915a99d958f5ea982f1a
|
||||
pub trait Scope {
|
||||
Review
I don't know if there is a better way to define this type. If I don't use I don't know if there is a better way to define this type. If I don't use `A` and `S` in its definition, it refuses to build.
Review
As you can see, these two Options will actually always be None, never Some(A) or Some(S). As you can see, these two Options will actually always be None, never Some(A) or Some(S).
trinity-1686a
commented 6 years ago
Review
You can use PhantomData https://doc.rust-lang.org/beta/std/marker/struct.PhantomData.html, it'll probably do the trick You can use PhantomData https://doc.rust-lang.org/beta/std/marker/struct.PhantomData.html, it'll probably do the trick
Simple example : https://gist.github.com/rust-play/9e51f5b8bb3a915a99d958f5ea982f1a
|
||||
fn to_str() -> &'static str;
|
||||
Review
I don't know if there is a better way to define this type. If I don't use I don't know if there is a better way to define this type. If I don't use `A` and `S` in its definition, it refuses to build.
Review
As you can see, these two Options will actually always be None, never Some(A) or Some(S). As you can see, these two Options will actually always be None, never Some(A) or Some(S).
trinity-1686a
commented 6 years ago
Review
You can use PhantomData https://doc.rust-lang.org/beta/std/marker/struct.PhantomData.html, it'll probably do the trick You can use PhantomData https://doc.rust-lang.org/beta/std/marker/struct.PhantomData.html, it'll probably do the trick
Simple example : https://gist.github.com/rust-play/9e51f5b8bb3a915a99d958f5ea982f1a
|
||||
}
|
||||
Review
I don't know if there is a better way to define this type. If I don't use I don't know if there is a better way to define this type. If I don't use `A` and `S` in its definition, it refuses to build.
Review
As you can see, these two Options will actually always be None, never Some(A) or Some(S). As you can see, these two Options will actually always be None, never Some(A) or Some(S).
trinity-1686a
commented 6 years ago
Review
You can use PhantomData https://doc.rust-lang.org/beta/std/marker/struct.PhantomData.html, it'll probably do the trick You can use PhantomData https://doc.rust-lang.org/beta/std/marker/struct.PhantomData.html, it'll probably do the trick
Simple example : https://gist.github.com/rust-play/9e51f5b8bb3a915a99d958f5ea982f1a
|
||||
impl Scope for plume_models::posts::Post {
|
||||
Review
I don't know if there is a better way to define this type. If I don't use I don't know if there is a better way to define this type. If I don't use `A` and `S` in its definition, it refuses to build.
Review
As you can see, these two Options will actually always be None, never Some(A) or Some(S). As you can see, these two Options will actually always be None, never Some(A) or Some(S).
trinity-1686a
commented 6 years ago
Review
You can use PhantomData https://doc.rust-lang.org/beta/std/marker/struct.PhantomData.html, it'll probably do the trick You can use PhantomData https://doc.rust-lang.org/beta/std/marker/struct.PhantomData.html, it'll probably do the trick
Simple example : https://gist.github.com/rust-play/9e51f5b8bb3a915a99d958f5ea982f1a
|
||||
fn to_str() -> &'static str {
|
||||
Review
I don't know if there is a better way to define this type. If I don't use I don't know if there is a better way to define this type. If I don't use `A` and `S` in its definition, it refuses to build.
Review
As you can see, these two Options will actually always be None, never Some(A) or Some(S). As you can see, these two Options will actually always be None, never Some(A) or Some(S).
trinity-1686a
commented 6 years ago
Review
You can use PhantomData https://doc.rust-lang.org/beta/std/marker/struct.PhantomData.html, it'll probably do the trick You can use PhantomData https://doc.rust-lang.org/beta/std/marker/struct.PhantomData.html, it'll probably do the trick
Simple example : https://gist.github.com/rust-play/9e51f5b8bb3a915a99d958f5ea982f1a
|
||||
"posts"
|
||||
Review
I don't know if there is a better way to define this type. If I don't use I don't know if there is a better way to define this type. If I don't use `A` and `S` in its definition, it refuses to build.
Review
As you can see, these two Options will actually always be None, never Some(A) or Some(S). As you can see, these two Options will actually always be None, never Some(A) or Some(S).
trinity-1686a
commented 6 years ago
Review
You can use PhantomData https://doc.rust-lang.org/beta/std/marker/struct.PhantomData.html, it'll probably do the trick You can use PhantomData https://doc.rust-lang.org/beta/std/marker/struct.PhantomData.html, it'll probably do the trick
Simple example : https://gist.github.com/rust-play/9e51f5b8bb3a915a99d958f5ea982f1a
|
||||
}
|
||||
Review
I don't know if there is a better way to define this type. If I don't use I don't know if there is a better way to define this type. If I don't use `A` and `S` in its definition, it refuses to build.
Review
As you can see, these two Options will actually always be None, never Some(A) or Some(S). As you can see, these two Options will actually always be None, never Some(A) or Some(S).
trinity-1686a
commented 6 years ago
Review
You can use PhantomData https://doc.rust-lang.org/beta/std/marker/struct.PhantomData.html, it'll probably do the trick You can use PhantomData https://doc.rust-lang.org/beta/std/marker/struct.PhantomData.html, it'll probably do the trick
Simple example : https://gist.github.com/rust-play/9e51f5b8bb3a915a99d958f5ea982f1a
|
||||
}
|
||||
Review
I don't know if there is a better way to define this type. If I don't use I don't know if there is a better way to define this type. If I don't use `A` and `S` in its definition, it refuses to build.
Review
As you can see, these two Options will actually always be None, never Some(A) or Some(S). As you can see, these two Options will actually always be None, never Some(A) or Some(S).
trinity-1686a
commented 6 years ago
Review
You can use PhantomData https://doc.rust-lang.org/beta/std/marker/struct.PhantomData.html, it'll probably do the trick You can use PhantomData https://doc.rust-lang.org/beta/std/marker/struct.PhantomData.html, it'll probably do the trick
Simple example : https://gist.github.com/rust-play/9e51f5b8bb3a915a99d958f5ea982f1a
|
||||
|
||||
Review
I don't know if there is a better way to define this type. If I don't use I don't know if there is a better way to define this type. If I don't use `A` and `S` in its definition, it refuses to build.
Review
As you can see, these two Options will actually always be None, never Some(A) or Some(S). As you can see, these two Options will actually always be None, never Some(A) or Some(S).
trinity-1686a
commented 6 years ago
Review
You can use PhantomData https://doc.rust-lang.org/beta/std/marker/struct.PhantomData.html, it'll probably do the trick You can use PhantomData https://doc.rust-lang.org/beta/std/marker/struct.PhantomData.html, it'll probably do the trick
Simple example : https://gist.github.com/rust-play/9e51f5b8bb3a915a99d958f5ea982f1a
|
||||
pub struct Authorization<A, S> (pub ApiToken, PhantomData<(A, S)>);
|
||||
Review
I don't know if there is a better way to define this type. If I don't use I don't know if there is a better way to define this type. If I don't use `A` and `S` in its definition, it refuses to build.
Review
As you can see, these two Options will actually always be None, never Some(A) or Some(S). As you can see, these two Options will actually always be None, never Some(A) or Some(S).
trinity-1686a
commented 6 years ago
Review
You can use PhantomData https://doc.rust-lang.org/beta/std/marker/struct.PhantomData.html, it'll probably do the trick You can use PhantomData https://doc.rust-lang.org/beta/std/marker/struct.PhantomData.html, it'll probably do the trick
Simple example : https://gist.github.com/rust-play/9e51f5b8bb3a915a99d958f5ea982f1a
|
||||
|
||||
Review
I don't know if there is a better way to define this type. If I don't use I don't know if there is a better way to define this type. If I don't use `A` and `S` in its definition, it refuses to build.
Review
As you can see, these two Options will actually always be None, never Some(A) or Some(S). As you can see, these two Options will actually always be None, never Some(A) or Some(S).
trinity-1686a
commented 6 years ago
Review
You can use PhantomData https://doc.rust-lang.org/beta/std/marker/struct.PhantomData.html, it'll probably do the trick You can use PhantomData https://doc.rust-lang.org/beta/std/marker/struct.PhantomData.html, it'll probably do the trick
Simple example : https://gist.github.com/rust-play/9e51f5b8bb3a915a99d958f5ea982f1a
|
||||
impl<'a, 'r, A, S> FromRequest<'a, 'r> for Authorization<A, S>
|
||||
Review
I don't know if there is a better way to define this type. If I don't use I don't know if there is a better way to define this type. If I don't use `A` and `S` in its definition, it refuses to build.
Review
As you can see, these two Options will actually always be None, never Some(A) or Some(S). As you can see, these two Options will actually always be None, never Some(A) or Some(S).
trinity-1686a
commented 6 years ago
Review
You can use PhantomData https://doc.rust-lang.org/beta/std/marker/struct.PhantomData.html, it'll probably do the trick You can use PhantomData https://doc.rust-lang.org/beta/std/marker/struct.PhantomData.html, it'll probably do the trick
Simple example : https://gist.github.com/rust-play/9e51f5b8bb3a915a99d958f5ea982f1a
|
||||
where A: Action,
|
||||
Review
I don't know if there is a better way to define this type. If I don't use I don't know if there is a better way to define this type. If I don't use `A` and `S` in its definition, it refuses to build.
Review
As you can see, these two Options will actually always be None, never Some(A) or Some(S). As you can see, these two Options will actually always be None, never Some(A) or Some(S).
trinity-1686a
commented 6 years ago
Review
You can use PhantomData https://doc.rust-lang.org/beta/std/marker/struct.PhantomData.html, it'll probably do the trick You can use PhantomData https://doc.rust-lang.org/beta/std/marker/struct.PhantomData.html, it'll probably do the trick
Simple example : https://gist.github.com/rust-play/9e51f5b8bb3a915a99d958f5ea982f1a
|
||||
S: Scope
|
||||
Review
I don't know if there is a better way to define this type. If I don't use I don't know if there is a better way to define this type. If I don't use `A` and `S` in its definition, it refuses to build.
Review
As you can see, these two Options will actually always be None, never Some(A) or Some(S). As you can see, these two Options will actually always be None, never Some(A) or Some(S).
trinity-1686a
commented 6 years ago
Review
You can use PhantomData https://doc.rust-lang.org/beta/std/marker/struct.PhantomData.html, it'll probably do the trick You can use PhantomData https://doc.rust-lang.org/beta/std/marker/struct.PhantomData.html, it'll probably do the trick
Simple example : https://gist.github.com/rust-play/9e51f5b8bb3a915a99d958f5ea982f1a
|
||||
{
|
||||
Review
I don't know if there is a better way to define this type. If I don't use I don't know if there is a better way to define this type. If I don't use `A` and `S` in its definition, it refuses to build.
Review
As you can see, these two Options will actually always be None, never Some(A) or Some(S). As you can see, these two Options will actually always be None, never Some(A) or Some(S).
trinity-1686a
commented 6 years ago
Review
You can use PhantomData https://doc.rust-lang.org/beta/std/marker/struct.PhantomData.html, it'll probably do the trick You can use PhantomData https://doc.rust-lang.org/beta/std/marker/struct.PhantomData.html, it'll probably do the trick
Simple example : https://gist.github.com/rust-play/9e51f5b8bb3a915a99d958f5ea982f1a
|
||||
type Error = ();
|
||||
Review
I don't know if there is a better way to define this type. If I don't use I don't know if there is a better way to define this type. If I don't use `A` and `S` in its definition, it refuses to build.
Review
As you can see, these two Options will actually always be None, never Some(A) or Some(S). As you can see, these two Options will actually always be None, never Some(A) or Some(S).
trinity-1686a
commented 6 years ago
Review
You can use PhantomData https://doc.rust-lang.org/beta/std/marker/struct.PhantomData.html, it'll probably do the trick You can use PhantomData https://doc.rust-lang.org/beta/std/marker/struct.PhantomData.html, it'll probably do the trick
Simple example : https://gist.github.com/rust-play/9e51f5b8bb3a915a99d958f5ea982f1a
|
||||
|
||||
Review
I don't know if there is a better way to define this type. If I don't use I don't know if there is a better way to define this type. If I don't use `A` and `S` in its definition, it refuses to build.
Review
As you can see, these two Options will actually always be None, never Some(A) or Some(S). As you can see, these two Options will actually always be None, never Some(A) or Some(S).
trinity-1686a
commented 6 years ago
Review
You can use PhantomData https://doc.rust-lang.org/beta/std/marker/struct.PhantomData.html, it'll probably do the trick You can use PhantomData https://doc.rust-lang.org/beta/std/marker/struct.PhantomData.html, it'll probably do the trick
Simple example : https://gist.github.com/rust-play/9e51f5b8bb3a915a99d958f5ea982f1a
|
||||
fn from_request(request: &'a Request<'r>) -> request::Outcome<Authorization<A, S>, ()> {
|
||||
Review
I don't know if there is a better way to define this type. If I don't use I don't know if there is a better way to define this type. If I don't use `A` and `S` in its definition, it refuses to build.
Review
As you can see, these two Options will actually always be None, never Some(A) or Some(S). As you can see, these two Options will actually always be None, never Some(A) or Some(S).
trinity-1686a
commented 6 years ago
Review
You can use PhantomData https://doc.rust-lang.org/beta/std/marker/struct.PhantomData.html, it'll probably do the trick You can use PhantomData https://doc.rust-lang.org/beta/std/marker/struct.PhantomData.html, it'll probably do the trick
Simple example : https://gist.github.com/rust-play/9e51f5b8bb3a915a99d958f5ea982f1a
|
||||
request.guard::<ApiToken>()
|
||||
Review
I don't know if there is a better way to define this type. If I don't use I don't know if there is a better way to define this type. If I don't use `A` and `S` in its definition, it refuses to build.
Review
As you can see, these two Options will actually always be None, never Some(A) or Some(S). As you can see, these two Options will actually always be None, never Some(A) or Some(S).
trinity-1686a
commented 6 years ago
Review
You can use PhantomData https://doc.rust-lang.org/beta/std/marker/struct.PhantomData.html, it'll probably do the trick You can use PhantomData https://doc.rust-lang.org/beta/std/marker/struct.PhantomData.html, it'll probably do the trick
Simple example : https://gist.github.com/rust-play/9e51f5b8bb3a915a99d958f5ea982f1a
|
||||
.map_failure(|_| (Status::Unauthorized, ()))
|
||||
Review
I don't know if there is a better way to define this type. If I don't use I don't know if there is a better way to define this type. If I don't use `A` and `S` in its definition, it refuses to build.
Review
As you can see, these two Options will actually always be None, never Some(A) or Some(S). As you can see, these two Options will actually always be None, never Some(A) or Some(S).
trinity-1686a
commented 6 years ago
Review
You can use PhantomData https://doc.rust-lang.org/beta/std/marker/struct.PhantomData.html, it'll probably do the trick You can use PhantomData https://doc.rust-lang.org/beta/std/marker/struct.PhantomData.html, it'll probably do the trick
Simple example : https://gist.github.com/rust-play/9e51f5b8bb3a915a99d958f5ea982f1a
|
||||
.and_then(|token| if token.can(A::to_str(), S::to_str()) {
|
||||
Review
I don't know if there is a better way to define this type. If I don't use I don't know if there is a better way to define this type. If I don't use `A` and `S` in its definition, it refuses to build.
Review
As you can see, these two Options will actually always be None, never Some(A) or Some(S). As you can see, these two Options will actually always be None, never Some(A) or Some(S).
trinity-1686a
commented 6 years ago
Review
You can use PhantomData https://doc.rust-lang.org/beta/std/marker/struct.PhantomData.html, it'll probably do the trick You can use PhantomData https://doc.rust-lang.org/beta/std/marker/struct.PhantomData.html, it'll probably do the trick
Simple example : https://gist.github.com/rust-play/9e51f5b8bb3a915a99d958f5ea982f1a
|
||||
Outcome::Success(Authorization(token, PhantomData))
|
||||
Review
I don't know if there is a better way to define this type. If I don't use I don't know if there is a better way to define this type. If I don't use `A` and `S` in its definition, it refuses to build.
Review
As you can see, these two Options will actually always be None, never Some(A) or Some(S). As you can see, these two Options will actually always be None, never Some(A) or Some(S).
trinity-1686a
commented 6 years ago
Review
You can use PhantomData https://doc.rust-lang.org/beta/std/marker/struct.PhantomData.html, it'll probably do the trick You can use PhantomData https://doc.rust-lang.org/beta/std/marker/struct.PhantomData.html, it'll probably do the trick
Simple example : https://gist.github.com/rust-play/9e51f5b8bb3a915a99d958f5ea982f1a
|
||||
} else {
|
||||
Review
I don't know if there is a better way to define this type. If I don't use I don't know if there is a better way to define this type. If I don't use `A` and `S` in its definition, it refuses to build.
Review
As you can see, these two Options will actually always be None, never Some(A) or Some(S). As you can see, these two Options will actually always be None, never Some(A) or Some(S).
trinity-1686a
commented 6 years ago
Review
You can use PhantomData https://doc.rust-lang.org/beta/std/marker/struct.PhantomData.html, it'll probably do the trick You can use PhantomData https://doc.rust-lang.org/beta/std/marker/struct.PhantomData.html, it'll probably do the trick
Simple example : https://gist.github.com/rust-play/9e51f5b8bb3a915a99d958f5ea982f1a
|
||||
Outcome::Failure((Status::Unauthorized, ()))
|
||||
Review
I don't know if there is a better way to define this type. If I don't use I don't know if there is a better way to define this type. If I don't use `A` and `S` in its definition, it refuses to build.
Review
As you can see, these two Options will actually always be None, never Some(A) or Some(S). As you can see, these two Options will actually always be None, never Some(A) or Some(S).
trinity-1686a
commented 6 years ago
Review
You can use PhantomData https://doc.rust-lang.org/beta/std/marker/struct.PhantomData.html, it'll probably do the trick You can use PhantomData https://doc.rust-lang.org/beta/std/marker/struct.PhantomData.html, it'll probably do the trick
Simple example : https://gist.github.com/rust-play/9e51f5b8bb3a915a99d958f5ea982f1a
|
||||
})
|
||||
Review
I don't know if there is a better way to define this type. If I don't use I don't know if there is a better way to define this type. If I don't use `A` and `S` in its definition, it refuses to build.
Review
As you can see, these two Options will actually always be None, never Some(A) or Some(S). As you can see, these two Options will actually always be None, never Some(A) or Some(S).
trinity-1686a
commented 6 years ago
Review
You can use PhantomData https://doc.rust-lang.org/beta/std/marker/struct.PhantomData.html, it'll probably do the trick You can use PhantomData https://doc.rust-lang.org/beta/std/marker/struct.PhantomData.html, it'll probably do the trick
Simple example : https://gist.github.com/rust-play/9e51f5b8bb3a915a99d958f5ea982f1a
|
||||
}
|
||||
Review
I don't know if there is a better way to define this type. If I don't use I don't know if there is a better way to define this type. If I don't use `A` and `S` in its definition, it refuses to build.
Review
As you can see, these two Options will actually always be None, never Some(A) or Some(S). As you can see, these two Options will actually always be None, never Some(A) or Some(S).
trinity-1686a
commented 6 years ago
Review
You can use PhantomData https://doc.rust-lang.org/beta/std/marker/struct.PhantomData.html, it'll probably do the trick You can use PhantomData https://doc.rust-lang.org/beta/std/marker/struct.PhantomData.html, it'll probably do the trick
Simple example : https://gist.github.com/rust-play/9e51f5b8bb3a915a99d958f5ea982f1a
|
||||
}
|
||||
Review
I don't know if there is a better way to define this type. If I don't use I don't know if there is a better way to define this type. If I don't use `A` and `S` in its definition, it refuses to build.
Review
As you can see, these two Options will actually always be None, never Some(A) or Some(S). As you can see, these two Options will actually always be None, never Some(A) or Some(S).
trinity-1686a
commented 6 years ago
Review
You can use PhantomData https://doc.rust-lang.org/beta/std/marker/struct.PhantomData.html, it'll probably do the trick You can use PhantomData https://doc.rust-lang.org/beta/std/marker/struct.PhantomData.html, it'll probably do the trick
Simple example : https://gist.github.com/rust-play/9e51f5b8bb3a915a99d958f5ea982f1a
|
||||
|
||||
Review
I don't know if there is a better way to define this type. If I don't use I don't know if there is a better way to define this type. If I don't use `A` and `S` in its definition, it refuses to build.
Review
As you can see, these two Options will actually always be None, never Some(A) or Some(S). As you can see, these two Options will actually always be None, never Some(A) or Some(S).
trinity-1686a
commented 6 years ago
Review
You can use PhantomData https://doc.rust-lang.org/beta/std/marker/struct.PhantomData.html, it'll probably do the trick You can use PhantomData https://doc.rust-lang.org/beta/std/marker/struct.PhantomData.html, it'll probably do the trick
Simple example : https://gist.github.com/rust-play/9e51f5b8bb3a915a99d958f5ea982f1a
|
@ -1 +1,59 @@
|
||||
trinity-1686a
commented 6 years ago
Review
both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170 both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170
trinity-1686a
commented 6 years ago
Review
both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170 both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170
|
||||
use rocket_contrib::Json;
|
||||
trinity-1686a
commented 6 years ago
Review
both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170 both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170
|
||||
use serde_json;
|
||||
trinity-1686a
commented 6 years ago
Review
both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170 both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170
|
||||
|
||||
trinity-1686a
commented 6 years ago
Review
both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170 both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170
|
||||
use plume_common::utils::random_hex;
|
||||
trinity-1686a
commented 6 years ago
Review
both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170 both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170
|
||||
use plume_models::{
|
||||
trinity-1686a
commented 6 years ago
Review
both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170 both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170
|
||||
apps::App,
|
||||
trinity-1686a
commented 6 years ago
Review
both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170 both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170
|
||||
api_tokens::*,
|
||||
trinity-1686a
commented 6 years ago
Review
both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170 both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170
|
||||
db_conn::DbConn,
|
||||
trinity-1686a
commented 6 years ago
Review
both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170 both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170
|
||||
users::User,
|
||||
trinity-1686a
commented 6 years ago
Review
both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170 both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170
|
||||
};
|
||||
trinity-1686a
commented 6 years ago
Review
both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170 both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170
|
||||
|
||||
trinity-1686a
commented 6 years ago
Review
both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170 both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170
|
||||
#[derive(FromForm)]
|
||||
trinity-1686a
commented 6 years ago
Review
both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170 both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170
|
||||
struct OAuthRequest {
|
||||
trinity-1686a
commented 6 years ago
Review
both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170 both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170
|
||||
client_id: String,
|
||||
trinity-1686a
commented 6 years ago
Review
both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170 both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170
|
||||
client_secret: String,
|
||||
trinity-1686a
commented 6 years ago
Review
both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170 both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170
|
||||
password: String,
|
||||
trinity-1686a
commented 6 years ago
Review
both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170 both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170
|
||||
username: String,
|
||||
trinity-1686a
commented 6 years ago
Review
both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170 both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170
|
||||
scopes: String,
|
||||
trinity-1686a
commented 6 years ago
Review
both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170 both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170
|
||||
}
|
||||
trinity-1686a
commented 6 years ago
Review
both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170 both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170
|
||||
|
||||
trinity-1686a
commented 6 years ago
Review
both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170 both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170
|
||||
#[get("/oauth2?<query>")]
|
||||
trinity-1686a
commented 6 years ago
Review
both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170 both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170
|
||||
fn oauth(query: OAuthRequest, conn: DbConn) -> Json<serde_json::Value> {
|
||||
trinity-1686a
commented 6 years ago
Review
both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170 both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170
|
||||
let app = App::find_by_client_id(&*conn, query.client_id).expect("OAuth request from unknown client");
|
||||
trinity-1686a
commented 6 years ago
Review
both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170 both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170
|
||||
if app.client_secret == query.client_secret {
|
||||
trinity-1686a
commented 6 years ago
Review
both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170 both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170
|
||||
if let Some(user) = User::find_local(&*conn, query.username) {
|
||||
trinity-1686a
commented 6 years ago
Review
both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170 both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170
|
||||
if user.auth(query.password) {
|
||||
trinity-1686a
commented 6 years ago
Review
both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170 both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170
|
||||
let token = ApiToken::insert(&*conn, NewApiToken {
|
||||
trinity-1686a
commented 6 years ago
Review
both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170 both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170
|
||||
app_id: app.id,
|
||||
trinity-1686a
commented 6 years ago
Review
both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170 both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170
|
||||
user_id: user.id,
|
||||
trinity-1686a
commented 6 years ago
Review
both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170 both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170
|
||||
value: random_hex(),
|
||||
trinity-1686a
commented 6 years ago
Review
both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170 both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170
|
||||
scopes: query.scopes,
|
||||
trinity-1686a
commented 6 years ago
Review
both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170 both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170
|
||||
});
|
||||
trinity-1686a
commented 6 years ago
Review
both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170 both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170
|
||||
Json(json!({
|
||||
trinity-1686a
commented 6 years ago
Review
both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170 both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170
|
||||
"token": token.value
|
||||
trinity-1686a
commented 6 years ago
Review
both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170 both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170
|
||||
}))
|
||||
trinity-1686a
commented 6 years ago
Review
both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170 both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170
|
||||
} else {
|
||||
trinity-1686a
commented 6 years ago
Review
both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170 both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170
|
||||
Json(json!({
|
||||
trinity-1686a
commented 6 years ago
Review
both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170 both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170
|
||||
"error": "Invalid credentials"
|
||||
trinity-1686a
commented 6 years ago
Review
both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170 both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170
|
||||
}))
|
||||
trinity-1686a
commented 6 years ago
Review
both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170 both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170
|
||||
}
|
||||
trinity-1686a
commented 6 years ago
Review
both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170 both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170
|
||||
} else {
|
||||
trinity-1686a
commented 6 years ago
Review
both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170 both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170
|
||||
// Making fake password verification to avoid different
|
||||
trinity-1686a
commented 6 years ago
Review
both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170 both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170
|
||||
// response times that would make it possible to know
|
||||
trinity-1686a
commented 6 years ago
Review
both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170 both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170
|
||||
// if a username is registered or not.
|
||||
trinity-1686a
commented 6 years ago
Review
both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170 both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170
|
||||
User::get(&*conn, 1).unwrap().auth(query.password);
|
||||
trinity-1686a
commented 6 years ago
Review
both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170 both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170
|
||||
Json(json!({
|
||||
trinity-1686a
commented 6 years ago
Review
both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170 both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170
|
||||
"error": "Invalid credentials"
|
||||
trinity-1686a
commented 6 years ago
Review
both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170 both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170
|
||||
}))
|
||||
trinity-1686a
commented 6 years ago
Review
both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170 both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170
|
||||
}
|
||||
trinity-1686a
commented 6 years ago
Review
both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170 both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170
|
||||
} else {
|
||||
trinity-1686a
commented 6 years ago
Review
both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170 both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170
|
||||
Json(json!({
|
||||
trinity-1686a
commented 6 years ago
Review
both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170 both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170
|
||||
"error": "Invalid client_secret"
|
||||
trinity-1686a
commented 6 years ago
Review
both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170 both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170
|
||||
}))
|
||||
trinity-1686a
commented 6 years ago
Review
both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170 both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170
|
||||
}
|
||||
trinity-1686a
commented 6 years ago
Review
both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170 both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170
|
||||
}
|
||||
trinity-1686a
commented 6 years ago
Review
both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170 both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170
|
||||
|
||||
trinity-1686a
commented 6 years ago
Review
both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170 both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170
|
||||
pub mod apps;
|
||||
trinity-1686a
commented 6 years ago
Review
both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170 both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170
|
||||
pub mod authorization;
|
||||
trinity-1686a
commented 6 years ago
Review
both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170 both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170
|
||||
pub mod posts;
|
||||
|
||||
trinity-1686a
commented 6 years ago
Review
both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170 both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170
trinity-1686a
commented 6 years ago
Review
both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170 both error message ("Wrong password" and "Unknown user") should probably be merged, for similar reasons as #170
|
Just "use apps" is maybe a bit unclear, maybe you should use the full path, and also tell how to use it (Do a post with such data, and such other is optional and....)
Just "use apps" is maybe a bit unclear, maybe you should use the full path, and also tell how to use it (Do a post with such data, and such other is optional and....)
The request should be documented with Swagger (but it is broken for the moment 😢)
The request should be documented with Swagger (but it is broken for the moment 😢)