Light OpenID
Lightweight OpenID primitives & client. This package can be used to turn an application into an OpenID relying party.
Warning ! This crate has not been audited, use at your own risks!
It is your responsibility to implement the routes (start & finish authentication) that interacts with the
OpenIDConfig
helper structure.Moreover, only a very small subset of OpenID specifications are supported :
code
authorization flow- The scopes
openid profile email
are hard coded and cannot be changed- User info retrieval using
userinfo
endpoint
Basic usage
let config = load_from_url.await.unwrap;
// Start authentication
let auth_url = config.gen_authorization_url;
redirect_user;
// Finish authentication
let token_response = config.request_token.await.unwrap;
let user_info = config.request_user_info.await.unwrap;
// user_info now contains profile info of user
Feature crypto-wrapper
CryptoWrapper
is a helper that can encrypt to base64-encoded string structures:
;
fun test
Note : In order to use
CryptoWrapper
on your own, you must addbincode>=2.0
as one of your own dependencies. This is not required if you decide useBasicStateManager
.
BasicStateManager
is a helper that uses CryptoWrapper
to generate and validates states for OpenID authentication:
let ip = V4;
let manager = new;
let state = manager.gen_state.unwrap;
assert!;
Complete example
A complete example usage of this crate can be found here: https://gitea.communiquons.org/pierre/oidc-test-client