-
-
Notifications
You must be signed in to change notification settings - Fork 523
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Authentication and authorization #2833
Comments
Auth SphinxQL interface.Daemon uses check of the password from the mysql client compatible with the plugin
should work the same was as with regular mysql server. Added new test options to
or use
the
and additional users should be added like
The |
Basic auth HTTP interface.If the user added into daemon client must use HTTP Basic access authentication schema, ie for the curl client it works like
|
auth_user_filedaemon works with the
That should prevent cases when the access authentication is required but no valid users loaded. |
SpecThis is the specification we will follow after the MVP. We will update it if we make any changes along the way. Table of Contents
OverviewThis document provides the specifications for implementing authentication and authorization functionality in Manticore Search. The system includes support for managing users and their credentials, as well as finely-grained permissions defined at the level of individual actions and targets. It ensures compatibility with MySQL clients and maintains data integrity through robust file management and security practices. RequirementsProtocol Support
Usability
Security
Plain Mode Support
Auth File/Table FormatsAuthentication data is split into two parts:
Plain Mode (File-Based)Structure: {
"users": [
{
"username": "admin",
"salt": "<unique_salt>",
"hashes": {
"password_sha1_no_salt": "<sha1(password)>",
"password_sha256": "<sha256(salt + password)>",
"bearer_sha256": "<sha256(salt + sha256(token))>"
}
},
{
"username": "readonly",
"salt": "<unique_salt>",
"hashes": {
"password_sha1_no_salt": "<sha1(password)>",
"password_sha256": "<sha256(salt + password)>",
"bearer_sha256": "<sha256(salt + sha256(token))>"
}
},
{
"username": "custom_user",
"salt": "<unique_salt>",
"hashes": {
"password_sha1_no_salt": "<sha1(password)>",
"password_sha256": "<sha256(salt + password)>",
"bearer_sha256": "<sha256(salt + sha256(token))>"
}
}
],
"permissions": [
{
"username": "admin",
"action": "read",
"target": "*",
"allow": true,
"budget": { "queries_per_minute": 1000 }
},
{
"username": "readonly",
"action": "read",
"target": "*",
"allow": true,
"budget": { "queries_per_day": 10000 }
},
{
"username": "custom_user",
"action": "read",
"target": "table/mytable",
"allow": true,
"budget": { "queries_per_minute": 500 }
}
]
} RT Mode (Table-Based)In RT Mode, authentication data should be stored in system tables with salts and hashes for enhanced security. Users Table ("system.auth_users"):
Example schema: CREATE TABLE system.auth_users (
username string,
salt string,
hashes json
); Permissions Table ("system.auth_permissions"):
Example schema: CREATE TABLE system.auth_permissions (
username string,
action string,
target string,
allow bool,
budget json
); Example "system.auth_users" content:
Example "system.auth_permissions" content:
Authentication via MySQL ProtocolFollows the requirements of the mysql/mariadb clients, e.g. https://dev.mysql.com/doc/refman/8.4/en/native-pluggable-authentication.html
Here's the diagram of how it works: sequenceDiagram
participant Client
participant Server
Server->>Client: Generate random nonce (public_seed) and send to Client
Client->>Client: Compute hash_stage1 = SHA1(password)
Client->>Client: Compute hash_stage2 = SHA1(hash_stage1)
Client->>Client: Compute scramble = XOR(hash_stage1, SHA1(public_seed + hash_stage2))
Client->>Server: Send scramble
Server->>Server: Retrieve stored hash_stage2 (SHA1(SHA1(password)))
Server->>Server: Compute SHA1(public_seed + stored hash_stage2)
Server->>Server: Compute hash_stage1 = XOR(scramble, SHA1(public_seed + stored hash_stage2))
Server->>Server: Compute candidate_hash2 = SHA1(hash_stage1)
Server->>Server: Compare candidate_hash2 with stored hash_stage2
alt Authentication Successful
Server->>Client: Authentication successful
else Authentication Failed
Server->>Client: Authentication failed
end
Authentication via HTTP ProtocolAuthentication supports the following mechanisms:
Authentication via Binary ProtocolAuthentication via the binary protocol uses a secure token-based mechanism with strong encryption and replay attack protection. This section outlines the steps involved and provides clarity on key details. Definitions
Process Overview
Process Flow DiagramThe following sequence diagram illustrates the interaction between the client and server during the
sequenceDiagram
participant Client as Client (Manticore instance or user's app)
participant Server as Server (Manticore instance)
alt Client is a Manticore instance
Client->>Client: Generate public-private key pair on startup
else Client is an app
Client->>Client: Generate public-private key pair before GET_TOKEN
end
Client->>Client: Encrypt main token with public key
Client->>Server: Send encrypted token, public key, and nonce
Server->>Server: Decrypt token using client public key
Server->>Server: Validate token and nonce
alt Token and nonce valid
Server->>Server: Generate temporary token
Server->>Server: Encrypt temporary token with client public key
Server->>Client: Send encrypted temporary token and nonce
Client->>Client: Decrypt temporary token
Client->>Client: Cache temporary token
else Token or nonce invalid
Server->>Client: Return authentication error
end
Temporary Token Management
Permissions ModelPermissions are defined as individual records. Each record specifies:
If multiple records apply to the same user/action/target, a record with Granular PermissionsThe actions
Notes
Rule Resolution Strategy
Rule Evaluation AlgorithmWhen a user attempts an action, evaluate permissions in the following order:
Documentation and TransparencyTo help administrators understand the system, we should document the rule resolution strategy clearly. Examples and edge cases, such as the following should be included:
Management Tool (
|
TODO:
|
implemented Bearer token authentication at the 4ea2737 Client could use HTTP header for authorization.
that he previously obtained via Additionally, the authentication token is now passed to the Buddy via an environment variable on Buddy start. I've also added an Daemon only collects the generated tokens and check the user HTTP requests the for |
I created tickets for the rest of the points from the Specification and suggest to implement these in the following order:
|
Proposal:
Umbrella issue for https://roadmap.mnt.cr/ about authentication and authorization.
Subtasks:
Added current issues list as separate ticket #2844
Checklist:
To be completed by the assignee. Check off tasks that have been completed or are not applicable.
The text was updated successfully, but these errors were encountered: