Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Redirection of OAuth2 response to any URL.

License

NotificationsYou must be signed in to change notification settings

czetech/oauthuri

Repository files navigation

OAuthURI solves the problem if the OAuth2 authorization provider does not allowto use the redirect URI that is needed, e.g. localhost, mobile app deep linking,or an HTTP scheme for testing purposes.

How it works

URL of the OAuthURI instance is set to the allowed redirect URIs of the OAuth2provider. The JSON string must be used as thestate parameter, where inaddition to the originalstate data, there are the keysredirect_uri withthe final URL andresponse_mode with the final mode (query,fragment orform_post). OAuthURI simply redirects the request further to the URL from theparameters.

Example of OAuth2 request:

{"scope":"<scope>","client_id":"<client ID>","redirect_uri":"https://<OAuthURI host>/redirect","state":"{\"redirect_uri\":\"myapp://deeplink\",\"state\":\"<state data>\"}"}

The response from OAuth2 provider to OAuthURI can be aquery,fragment, orform_post.

Configuration

There are several configuration variables:

NameDescriptionDefault value
redirectUriDefault redirect URI valuenull
responseModeDefault response mode value"query"
keyRedirectUriKey to redirect URI instate JSON"redirect_uri"
keyResponseModeKey to response mode instate JSON"response_mode"

SeeUsage options on how to use them.

Usage options

The application is a static web page where the response from OAuth2 providermust point toredirect.html and the configuration is in theconfig.jsonfile.

OAuthURI can also be used as a JavaScript library.

Use as a service

Application is deployed athttps://oauthuri.cze.tech. The URL for responsefrom OAuth2 provider is:

https://oauthuri.cze.tech/redirect

Feel free to use the service for testing or simple production purposes.

Build from code

Requirements:

Build is done with:

make

then the output is in the./build/web directory. The web server must redirectPOST requests to the GET and send the data as a query string (see the Nginxconfiguration example indocker-nginx.conf).

The Dockerfile and Helm chart are also part of this repository so it can beeasily build and deployed to Kubernetes.

Run from Docker Hub

Run the image from Docker Hub:

docker run -p 80:80 czetech/oauthuri

The endpoint for a response from OAuth2 provider is/redirect. The image can beconfigured usingconfig.json file mounted to/app/config.json.

Install to Kubernetes using Helm

Setup Helm repository:

helm repo add czetech https://charts.cze.tech/

Install Helm chart:

helm install oauthuri czetech/oauthuri \  --set ingress.enabled=true \  --set ingress.hosts[0]=<ingress-host>

see thechart for more options.

As in the Docker image, the endpoint for a response from OAuth2 provider is/redirect. Configuration variables can be passed to the Helm chart.

Library

OAuthURI as a JavaScript front-end library is available as npm packageoauthuri.

It is installed with:

npm install oauthuri

Or it is possible to use UMD module from the CDN:

<scriptsrc="https://unpkg.com/oauthuri"></script>

Usage:

constoAuthURI=newOAuthURI(redirectUri,responseMode,keyRedirectUri,keyResponseMode);oAuthURI.redirect();

Source code

The source code is available athttps://github.com/czetech/oauthuri.


[8]ページ先頭

©2009-2025 Movatter.jp