https://github.com/maxgoedjen/simple_openid
Simple OpenID. One-line setup for OpenID login for Flask.
https://github.com/maxgoedjen/simple_openid
Last synced: about 1 month ago
JSON representation
Simple OpenID. One-line setup for OpenID login for Flask.
- Host: GitHub
- URL: https://github.com/maxgoedjen/simple_openid
- Owner: maxgoedjen
- Created: 2013-03-26T02:52:27.000Z (about 12 years ago)
- Default Branch: master
- Last Pushed: 2013-04-11T19:37:22.000Z (about 12 years ago)
- Last Synced: 2025-03-06T12:07:47.764Z (about 2 months ago)
- Language: Python
- Size: 133 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Simple OpenID
*One line OpenID login for Flask*## Setup
Import the module:
`from simple_openid import SimpleOpenID`
Configure it:
`openid = SimpleOpenID(app, 'YOUR_APP_SECRET')`
### Arguments
#### Required
- `app` - Your Flask App
- `secret` - Flask App secret#### Optional
- `valid_domain` - Domains to restrict login to. Defaults to `''`, which allows login with emails from any domain.
- `login_url` - URL to your login page. This page should contain a link to `/login_redirect`. Defaults to `login.html`
- `openid_url` - Auth URL for OpenID provider. Defaults to Google.## Use
### Restricting Login
To restrict access to a page, use the `require_login` decorator.
Example:
@app.route('/hello')
@openid.require_login
def main():
return 'Hello World'Access user info with the `user_realname` and `user_email` properties.
@app.route('/hello')
@openid.require_login
def main():
return '{email}, {realname}'.format(email=openid.user_email, realname=openid.user_realname