Exemplo n.º 1
0
def register_blueprint(application):
    from app.service.rest import service_blueprint
    from app.service.callback_rest import service_callback_blueprint
    from app.service.sms_sender_rest import service_sms_sender_blueprint
    from app.user.rest import user_blueprint
    from app.template.rest import template_blueprint
    from app.status.healthcheck import status as status_blueprint
    from app.job.rest import job_blueprint
    from app.notifications.rest import notifications as notifications_blueprint
    from app.invite.rest import invite as invite_blueprint
    from app.accept_invite.rest import accept_invite
    from app.template_statistics.rest import template_statistics as template_statistics_blueprint
    from app.events.rest import events as events_blueprint
    from app.provider_details.rest import provider_details as provider_details_blueprint
    from app.email_branding.rest import email_branding_blueprint
    from app.api_key.rest import api_key_blueprint
    from app.inbound_number.rest import inbound_number_blueprint
    from app.inbound_sms.rest import inbound_sms as inbound_sms_blueprint
    from app.notifications.notifications_govdelivery_callback import govdelivery_callback_blueprint
    from app.authentication.auth import (
        validate_admin_auth, validate_service_api_key_auth,
        do_not_validate_auth,
        create_validator_for_admin_auth_or_user_in_service)
    from app.letters.rest import letter_job
    from app.billing.rest import billing_blueprint
    from app.organisation.rest import organisation_blueprint
    from app.organisation.invite_rest import organisation_invite_blueprint
    from app.complaint.complaint_rest import complaint_blueprint
    from app.platform_stats.rest import platform_stats_blueprint
    from app.template_folder.rest import template_folder_blueprint
    from app.letter_branding.letter_branding_rest import letter_branding_blueprint
    from app.oauth.rest import oauth_blueprint

    application.register_blueprint(service_blueprint, url_prefix='/service')

    user_blueprint.before_request(validate_admin_auth)
    application.register_blueprint(user_blueprint, url_prefix='/user')

    template_blueprint.before_request(
        create_validator_for_admin_auth_or_user_in_service('manage_templates'))
    application.register_blueprint(template_blueprint)

    status_blueprint.before_request(do_not_validate_auth)
    application.register_blueprint(status_blueprint)

    oauth_blueprint.before_request(do_not_validate_auth)
    application.register_blueprint(oauth_blueprint)

    govdelivery_callback_blueprint.before_request(do_not_validate_auth)
    application.register_blueprint(govdelivery_callback_blueprint)

    notifications_blueprint.before_request(validate_service_api_key_auth)
    application.register_blueprint(notifications_blueprint)

    job_blueprint.before_request(validate_admin_auth)
    application.register_blueprint(job_blueprint)

    invite_blueprint.before_request(validate_admin_auth)
    application.register_blueprint(invite_blueprint)

    inbound_number_blueprint.before_request(validate_admin_auth)
    application.register_blueprint(inbound_number_blueprint)

    inbound_sms_blueprint.before_request(validate_admin_auth)
    application.register_blueprint(inbound_sms_blueprint)

    accept_invite.before_request(validate_admin_auth)
    application.register_blueprint(accept_invite, url_prefix='/invite')

    template_statistics_blueprint.before_request(validate_admin_auth)
    application.register_blueprint(template_statistics_blueprint)

    events_blueprint.before_request(validate_admin_auth)
    application.register_blueprint(events_blueprint)

    provider_details_blueprint.before_request(validate_admin_auth)
    application.register_blueprint(provider_details_blueprint,
                                   url_prefix='/provider-details')

    email_branding_blueprint.before_request(validate_admin_auth)
    application.register_blueprint(email_branding_blueprint,
                                   url_prefix='/email-branding')

    api_key_blueprint.before_request(validate_admin_auth)
    application.register_blueprint(api_key_blueprint, url_prefix='/api-key')

    letter_job.before_request(validate_admin_auth)
    application.register_blueprint(letter_job)

    billing_blueprint.before_request(validate_admin_auth)
    application.register_blueprint(billing_blueprint)

    service_callback_blueprint.before_request(validate_admin_auth)
    application.register_blueprint(service_callback_blueprint)

    application.register_blueprint(service_sms_sender_blueprint)

    organisation_blueprint.before_request(validate_admin_auth)
    application.register_blueprint(organisation_blueprint,
                                   url_prefix='/organisations')

    organisation_invite_blueprint.before_request(validate_admin_auth)
    application.register_blueprint(organisation_invite_blueprint)

    complaint_blueprint.before_request(validate_admin_auth)
    application.register_blueprint(complaint_blueprint)

    platform_stats_blueprint.before_request(validate_admin_auth)
    application.register_blueprint(platform_stats_blueprint,
                                   url_prefix='/platform-stats')

    template_folder_blueprint.before_request(validate_admin_auth)
    application.register_blueprint(template_folder_blueprint)

    letter_branding_blueprint.before_request(validate_admin_auth)
    application.register_blueprint(letter_branding_blueprint)
Exemplo n.º 2
0
def register_blueprint(application):
    from app.accept_invite.rest import accept_invite
    from app.api_key.rest import api_key_blueprint
    from app.authentication.auth import (
        requires_admin_auth,
        requires_auth,
        requires_no_auth,
    )
    from app.billing.rest import billing_blueprint
    from app.complaint.complaint_rest import complaint_blueprint
    from app.email_branding.rest import email_branding_blueprint
    from app.events.rest import events as events_blueprint
    from app.inbound_number.rest import inbound_number_blueprint
    from app.inbound_sms.rest import inbound_sms as inbound_sms_blueprint
    from app.invite.rest import invite as invite_blueprint
    from app.job.rest import job_blueprint
    from app.letter_branding.letter_branding_rest import letter_branding_blueprint
    from app.letters.rest import letter_job
    from app.notifications.notifications_letter_callback import (
        letter_callback_blueprint,
    )
    from app.notifications.rest import notifications as notifications_blueprint
    from app.organisation.invite_rest import organisation_invite_blueprint
    from app.organisation.rest import organisation_blueprint
    from app.platform_stats.rest import platform_stats_blueprint
    from app.provider_details.rest import provider_details as provider_details_blueprint
    from app.service.callback_rest import service_callback_blueprint
    from app.service.rest import service_blueprint
    from app.status.healthcheck import status as status_blueprint
    from app.template.rest import template_blueprint
    from app.template_folder.rest import template_folder_blueprint
    from app.template_statistics.rest import (
        template_statistics as template_statistics_blueprint,
    )
    from app.user.rest import user_blueprint

    service_blueprint.before_request(requires_admin_auth)
    application.register_blueprint(service_blueprint, url_prefix="/service")

    user_blueprint.before_request(requires_admin_auth)
    application.register_blueprint(user_blueprint, url_prefix="/user")

    template_blueprint.before_request(requires_admin_auth)
    application.register_blueprint(template_blueprint)

    status_blueprint.before_request(requires_no_auth)
    application.register_blueprint(status_blueprint)

    notifications_blueprint.before_request(requires_auth)
    application.register_blueprint(notifications_blueprint)

    job_blueprint.before_request(requires_admin_auth)
    application.register_blueprint(job_blueprint)

    invite_blueprint.before_request(requires_admin_auth)
    application.register_blueprint(invite_blueprint)

    inbound_number_blueprint.before_request(requires_admin_auth)
    application.register_blueprint(inbound_number_blueprint)

    inbound_sms_blueprint.before_request(requires_admin_auth)
    application.register_blueprint(inbound_sms_blueprint)

    accept_invite.before_request(requires_admin_auth)
    application.register_blueprint(accept_invite, url_prefix="/invite")

    template_statistics_blueprint.before_request(requires_admin_auth)
    application.register_blueprint(template_statistics_blueprint)

    events_blueprint.before_request(requires_admin_auth)
    application.register_blueprint(events_blueprint)

    provider_details_blueprint.before_request(requires_admin_auth)
    application.register_blueprint(provider_details_blueprint, url_prefix="/provider-details")

    email_branding_blueprint.before_request(requires_admin_auth)
    application.register_blueprint(email_branding_blueprint, url_prefix="/email-branding")

    api_key_blueprint.before_request(requires_admin_auth)
    application.register_blueprint(api_key_blueprint, url_prefix="/api-key")

    letter_job.before_request(requires_admin_auth)
    application.register_blueprint(letter_job)

    letter_callback_blueprint.before_request(requires_no_auth)
    application.register_blueprint(letter_callback_blueprint)

    billing_blueprint.before_request(requires_admin_auth)
    application.register_blueprint(billing_blueprint)

    service_callback_blueprint.before_request(requires_admin_auth)
    application.register_blueprint(service_callback_blueprint)

    organisation_blueprint.before_request(requires_admin_auth)
    application.register_blueprint(organisation_blueprint, url_prefix="/organisations")

    organisation_invite_blueprint.before_request(requires_admin_auth)
    application.register_blueprint(organisation_invite_blueprint)

    complaint_blueprint.before_request(requires_admin_auth)
    application.register_blueprint(complaint_blueprint)

    platform_stats_blueprint.before_request(requires_admin_auth)
    application.register_blueprint(platform_stats_blueprint, url_prefix="/platform-stats")

    template_folder_blueprint.before_request(requires_admin_auth)
    application.register_blueprint(template_folder_blueprint)

    letter_branding_blueprint.before_request(requires_admin_auth)
    application.register_blueprint(letter_branding_blueprint)
