BearerToken auth in silhouette not working











up vote
0
down vote

favorite












Unable to auth with existing bearer-token in play+silhouette



I use:



trait BTEnv extends Env {
type I = User
type A = BearerTokenAuthenticator
}


controller code:



class RestController @Inject() (
components: ControllerComponents,
silhouette: Silhouette[BTEnv],
socialProviderRegistry: SocialProviderRegistry
)(
implicit
ex: ExecutionContext
) extends AbstractController(components) with I18nSupport with Logger {

def secured = silhouette.SecuredAction(WithProvider[BTEnv#A](CustomProvider.ID)) { implicit request: SecuredRequest[BTEnv, AnyContent] =>

Ok("42")
}

def unsecured = silhouette.UnsecuredAction.async {
implicit request: Request[AnyContent] => Future.successful(Ok("420"))
}

}


gist for custom provider:



https://gist.github.com/iOgre/02a4ed1eff9656e8f9bc57baf0c36d14



gist for silhouette module



https://gist.github.com/iOgre/99222d040461e699146397ae6bd075f3



I have access token received from identity server, and use it when requesting endpoint (def secured ... in provided controller code)



I pass token as:
authorization: Bearer {my-token-here}
and request returns unauthorized and redirects to predefined url
but I can't find where in code the token parsing and validating takes place



I did some debugging, but neither isAuthorized method in WithProvider
case class, nor auth functions in CustomProvider class hierarchy do not run.
at least, breakpoints did not hit










share|improve this question




























    up vote
    0
    down vote

    favorite












    Unable to auth with existing bearer-token in play+silhouette



    I use:



    trait BTEnv extends Env {
    type I = User
    type A = BearerTokenAuthenticator
    }


    controller code:



    class RestController @Inject() (
    components: ControllerComponents,
    silhouette: Silhouette[BTEnv],
    socialProviderRegistry: SocialProviderRegistry
    )(
    implicit
    ex: ExecutionContext
    ) extends AbstractController(components) with I18nSupport with Logger {

    def secured = silhouette.SecuredAction(WithProvider[BTEnv#A](CustomProvider.ID)) { implicit request: SecuredRequest[BTEnv, AnyContent] =>

    Ok("42")
    }

    def unsecured = silhouette.UnsecuredAction.async {
    implicit request: Request[AnyContent] => Future.successful(Ok("420"))
    }

    }


    gist for custom provider:



    https://gist.github.com/iOgre/02a4ed1eff9656e8f9bc57baf0c36d14



    gist for silhouette module



    https://gist.github.com/iOgre/99222d040461e699146397ae6bd075f3



    I have access token received from identity server, and use it when requesting endpoint (def secured ... in provided controller code)



    I pass token as:
    authorization: Bearer {my-token-here}
    and request returns unauthorized and redirects to predefined url
    but I can't find where in code the token parsing and validating takes place



    I did some debugging, but neither isAuthorized method in WithProvider
    case class, nor auth functions in CustomProvider class hierarchy do not run.
    at least, breakpoints did not hit










    share|improve this question


























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      Unable to auth with existing bearer-token in play+silhouette



      I use:



      trait BTEnv extends Env {
      type I = User
      type A = BearerTokenAuthenticator
      }


      controller code:



      class RestController @Inject() (
      components: ControllerComponents,
      silhouette: Silhouette[BTEnv],
      socialProviderRegistry: SocialProviderRegistry
      )(
      implicit
      ex: ExecutionContext
      ) extends AbstractController(components) with I18nSupport with Logger {

      def secured = silhouette.SecuredAction(WithProvider[BTEnv#A](CustomProvider.ID)) { implicit request: SecuredRequest[BTEnv, AnyContent] =>

      Ok("42")
      }

      def unsecured = silhouette.UnsecuredAction.async {
      implicit request: Request[AnyContent] => Future.successful(Ok("420"))
      }

      }


      gist for custom provider:



      https://gist.github.com/iOgre/02a4ed1eff9656e8f9bc57baf0c36d14



      gist for silhouette module



      https://gist.github.com/iOgre/99222d040461e699146397ae6bd075f3



      I have access token received from identity server, and use it when requesting endpoint (def secured ... in provided controller code)



      I pass token as:
      authorization: Bearer {my-token-here}
      and request returns unauthorized and redirects to predefined url
      but I can't find where in code the token parsing and validating takes place



      I did some debugging, but neither isAuthorized method in WithProvider
      case class, nor auth functions in CustomProvider class hierarchy do not run.
      at least, breakpoints did not hit










      share|improve this question















      Unable to auth with existing bearer-token in play+silhouette



      I use:



      trait BTEnv extends Env {
      type I = User
      type A = BearerTokenAuthenticator
      }


      controller code:



      class RestController @Inject() (
      components: ControllerComponents,
      silhouette: Silhouette[BTEnv],
      socialProviderRegistry: SocialProviderRegistry
      )(
      implicit
      ex: ExecutionContext
      ) extends AbstractController(components) with I18nSupport with Logger {

      def secured = silhouette.SecuredAction(WithProvider[BTEnv#A](CustomProvider.ID)) { implicit request: SecuredRequest[BTEnv, AnyContent] =>

      Ok("42")
      }

      def unsecured = silhouette.UnsecuredAction.async {
      implicit request: Request[AnyContent] => Future.successful(Ok("420"))
      }

      }


      gist for custom provider:



      https://gist.github.com/iOgre/02a4ed1eff9656e8f9bc57baf0c36d14



      gist for silhouette module



      https://gist.github.com/iOgre/99222d040461e699146397ae6bd075f3



      I have access token received from identity server, and use it when requesting endpoint (def secured ... in provided controller code)



      I pass token as:
      authorization: Bearer {my-token-here}
      and request returns unauthorized and redirects to predefined url
      but I can't find where in code the token parsing and validating takes place



      I did some debugging, but neither isAuthorized method in WithProvider
      case class, nor auth functions in CustomProvider class hierarchy do not run.
      at least, breakpoints did not hit







      playframework oauth-2.0 bearer-token silhouette






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 18 at 20:29

























      asked Nov 18 at 9:44









      udovichenko

      417




      417





























          active

          oldest

          votes











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














           

          draft saved


          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53359551%2fbearertoken-auth-in-silhouette-not-working%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown






























          active

          oldest

          votes













          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















           

          draft saved


          draft discarded



















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53359551%2fbearertoken-auth-in-silhouette-not-working%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Ottavio Pratesi

          Tricia Helfer

          15 giugno