Code Monkey home page Code Monkey logo

identity-carbon-auth-rest's Introduction

#identity-carbon-auth-rest

Custom Header Filter

Custom Header Filter to add customer headers for applications using the resource manager service.

Setting-up Guide

  1. Setup WSO2 Identity Server and enable Configuration Manager

    https://is.docs.wso2.com/en/latest/develop/using-the-configuration-management-rest-apis/

  2. Build the project using Java 11 or Java 17 and copy org.wso2.carbon.identity.custom.header.filter-${project.version}.jar to the <IS_HOME>/repository/components/dropins directory.

  3. Open deployment.toml and enable the CustomHeaderFilter by adding following lines

       [custom_header_filter]
       enable = true
    
  4. Create custom header configurations through the Configuration Manager API.

    1. Enable the Custom Header Filter by adding the resource type custom-headers.
    curl -k -X POST https://localhost:9443/api/identity/config-mgt/v1.0/resource-type \
       -H "accept: application/json" -H 'Content-Type: application/json' \
       -H 'Authorization: Basic YWRtaW46YWRtaW4=' \
       -d '{"name": "custom-headers", "description": "This is the resource type for custom header resources."}'
    
    1. Create a new app along with headers to be written.

    e.g Create a header named Content-Security for the application wso2app.

    curl -k -X POST https://localhost:9443/api/identity/config-mgt/v1.0/resource/custom-headers \
        -H "accept: application/json" -H 'Content-Type: application/json' \
        -H 'Authorization: Basic YWRtaW46YWRtaW4=' \
        -d '{"name": "wso2app","attributes": [{"key":"Content-Security", "value":"values"}]}'
    
    1. You can add headers to an existing app as follows.

    e.g Add headers to the existing wso2app app.

    curl -k -X POST https://localhost:9443/api/identity/config-mgt/v1.0/resource/custom-headers/wso2app \
         -H "accept: application/json" -H 'Content-Type: application/json' -H 'Authorization: Basic YWRtaW46YWRtaW4=' \
         -d '{"key":"Content-Security-Policy", "value":"values"}'
    

identity-carbon-auth-rest's People

Contributors

anuradhask avatar ashensw avatar chamathns avatar darshanasbg avatar dewnimw avatar dinikasen avatar emswbandara avatar harsha1979 avatar hasinidilanka avatar isurad avatar janakamarasena avatar madurangasiriwardena avatar malithie avatar piraveena avatar pulasthi7 avatar rushmin avatar sadilchamishka avatar sahandilshan avatar senthalan avatar shanggeeth avatar somindatommy avatar sumedhe avatar thamindudilshan avatar thamindur avatar thanujalk avatar thisara-welmilla avatar vihanga-liyanage avatar wso2-jenkins-bot avatar yogyagamage avatar yoshani avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

identity-carbon-auth-rest's Issues

NPE is thrown when 'Authorization' header is missing and debug logs are enabled for AuthenticationValve

Description:
Below exception is thrown when 'Authorization' header is not present in the request for a resource protected over AuthenticationValve.

java.lang.NullPointerException
	at org.wso2.carbon.identity.auth.service.handler.HandlerManager.getFirstPriorityHandler(HandlerManager.java:153)
	at org.wso2.carbon.identity.auth.service.AuthenticationManager.authenticate(AuthenticationManager.java:97)
	at org.wso2.carbon.identity.auth.valve.AuthenticationValve.invoke(AuthenticationValve.java:76)
	at org.wso2.carbon.tomcat.ext.valves.CompositeValve.continueInvocation(CompositeValve.java:99)
	at org.wso2.carbon.tomcat.ext.valves.CarbonTomcatValve$1.invoke(CarbonTomcatValve.java:47)
	at org.wso2.carbon.webapp.mgt.TenantLazyLoaderValve.invoke(TenantLazyLoaderValve.java:57)
	at org.wso2.carbon.tomcat.ext.valves.TomcatValveContainer.invokeValves(TomcatValveContainer.java:47)
	at org.wso2.carbon.tomcat.ext.valves.CompositeValve.invoke(CompositeValve.java:62)
	at org.wso2.carbon.tomcat.ext.valves.CarbonStuckThreadDetectionValve.invoke(CarbonStuckThreadDetectionValve.java:159)
	at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:962)
	at org.wso2.carbon.tomcat.ext.valves.CarbonContextCreatorValve.invoke(CarbonContextCreatorValve.java:57)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:445)
	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1115)
	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:637)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1775)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1734)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.lang.Thread.run(Thread.java:745)

Affected Product Version:
IS 5.3.0, IS 5.4.0, IS 5.4.1, IS 5.5.0

Steps to reproduce:
Try to access a protected REST API without an Authorization header.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.