Exemplo n.º 3
0
def register_blueprint(application):
    from app.service.rest import service_blueprint
    from app.service.callback_rest import service_callback_blueprint
    from app.user.rest import user_blueprint
    from app.template.rest import template_blueprint
    from app.status.healthcheck import status as status_blueprint
    from app.job.rest import job_blueprint
    from app.notifications.rest import notifications as notifications_blueprint
    from app.invite.rest import invite as invite_blueprint
    from app.accept_invite.rest import accept_invite
    from app.template_statistics.rest import template_statistics as template_statistics_blueprint
    from app.events.rest import events as events_blueprint
    from app.provider_details.rest import provider_details as provider_details_blueprint
    from app.email_branding.rest import email_branding_blueprint
    from app.api_key.rest import api_key_blueprint
    from app.inbound_number.rest import inbound_number_blueprint
    from app.inbound_sms.rest import inbound_sms as inbound_sms_blueprint
    from app.notifications.receive_notifications import receive_notifications_blueprint
    from app.celery.process_ses_receipts_tasks import ses_callback_blueprint, ses_smtp_callback_blueprint
    from app.notifications.notifications_sms_callback import sms_callback_blueprint
    from app.notifications.notifications_letter_callback import letter_callback_blueprint
    from app.notifications.notifications_email_callback import email_callback_blueprint
    from app.authentication.auth import requires_admin_auth, requires_auth, requires_no_auth
    from app.letters.rest import letter_job
    from app.billing.rest import billing_blueprint
    from app.organisation.rest import organisation_blueprint
    from app.organisation.invite_rest import organisation_invite_blueprint
    from app.complaint.complaint_rest import complaint_blueprint
    from app.platform_stats.rest import platform_stats_blueprint
    from app.template_folder.rest import template_folder_blueprint
    from app.letter_branding.letter_branding_rest import letter_branding_blueprint

    service_blueprint.before_request(requires_admin_auth)
    application.register_blueprint(service_blueprint, url_prefix='/service')

    user_blueprint.before_request(requires_admin_auth)
    application.register_blueprint(user_blueprint, url_prefix='/user')

    template_blueprint.before_request(requires_admin_auth)
    application.register_blueprint(template_blueprint)

    status_blueprint.before_request(requires_no_auth)
    application.register_blueprint(status_blueprint)

    # delivery receipts
    ses_callback_blueprint.before_request(requires_no_auth)
    application.register_blueprint(ses_callback_blueprint)

    ses_smtp_callback_blueprint.before_request(requires_no_auth)
    application.register_blueprint(ses_smtp_callback_blueprint)

    # TODO: make sure research mode can still trigger sms callbacks, then re-enable this
    sms_callback_blueprint.before_request(requires_no_auth)
    application.register_blueprint(sms_callback_blueprint)

    email_callback_blueprint.before_request(requires_no_auth)
    application.register_blueprint(email_callback_blueprint)

    # inbound sms
    receive_notifications_blueprint.before_request(requires_no_auth)
    application.register_blueprint(receive_notifications_blueprint)

    notifications_blueprint.before_request(requires_auth)
    application.register_blueprint(notifications_blueprint)

    job_blueprint.before_request(requires_admin_auth)
    application.register_blueprint(job_blueprint)

    invite_blueprint.before_request(requires_admin_auth)
    application.register_blueprint(invite_blueprint)

    inbound_number_blueprint.before_request(requires_admin_auth)
    application.register_blueprint(inbound_number_blueprint)

    inbound_sms_blueprint.before_request(requires_admin_auth)
    application.register_blueprint(inbound_sms_blueprint)

    accept_invite.before_request(requires_admin_auth)
    application.register_blueprint(accept_invite, url_prefix='/invite')

    template_statistics_blueprint.before_request(requires_admin_auth)
    application.register_blueprint(template_statistics_blueprint)

    events_blueprint.before_request(requires_admin_auth)
    application.register_blueprint(events_blueprint)

    provider_details_blueprint.before_request(requires_admin_auth)
    application.register_blueprint(provider_details_blueprint, url_prefix='/provider-details')

    email_branding_blueprint.before_request(requires_admin_auth)
    application.register_blueprint(email_branding_blueprint, url_prefix='/email-branding')

    api_key_blueprint.before_request(requires_admin_auth)
    application.register_blueprint(api_key_blueprint, url_prefix='/api-key')

    letter_job.before_request(requires_admin_auth)
    application.register_blueprint(letter_job)

    letter_callback_blueprint.before_request(requires_no_auth)
    application.register_blueprint(letter_callback_blueprint)

    billing_blueprint.before_request(requires_admin_auth)
    application.register_blueprint(billing_blueprint)

    service_callback_blueprint.before_request(requires_admin_auth)
    application.register_blueprint(service_callback_blueprint)

    organisation_blueprint.before_request(requires_admin_auth)
    application.register_blueprint(organisation_blueprint, url_prefix='/organisations')

    organisation_invite_blueprint.before_request(requires_admin_auth)
    application.register_blueprint(organisation_invite_blueprint)

    complaint_blueprint.before_request(requires_admin_auth)
    application.register_blueprint(complaint_blueprint)

    platform_stats_blueprint.before_request(requires_admin_auth)
    application.register_blueprint(platform_stats_blueprint, url_prefix='/platform-stats')

    template_folder_blueprint.before_request(requires_admin_auth)
    application.register_blueprint(template_folder_blueprint)

    letter_branding_blueprint.before_request(requires_admin_auth)
    application.register_blueprint(letter_branding_blueprint)