All Downloads are FREE. Search and download functionalities are using the official Maven repository.

gitbucket.core.util.AuthUtil.scala Maven / Gradle / Ivy

There is a newer version: 4.9.0
Show newest version
package gitbucket.core.util

import javax.servlet.http.HttpServletResponse

/**
 * Provides HTTP (Basic) Authentication related functions.
 */
object AuthUtil {
  def requireAuth(response: HttpServletResponse): Unit = {
    response.setHeader("WWW-Authenticate", "BASIC realm=\"GitBucket\"")
    response.sendError(HttpServletResponse.SC_UNAUTHORIZED)
  }

  def decodeAuthHeader(header: String): String = {
    try {
      new String(new sun.misc.BASE64Decoder().decodeBuffer(header.substring(6)))
    } catch {
      case _: Throwable => ""
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy