Git Product home page Git Product logo

mod_sts's Introduction

Build Status

mod_sts

A security token exchange module for Apache HTTP Server 2.x which allows for exchanging arbitrary security tokens by calling into a remote Security Token Service (STS).

Overview

This Apache module allows for exchanging a security token (aka. "source token") that is presented on an incoming HTTP request for another security token (aka. "target token") by calling into a Security Token Service (STS) and then include that target token on the propagated HTTP request to the content or origin server.

This can be used in scenario's where an Apache server is put in front of a backend service as a Reverse Proxy/Gateway that handles tokens presented by external clients but needs to forward those requests using some internal security token format, acting as an internal client to the backend service. Note that the backend service can also be an application that is hosted on the Apache server itself, e.g. a PHP application.

Rationale

The split between external tokens and internal tokens may be enforced for security reasons i.e. separating external requests from internal requests/tokens whilst keeping "on-behalf-of-a-user" semantics, or for legacy reasons i.e. when your backend only supports consuming a proprietary/legacy token format/protocol and you don't want to enforce support for that legacy onto your external clients (or vice versa).

Tokens

Source

An source (or: incoming) token can be presented in a header (e.g. an Authorization: bearer header for OAuth 2.0 bearer access tokens), a query parameter or a cookie. Alternatively the token can be consumed from an environment variable set by a another Apache (authentication) module such as a validated access token set by mod_oauth2 operating as an OAuth 2.0 Resource Server.

Sample supported - incoming/external - source tokens:

  • an OAuth 2.0 bearer access token presented by an external OAuth 2.0 Client
  • a generic JWT presented in a header or query parameter
  • a generic cookie
  • a vendor specific token - e.g. an OpenToken produced by PingFederate - or a vendor specific cookie such as an SSO cookie produced by CA SiteMinder or Oracle Access Manager
Target

A target (or: outgoing) token can be appended in a header (e.g. an Authorization: bearer header for OAuth 2.0 bearer access tokens), a query parameter or a cookie but the token can also be set as an environment variable so it can be consumed by another Apache module or by an application that is served from the Apache server, e.g. a PHP application.

Sample supported - outgoing/internal - target tokens:

  • an OAuth 2.0 bearer access token, scoped to an internal service security domain
  • a generic JWT put in a header
  • a generic cookie
  • a vendor specific token - e.g. an OpenToken produced by PingFederate - or a vendor specific cookie such as an SSO cookie produced by CA SiteMinder or Oracle Access Manager

Security Token Service Protocols

This module supports a number of different protocols for interfacing with a Security Token Service:

WS-Trust

XML/SOAP based OASIS standard, see: https://en.wikipedia.org/wiki/WS-Trust

OAuth 2.0 Token Exchange

REST/OAuth 2.0 based IETF standard RFC 8693, see: https://tools.ietf.org/html/rfc8693

OAuth 2.0 Resource Owner Password Credentials (ROPC)

Essentially a workaround for communicating with servers that don't support any of the two options above but can be configured/programmed to validate a token presented in the password parameter of the OAuth 2.0 Resource Owner Password Credentials grant and return a target token in the access token claim of the token response.

OAuth 2.0 Client Credentials (CC)

This leverages the OAuth 2.0 Client Credentials grant type but does not actually require a source token. Instead the configured client credentials are used as a bootstrapping mechanism to obtain an OAuth 2.0 access token that can be used to authenticate the service towards the backend.

Quickstart

WS-Trust STS using HTTP Basic authentication.

LogLevel sts:debug

<Location /sts/wstrust>	
	STSExchange wstrust https://pingfed:9031/pf/sts.wst \
auth=basic&username=wstrust&password=2Federate&\
applies_to=urn:pingfed&\
value_type=urn:pingidentity.com:oauth2:grant_type:validate_bearer&\
token_type=urn:bogus:token&\
ssl_verify=false

	ProxyPass http://echo:8080
	ProxyPassReverse http://echo:8080
</Location>

OAuth 2.0 Resource Owner Password Credentials based STS using client_secret_basic authentication.

LogLevel sts:debug

<Location /sts/ropc>
	STSExchange ropc https://pingfed:9031/as/token.oauth2 \
auth=client_secret_basic&\
client_id=sts0&\
client_secret=2Federate&\
username=dummy&\
ssl_verify=false

	ProxyPass http://echo:8080
	ProxyPassReverse http://echo:8080
</Location>

OAuth 2.0 Client Credentials token retrieval using client_secret_basic authentication.

LogLevel sts:debug

<Location /sts/cc>
	SetEnvIfExpr true dummy=dummy
	STSAcceptSourceTokenIn environment name=dummy
	STSPassTargetTokenIn header
	STSExchange cc https://keycloak:8443/realms/master/protocol/openid-connect/token \
auth=client_secret_basic&\
client_id=cc_client&\
client_secret=mysecret&\
ssl_verify=false

	ProxyPass http://echo:8080
	ProxyPassReverse http://echo:8080
</Location>

OAuth 2.0 Token Exchange using client_secret_basic authentication.

LogLevel sts:debug

<Location /sts/otx>
	STSExchange otx https://keycloak:8443/auth/realms/master/protocol/openid-connect/token \
auth=client_secret_basic&\
client_id=otxclient&\
client_secret=2Federate&\
ssl_verify=false

	ProxyPass http://echo:8080
	ProxyPassReverse http://echo:8080
</Location>

For a detailed overview of configuration options see the sts.conf Apache configuration file in this directory.

Support

Community Support

For generic questions, see the Wiki pages with Frequently Asked Questions at:
https://github.com/OpenIDC/mod_sts/wiki
Any questions/issues should go to issues tracker.

Commercial Services

For commercial Support contracts, Professional Services, Training and use-case specific support you can contact:
[email protected]

Disclaimer

This software is open sourced by OpenIDC. For commercial support you can contact OpenIDC as described above in the Support section.

mod_sts's People

Contributors

zandbelt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

mod_sts's Issues

mod_sts with mod_openid

Hello,

I am trying to enable mod_stsfor apache with mod_oidc.

For now I have the following config in apache for OIDC :

OIDCClientID 'xxxxxxxxxx'
    OIDCPublicKeyFiles xxxxxxxxxx#/xxxxxxxxxx/client_sign.pem xxxxxxxxxx#/xxxxxxxxxx/client_enc.pem
    OIDCPrivateKeyFiles xxxxxxxxxx#/xxxxxxxxxx/client_sign.key xxxxxxxxxx#/xxxxxxxxxx/client_enc.key
    OIDCProviderMetadataURL https://xxxxxx/auth/realms/xxxxx/.well-known/openid-configuration
    OIDCProviderTokenEndpointAuth private_key_jwt
    OIDCCryptoPassphrase 'xxxxxx'
    OIDCRedirectURI https://xxxxx/redirect_uri
    OIDCSSLValidateServer On

    OIDCUserInfoSignedResponseAlg RS256
    OIDCIDTokenSignedResponseAlg RS256
    OIDCIDTokenEncryptedResponseEnc A256GCM
    OIDCIDTokenEncryptedResponseAlg RSA-OAEP

    OIDCIDTokenIatSlack 60
    OIDCStateTimeout 30
    OIDCPassRefreshToken On
    OIDCRemoteUserClaim preferred_username

    OIDCScope "openid email profile"

    <Location "/oidc/jwks.json">
        Alias /xxxxxxxxxx/jwks.json
        Satisfy Any
        Allow from all
        AuthType None
        Require all granted
    </Location>

    # Replace OIDC location
    <Location "/">
        LogLevel sts:debug
        AuthType openid-connect
        Require valid-user
        SetEnvIf OIDC_access_token "(.+)" access_token=$1

        STSExchange otx https://xxxxxxxxxx/auth/realms/xxxxxxxxxx/protocol/openid-connect/token \
auth=private_key_jwt&\
client_id=xxxxxxxxxx&\
jwk=JWKKEY&\
aud=https://xxxxxxxxxx/auth/realms/xxxxxxxxxx

    </Location>

In my apache log i get the following :

<snip>
[Fri Apr 09 09:12:31.062683 2021] [sts:debug] [pid 66] src/http.c(158): [client 1.2.3.4:58854] _oauth2_http_request_header_set_add_sanitized: OIDC_CLAIM_nonce: xxxxxxxxxx
[Fri Apr 09 09:12:31.062694 2021] [sts:debug] [pid 66] src/http.c(158): [client 1.2.3.4:58854] _oauth2_http_request_header_set_add_sanitized: OIDC_CLAIM_session_state: xxxxxxxxxx
[Fri Apr 09 09:12:31.062706 2021] [sts:debug] [pid 66] src/http.c(158): [client 1.2.3.4:58854] _oauth2_http_request_header_set_add_sanitized: OIDC_CLAIM_at_hash: xxxxxxxxxx
[Fri Apr 09 09:12:31.062719 2021] [sts:debug] [pid 66] src/http.c(158): [client 1.2.3.4:58854] _oauth2_http_request_header_set_add_sanitized: OIDC_CLAIM_acr: 0
[Fri Apr 09 09:12:31.062761 2021] [sts:debug] [pid 66] src/http.c(158): [client 1.2.3.4:58854] _oauth2_http_request_header_set_add_sanitized: OIDC_refresh_token: xxxxxxxxxx
[Fri Apr 09 09:12:31.062809 2021] [sts:debug] [pid 66] src/http.c(158): [client 1.2.3.4:58854] _oauth2_http_request_header_set_add_sanitized: OIDC_access_token: xxxxxxxxxx
[Fri Apr 09 09:12:31.062858 2021] [sts:debug] [pid 66] src/http.c(158): [client 1.2.3.4:58854] _oauth2_http_request_header_set_add_sanitized: OIDC_access_token_expires: 1617989756
[Fri Apr 09 09:12:31.062873 2021] [sts:debug] [pid 66] src/http.c(158): [client 1.2.3.4:58854] _oauth2_http_request_header_set_add_sanitized: REMOTE_USER: xxxxxxxxxx
[Fri Apr 09 09:12:31.062884 2021] [sts:debug] [pid 66] src/server/apache.c(280): [client 1.2.3.4:58854] oauth2_apache_request_context_init: created request context: 0x56189d8b7bb0
[Fri Apr 09 09:12:31.062896 2021] [sts:debug] [pid 66] src/mod_sts.c(52): [client 1.2.3.4:58854] sts_check_access_handler: enter: "/?(null)", ap_is_initial_req(r)=1
[Fri Apr 09 09:12:31.062905 2021] [sts:debug] [pid 66] src/liboauth2-sts/src/sts.c(704): [client 1.2.3.4:58854] sts_request_handler: enter
[Fri Apr 09 09:12:31.062924 2021] [sts:debug] [pid 66] src/proto.c(212): [client 1.2.3.4:58854] _oauth2_get_source_token_from_envvar: enter
[Fri Apr 09 09:12:31.062934 2021] [sts:debug] [pid 66] src/server/apache.c(491): [client 1.2.3.4:58854] oauth2_apache_get_envvar: get environment variable: access_token
[Fri Apr 09 09:12:31.062944 2021] [sts:debug] [pid 66] src/proto.c(226): [client 1.2.3.4:58854] _oauth2_get_source_token_from_envvar: no source token found in access_token environment variable

Do you have any idea to rename the OIDC_access_token variable as access_token variable ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.