外观
lib-certAuth 库参考
原文: https://finproducts.atlassian.net/wiki/spaces/JIDD3/pages/34793226291/FIN+5.3.1+lib-certAuth 中文整理基于 FIN 5.3.1
导读: TLS 客户端证书认证模块
以下为 API 参考,保留英文以便对照源码;目录已列出(英文标题便于检索);概述已尽量中译。
目录(导读)
- lib
- meta
- docs
- tags
- views
- def
- supertypes
- Overview
- Setup
- Using Certificate Authentication
- Certificate Auth Settings
- HTTPS Key Pair
- Use Cases
- Using a Reverse Proxy
- HAProxy
- Nginx
- tags
- src
概述(中译)
TLS 客户端证书认证模块
API 正文(英文)
docs
Overview • Setup • Using Certificate Authentication • Use Cases • Using a Reverse Proxy
tags
| certificatePem | PEM encoding of the User Certificate |
| userCertificate | A user certificate |
views
| certAuthConfig | Upload user certificates to configure certificate authentication |
| certAuthSettings | Settings for the Client Certificate Authentication module |
def
certificatePem
PEM encoding of the User Certificate.
meta
| def | certificatePem |
| is | str |
| lib | lib:certAuth |
| tagOn | userCertificate |
supertypes
| val | Data value type |
| scalar | Scalar is an atomic value kind |
| str | Unicode string of characters |
lib certAuth
Overview
The Certificate Authentication (certAuth) AuthMod enables TLS Client Certificate Authentication to SkySpark. This allows users to skip the standard SkySpark username/password login page and use a certificate to authenticate. In order to use Certificate Authentication, SkySpark users must already be connecting to SkySpark over HTTPS (either using the internal HTTPS server or by using a reverse proxy).
The Settings|Certificate Auth view allows configuration of the Certificate Auth settings.
Setup
The following steps are required to use Certificate authentication:
- Enable the certAuth SysMod from the
Host|SysModsview - Configure the required Certificate Auth Settings (see Certificate Auth Settings)
- Add a certificate key pair to the SkySpark Trust Store (see HTTPS Key Pair)
- Change the
userAuthtag for one or more local SkySpark users toAuthMod - certAuth - Upload one or more user public certificates using the
User|User Certificate Configview - Assign uploaded certificate to a SkySpark user configured for Certificate Authentication
- Users must access a specific path to authenticate (see Using Certificate Authentication)
IMPORTANT: User's must have their certificate loaded on their system so that the web browser allows the user to select their certificate for authentication.
Using Certificate Authentication
After completing the Certificate Auth setup instructions, SkySpark will be listening for connections on the configured certAuthPort. Users that access SkySpark through a web browser will still see the standard login page when they navigate to the SkySpark Server Url (unless the certAuth/ path is accessed directly). Users can click the Certificate Login link or access the certAuth/ path directly by typing it in the address bar to login with their certificate. The browser will be redirected to the configured certAuthPort and the user will be prompted to select their certificate. Most browsers will cache the selected certificate so user's may not be prompted to select a certificate on subsequent logins. After the TLS session is established the browser will be automatically redirected back to SkySpark and logged in. Review the user cases section for additional information on using certificate authentication.
IMPORTANT: SkySpark will not automatically create users when a certificate authentication login attempt is made. User records must be created before logging in, the userAuth tag must be set to AuthMod - certAuth and the user's public certificate must be uploaded and assigned to the user record.
Certificate Auth Settings
After enabling the certAuth SysMod on the Host|SysMods view, navigate to Settings|Certificate Auth view.
The only required setting is certAuthPort. SkySpark will open another listening port to handle certificate authentication. This port must be configured for HTTPS so it requires a key pair. Ensure the configured port does not conflict with the standard SkySpark HTTP or HTTPS port.
- addr - Optional setting. If the SkySpark server has multiple IP addresses assigned, only listen for connections to this IP address.
- certAuthPort - Required setting. The local port SkySpark will listen on for Certificate Auth logins.
- useReverseProxy - If users connect to SkySpark through a reverse proxy, set this setting to true. Review the Using a Reverse Proxy section.
- certAuthProxyPort - Required setting if useReverseProxy set to true. The port the reverse proxy server is listening on for client certificate authentication.
- displayCertificateLogin - Add a
Certificate Loginlink to the SkySpark login page. This makes it easier to login with a certificate, but users that don't have their browser configured properly will get an error if they click the link. - supportText - Optional setting. Fandoc formatted text that will display on certAuth/authFailed page that can be used to help users troubleshoot login issues.
HTTPS Key Pair
Follow the standard SkySpark instructions to load an HTTPS key pair if SkySpark is not already using HTTPS for its standard login. If desired, a different key pair can be loaded for the certificate authentication port using the alias certauth.
Use Cases
The primary use case that drove the design of this feature, was offering a login option that did not depend on passwords. Configuring users with the su userRole to use certificate authentication can mitigate the security problems associated with passwords and will allow organizations that already use certificates for secure logins to other applications to leverage their existing investment in their Public Key Infrastructure (PKI) for SkySpark logins.
A secondary use case was to allow authentication to the SkySpark REST API from client libraries that do not support Haystack Authentication. Now if a client library connects directly to <server>:certAuthPort/token and performs client certificate authentication, the authToken will be returned in the Authentication-Info header that can be reused for API requests sent to the standard SkySpark listening port by setting the Authorization header as shown below:
Authorization: BEARER authToken=web-LYF0...Using a Reverse Proxy
If SkySpark is running behind a reverse proxy, the reverse proxy must support passing through the TLS session to the SkySpark certAuthPort without terminating the TLS session. This may be referred to as a TLS Passthrough Proxy or a straight TCP proxy which will proxy TLS connections as-is without decrypting and re-encrypting.
HAProxy
HAProxy can be configured as a straight TCP proxy by using mode tcp. An example configuration is shown below where the IP address and ports need to be updated to match the local configuration:
frontend localhost_Passthrough
mode tcp
bind *:{certAuthProxyPort}
default_backend TLS_Passthrough
backend TLS_Passthrough
mode tcp
server MyServer xxx.xxx.xxx.xxx:{certAuthPort}Nginx
Nginx supports a passthrough feature by embedding a server directive in the stream directive. The stream directive cannot exist within an http directive. An example configuration is shown below where the IP address and ports need to be updated to match the local configuration:
stream {
server {
listen {certAuthProxyPort};
listen [::]:{certAuthProxyPort};
proxy_pass xxx.xxx.xxx.xxx:{certAuthPort};
}
}def
userCertificate
A user certificate. Identifies a public certificate used for user login with the Certificate Authentication SysMod.
meta
| def | userCertificate |
| icon | user |
| is | entity |
| lib | lib:certAuth |
| mandatory | ✓ |
supertypes
| marker | Marker labels a dict with typing information |
| entity | Top-level dicts with a unique identifier |
tags
| certificatePem | PEM encoding of the User Certificate |
| dis | Display name for an entity |
| id | Defines the unique identifier of an entity in system using a ref value type |
| userRef | Reference to user entity |
def
view:certAuthConfig
Upload user certificates to configure certificate authentication
meta
| appName | users |
| def | view:certAuthConfig |
| dis | User Certificate Config |
| icon | view |
| is | view |
| lib | lib:certAuth |
| order | 900 |
| su | ✓ |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| view | Fresco UI view |
src
view: { inherit:"table" }
upload: { disKey:"ui::upload" action:"certAuthMod::CertUploadAction.onUpload" }
assign: { disKey:"certAuthMod::certAuth.assignUser" action:"certAuthMod::CertAssignAction.onAssign" select }
delete: { action:"certAuthDelete" }
data: { expr:"certAuthReadAll()" }def
view:certAuthSettings
Settings for the Client Certificate Authentication module
meta
| appName | settings |
| def | view:certAuthSettings |
| disKey | certAuthMod::certAuthSettings |
| icon | view |
| is | view |
| lib | lib:certAuth |
| su | ✓ |
supertypes
| feature | Feature namespace of definitions formatted as feature:name |
| view | Fresco UI view |
src
view: {inherit:"form"}
submit: {action:"hostCommit"}
validate: {action:"certAuthValidateConfig"}
data: {expr:"hostSettings(\"certAuth\")"}