如果你使用 DeepSeek、元宝 AI、Copilot、ChatGPT 等 AI 工具,协助配置轩辕镜像、编写 docker pull 命令、修改 Docker Compose 镜像地址、配置镜像加速、排查镜像拉取失败、分析报错日志等问题,请先让 AI 阅读并遵守轩辕镜像的规则文档。
只需在 AI 对话中先发送下面这段话即可:
请先阅读并遵守:https://xuanyuan.cloud/agents.md
未读文档前不要生成 pull 命令或排错方案。查看 agents.md 用法指南与完整示范。国内用户首推 元宝 AI、DeepSeek 的深度思考模式,不推荐豆包 AI;Cursor 等编辑器可在对话 @ 该链接,或加入 User Rules。 若 AI 无法访问外链,可 打开说明文档 复制全文粘贴。文档会随站点更新,复制内容可能过期,建议定期检查。
Authentication adapter and services used for the GHGA data portal
This repository contains two services for the management, authentication and authorization of users of the GHGA data portal.
These two services are described in the following sections. The setting provide_apis can be used to determine which of the services will be started and which APIs these services should provide. The setting run_consumer should be set for the service instance that runs as an event consumer.
The auth_adapter sub-package contains the authentication service used by the API gateway via the ExtAuth protocol. It is started when provide_apis contains the value ext_auth. No other APIs can be provided in that case.
If a path_prefix has been configured for the AuthService in the API gateway, then the api_root_path must be set accordingly.
Note that the Auth Adapter carries out a dual role in our architecture, by communicating directly with the client in order to establish user sessions and enroll TOTP, and also regulating access to the backend while modifying authorization headers. This utilises the https://www.getambassador.io/docs/edge-stack/latest/topics/running/services/ext-authz protocol used by Envoy-based proxies like Emissary-ingress. It does not work with Nginx-based proxies like Ingress-Nginx, because the protocol for external authentication used by http_auth_request_module works in a slightly different way that prevents this dual-use of the Auth Apater.
Emissary-ingress does not forward all authorization headers by default, therefore the additional headers must be configured for the AuthService like this:
yamlallowed_request_headers: - x-authorization - x-csrf-token allowed_authorization_headers: - cookie - x-authorization - x-csrf-token - x-session
The x-authorization header is only needed when an additional HTTP Basic Auth is used on top of the OIDC based authentication. Only the default authorization header actually needs to be modified by the Auth Adapter. However, for security purposes the Auth Adapter also empties the authorization headers that it consumes and evaluates itself and which are therefore not needed by the backend. Therefore, these are also specified as response headers.
The Auth Service provides two APIs, the (public) users API for the user registry, and the (internal) claims API for the claims repository. The setting provide_apis can be used to specify which of the two APIs should be provided. For testing purposes, both APIs can be provided at the same time, but this is not recommended in production. If no API is specified, then only a health endpoint is provided.
We recommend using the provided Docker container.
A pre-built version is available on https://hub.docker.com/repository/docker/ghga/auth-service:
bashdocker pull ghga/auth-service:10.0.2
Or you can build the container yourself from the ./Dockerfile:
bash# Execute in the repo's root dir: docker build -t ghga/auth-service:10.0.2 .
For production-ready deployment, we recommend using Kubernetes. However for simple use cases, you could execute the service using docker on a single server:
bash# The entrypoint is pre-configured: docker run -p 8080:8080 ghga/auth-service:10.0.2 --help
If you prefer not to use containers, you may install the service from source:
bash# Execute in the repo's root dir: pip install . # To run the service: auth_service --help
The service requires the following configuration parameters:
enable_opentelemetry (boolean): If set to true, this will run necessary setup code.If set to false, no setup code is run, which leaves tracing disabled. Default: false.
otel_trace_sampling_rate (number): Determines which proportion of spans should be sampled. A value of 1.0 means all and is equivalent to the previous behaviour. Setting this to 0 will result in no spans being sampled, but this does not automatically set enable_opentelemetry to False. Minimum: 0. Maximum: 1. Default: 1.0.
auth_topic (string, required): The name of the topic containing auth-related events.
Examples:
json"auth-events"
second_factor_recreated_type (string, required): The event type for recreation of the second factor for authentication.
Examples:
json"second_factor_recreated"
iva_state_changed_topic (string, required): The name of the topic containing IVA events.
Examples:
json"ivas"
iva_state_changed_type (string, required): The type to use for IVA state changed events.
Examples:
json"iva_state_changed"
iva_send_code_type (string, required): The type to use for IVA send code events.
Examples:
json"iva_send_code"
dataset_change_topic (string, required): Name of the topic announcing, among other things, the list of files included in a new dataset.
Examples:
json"metadata_datasets"
dataset_deletion_type (string, required): Event type used for communicating dataset deletions.
Examples:
json"dataset_deleted"
dataset_upsertion_type (string, required): Event type used for communicating dataset upsertions.
Examples:
json"dataset_upserted"
claims_collection (string): Name of the collection for user claims. Default: "claims".
user_topic (string): The name of the topic containing user events. Default: "users".
users_collection (string): Name of the collection for users. Default: "users".
user_tokens_collection (string): Name of the collection for user tokens. Default: "user_tokens".
ivas_collection (string): Name of the collection for IVAs. Default: "ivas".
service_name (string): Short name of this service. Default: "auth_service".
service_instance_id (string, required): A string that uniquely identifies this instance across all instances of this service. This is included in log messages.
Examples:
json"germany-bw-instance-001"
kafka_servers (array, required): A list of connection strings to connect to Kafka bootstrap servers.
Examples:
json[ "localhost:9092" ]
kafka_security_protocol (string): Protocol used to communicate with brokers. Valid values are: PLAINTEXT, SSL. Must be one of: "PLAINTEXT" or "SSL". Default: "PLAINTEXT".
kafka_ssl_cafile (string): Certificate Authority file path containing certificates used to sign broker certificates. If a CA is not specified, the default system CA will be used if found by OpenSSL. Default: "".
kafka_ssl_certfile (string): Optional filename of client certificate, as well as any CA certificates needed to establish the certificate's authenticity. Default: "".
kafka_ssl_keyfile (string): Optional filename containing the client private key. Default: "".
kafka_ssl_password (string, format: password, write-only): Optional password to be used for the client private key. Default: "".
generate_correlation_id (boolean): A flag, which, if False, will result in an error when inbound requests don't possess a correlation ID. If True, requests without a correlation ID will be assigned a newly generated ID in the correlation ID middleware function. Default: true.
Examples:
jsontrue
jsonfalse
kafka_max_message_size (integer): The largest message size that can be transmitted, in bytes, before compression. Only services that have a need to send/receive larger messages should set this. When used alongside compression, this value can be set to something greater than the broker's message.max.bytes field, which effectively concerns the compressed message size. Exclusive minimum: 0. Default: 1048576.
Examples:
json1048576
json16777216
kafka_compression_type: The compression type used for messages. Valid values are: None, gzip, snappy, lz4, and zstd. If None, no compression is applied. This setting is only relevant for the producer and has no effect on the consumer. If set to a value, the producer will compress messages before sending them to the Kafka broker. If unsure, zstd provides a good balance between speed and compression ratio. Default: null.
Examples:
jsonnull
json"gzip"
json"snappy"
json"lz4"
json"zstd"
kafka_max_retries (integer): The maximum number of times to immediately retry consuming an event upon failure. Works independently of the dead letter queue. Minimum: 0. Default: 0.
Examples:
json0
json1
json2
json3
json5
kafka_enable_dlq (boolean): A flag to toggle the dead letter queue. If set to False, the service will crash upon exhausting retries instead of publishing events to the DLQ. If set to True, the service will publish events to the DLQ topic after exhausting all retries. Default: false.
Examples:
jsontrue
jsonfalse
kafka_dlq_topic (string): The name of the topic used to resolve error-causing events. Default: "dlq".
Examples:
json"dlq"
kafka_retry_backoff (integer): The number of seconds to wait before retrying a failed event. The backoff time is doubled for each retry attempt. Minimum: 0. Default: 0.
Examples:
json0
json1
json2
json3
json5
mongo_dsn (string, format: multi-host-uri, required): MongoDB connection string. Might include credentials. For more information see: [***] Length must be at least 1.
Examples:
json"mongodb://localhost:27017"
db_name (string): the name of the database located on the MongoDB server. Default: "auth-db".
Examples:
json"auth-db"
json"user-management"
json"users-and-claims"
mongo_timeout: Timeout in seconds for API calls to MongoDB. The timeout applies to all steps needed to complete the operation, including server selection, connection checkout, serialization, and server-side execution. When the timeout expires, PyMongo raises a timeout exception. If set to None, the operation will not time out (default MongoDB behavior). Default: null.
Examples:
json300
json600
jsonnull
db_version_collection (string, required): The name of the collection containing DB version information for this service.
Examples:
json"ifrsDbVersions"
migration_wait_sec (integer, required): The number of seconds to wait before checking the DB version again.
Examples:
json5
json30
json180
migration_max_wait_sec: The maximum number of seconds to wait for migrations to complete before raising an error. Default: null.
Examples:
jsonnull
json300
json600
json3600
log_level (string): The minimum log level to capture. Must be one of: "CRITICAL", "ERROR", "WARNING", "INFO", "DEBUG", or "TRACE". Default: "INFO".
log_format: If set, will replace JSON formatting with the specified string format. If not set, has no effect. In addition to the standard attributes, the following can also be specified: timestamp, service, instance, level, correlation_id, and details. Default: null.
Examples:
json"%(timestamp)s - %(service)s - %(level)s - %(message)s"
json"%(asctime)s - Severity: %(levelno)s - %(msg)s"
log_traceback (boolean): Whether to include exception tracebacks in log messages. Default: true.
max_ivas (integer): Maximum number of IVAs a user can create per day and in total. Exclusive minimum: 0. Default: 5.
max_iva_verification_attempts (integer): Maximum number of verification attempts for an IVA. Exclusive minimum: 0. Default: 10.
max_iva_code_validity_days (integer): Maximum number of days an IVA verification code is valid. Exclusive minimum: 0. Default: 7.
max_iva_codes_per_day (integer): Maximum number of verification code requests per IVA and day. Exclusive minimum: 0. Default: 3.
auto_send_iva_code_for_types (array): IVA types for which verification codes are sent automatically. Default: ["Phone"].
totp_issuer (string): Issuer name for TOTP provisioning URIs. Default: "GHGA".
totp_image: URL of the PNG image provided in the TOTP provisioning URIs. Default: null.
Examples:
json"https://www.ghga.de/logo.png"
totp_algorithm: Refer to #/$defs/TOTPAlgorithm. Default: "sha1".
totp_digits (integer): Number of digits used for the TOTP code. Minimum: 6. Maximum: 12. Default: 6.
totp_interval (integer): Time interval in seconds for generating TOTP codes. Minimum: 10. Maximum: 300. Default: 30.
totp_tolerance (integer): Number of intervals to check before and after the current time. Minimum: 0. Maximum: 10. Default: 1.
totp_attempts_per_code (integer): Maximum number of attempts to verify an individual TOTP code. Minimum: 1. Maximum: 10. Default: 3.
totp_max_failed_attempts (integer): Maximum number of consecutive failed attempts to verify TOTP codes. Minimum: 1. Maximum: 100. Default: 10.
totp_secret_size (integer): Size of the Base32 encoded TOTP secrets. Minimum: 24. Maximum: 256. Default: 32.
totp_encryption_key: Base64 encoded key used to encrypt TOTP secrets. Default: null.
session_id_bytes (integer): Number of bytes to be used for a session ID. Default: 24.
csrf_token_bytes (integer): Number of bytes to be used for a CSRF token. Default: 24.
session_timeout_seconds (integer): Session timeout in seconds. Default: 3600.
session_max_lifetime_seconds (integer): Maximum lifetime of a session in seconds. Default: 43200.
auth_key: internal public key for the auth service (key pair for auth adapter). Default: null.
auth_algs (array): A list of all algorithms used for signing GHGA internal tokens. Default: ["ES256"].
auth_check_claims (object): A dict of all GHGA internal claims that shall be verified. Can contain additional properties. Default: {"id": null, "name": null, "email": null, "iat": null, "exp": null}.
auth_map_claims (object): A mapping of claims to attributes in the GHGA auth context. Can contain additional properties. Default: {}.
port (integer): Port to expose the server on the specified host. Default: 8080.
auto_reload (boolean): A development feature. Set to True to automatically reload the server upon code changes. Default: false.
workers (integer): Number of workers processes to run. Default: 1.
timeout_keep_alive (integer): The time in seconds to keep an idle connection open for subsequent requests before closing it. This value should be higher than the timeout used by any client or reverse proxy to avoid premature connection closures. Default: 90.
Examples:
json5
json90
json5400
api_root_path (string): Root path at which the API is reachable. This is relative to the specified host and port. Default: "".
openapi_url (string): Path to get the openapi specification in JSON format. This is relative to the specified host and port. Default: "/openapi.json".
docs_url (string): Path to host the swagger documentation. This is relative to the specified host and port. Default: "/docs".
cors_allowed_origins: A list of origins that should be permitted to make cross-origin requests. By default, cross-origin requests are not allowed. You can use ['*'] to allow any origin. Default: null.
Examples:
json[ "https://example.org", "https://www.example.org" ]
cors_allow_credentials: Indicate that cookies should be supported for cross-origin requests. Defaults to False. Also, cors_allowed_origins cannot be set to ['*'] for credentials to be allowed. The origins must be explicitly specified. Default: null.
Examples:
json[ "https://example.org", "https://www.example.org" ]
This README is longer than Docker Hub's 25000-character overview limit, so it has been cut short here. Read the rest on GitHub: https://github.com/ghga-de/ghga/blob/main/services/auth-service/README.md
您可以使用以下命令拉取该镜像。请将 <标签> 替换为具体的标签版本。如需查看所有可用标签版本,请访问 标签列表页面。
来自真实用户的反馈,见证轩辕镜像的优质服务