How to use the oic.oic.message.AuthorizationRequest function in oic

To help you get started, we’ve selected a few oic examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github OpenIDC / pyoidc / tests / test_sdb.py View on Github external
from oic.oic.message import OpenIDRequest
from oic.utils.sdb import AccessCodeUsed
from oic.utils.sdb import AuthnEvent
from oic.utils.sdb import Crypt
from oic.utils.sdb import DefaultToken
from oic.utils.sdb import DictRefreshDB
from oic.utils.sdb import ExpiredToken
from oic.utils.sdb import SessionDB
from oic.utils.sdb import WrongTokenType
from oic.utils.sdb import create_session_db
from oic.utils.session_backend import DictSessionBackend
from oic.utils.time_util import utc_time_sans_frac

__author__ = "rohe0002"

AREQ = AuthorizationRequest(
    response_type="code",
    client_id="client1",
    redirect_uri="http://example.com/authz",
    scope=["openid"],
    state="state000",
)

AREQN = AuthorizationRequest(
    response_type="code",
    client_id="client1",
    redirect_uri="http://example.com/authz",
    scope=["openid"],
    state="state000",
    nonce="something",
)
github OpenIDC / pyoidc / tests / test_oic.py View on Github external
def test_parse_authz_req(self):
        ar = AuthorizationRequest(
            response_type=["code"],
            client_id="foobar",
            redirect_uri="http://foobar.example.com/oaclient",
            state="cold",
            nonce="NONCE",
            scope=["openid"],
        )

        # query string
        uencq = ar.to_urlencoded()
        areq = self.srv.parse_authorization_request(query=uencq)

        assert isinstance(areq, AuthorizationRequest)
        assert areq["response_type"] == ["code"]
        assert areq["client_id"] == "foobar"
        assert areq["redirect_uri"] == "http://foobar.example.com/oaclient"
github OpenIDC / pyoidc / tests / test_oic_provider.py View on Github external
def test_refresh_token_grant_type_expired(self):
        authreq = AuthorizationRequest(
            state="state",
            redirect_uri="http://example.com/authz",
            client_id=CLIENT_ID,
            response_type="code",
            scope=["openid", "offline_access"],
            prompt="consent",
        )

        _sdb = self.provider.sdb
        sid = _sdb.access_token.key(user="sub", areq=authreq)
        access_grant = _sdb.access_token(sid=sid)
        ae = AuthnEvent("user", "salt")
        _sdb[sid] = {
            "oauth_state": "authz",
            "authn_event": ae.to_json(),
            "authzreq": authreq.to_json(),
github OpenIDC / pyoidc / tests / oic / utils / test_sdb.py View on Github external
import time

import pytest

import mock
from oic.utils.time_util import utc_time_sans_frac
from oic.utils.sdb import SessionDB, AuthnEvent, Token, WrongTokenType, Crypt, \
    AccessCodeUsed
from oic.utils.sdb import ExpiredToken
from oic.oic.message import AuthorizationRequest
from oic.oic.message import OpenIDRequest
from utils_for_tests import _eq

__author__ = 'rohe0002'

AREQ = AuthorizationRequest(response_type="code", client_id="client1",
                            redirect_uri="http://example.com/authz",
                            scope=["openid"], state="state000")

AREQN = AuthorizationRequest(response_type="code", client_id="client1",
                             redirect_uri="http://example.com/authz",
                             scope=["openid"], state="state000",
                             nonce="something")

OIDR = OpenIDRequest(response_type="code", client_id="client1",
                     redirect_uri="http://example.com/authz", scope=["openid"],
                     state="state000")


class TestToken(object):
    @pytest.fixture(autouse=True)
    def create_token(self):
github OpenIDC / pyoidc / tests / test_oic_provider.py View on Github external
def test_verify_redirect_uri_faulty_without_query(self, uri):
        rr = RegistrationRequest(
            operation="register",
            redirect_uris=["http://example.org/cb"],
            response_types=["code"],
        )
        registration_req = rr.to_json()

        resp = self.provider.registration_endpoint(request=registration_req)
        regresp = RegistrationResponse().from_json(resp.message)
        cid = regresp["client_id"]

        areq = AuthorizationRequest(
            redirect_uri=uri, client_id=cid, response_type="code", scope="openid"
        )

        with pytest.raises(RedirectURIError):
            self.provider._verify_redirect_uri(areq)
github OpenIDC / pyoidc / tests / test_sdb.py View on Github external
client_id="client1",
    redirect_uri="http://example.com/authz",
    scope=["openid"],
    state="state000",
)

AREQN = AuthorizationRequest(
    response_type="code",
    client_id="client1",
    redirect_uri="http://example.com/authz",
    scope=["openid"],
    state="state000",
    nonce="something",
)

AREQO = AuthorizationRequest(
    response_type="code",
    client_id="client1",
    redirect_uri="http://example.com/authz",
    scope=["openid", "offlien_access"],
    prompt="consent",
    state="state000",
)

OIDR = OpenIDRequest(
    response_type="code",
    client_id="client1",
    redirect_uri="http://example.com/authz",
    scope=["openid"],
    state="state000",
)
github OpenIDC / pyoidc / tests / utils / test_authn_client.py View on Github external
def test_basic_authn_client_ok(self):
        authn = "Basic " + b64encode(b"number5:drickyoughurt").decode()
        assert get_client_id(self.cdb, AuthorizationRequest(), authn)
github OpenIDC / pyoidc / src / oic / oic / pop / TestPoPProvider.py View on Github external
def _authz_req(self):
        req_args = {"scope": ["openid", "profile"],
                    "redirect_uri": "http://localhost:8087/authz",
                    "response_type": ["code"],
                    "client_id": "client1"
                    }
        areq = AuthorizationRequest(**req_args)
        resp = self.provider.authorization_endpoint(areq.to_urlencoded())

        return AuthorizationResponse().deserialize(
            urlparse(resp.message).query, "urlencoded")
github IdentityPython / SATOSA / src / satosa / frontends / openid_connect.py View on Github external
def _get_authn_request_from_state(self, state):
        """
        Extract the clietns request stoed in the SATOSA state.
        :type state: satosa.state.State
        :rtype: oic.oic.message.AuthorizationRequest

        :param state: the current state
        :return: the parsed authentication request
        """
        return AuthorizationRequest().deserialize(state[self.name]["oidc_request"])